Skip to content

Commit

Permalink
Merge pull request #19973 from terabytesoftw/add-classname-base-object
Browse files Browse the repository at this point in the history
Add method `className()`, don't break `BC` third party extensions.
  • Loading branch information
bizley authored Sep 23, 2023
2 parents 6618aa8 + 726e641 commit 1cb372d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions framework/base/BaseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,14 @@ public function hasMethod($name)
{
return method_exists($this, $name);
}

/**
* Returns the fully qualified name of this class.
*
* @return string the fully qualified name of this class.
*/
public static function className(): string
{
return static::class;
}
}
5 changes: 5 additions & 0 deletions tests/framework/base/BaseObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public function testReadingWriteOnlyProperty()
$this->expectExceptionMessage('Getting write-only property: yiiunit\framework\base\NewObject::writeOnly');
$this->object->writeOnly;
}

public function testClassName(): void
{
$this->assertSame(NewObject::class, $this->object::className());
}
}


Expand Down

0 comments on commit 1cb372d

Please sign in to comment.