Skip to content

Commit

Permalink
Add method className(), don't break BC third party extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Sep 22, 2023
1 parent 6618aa8 commit 726e641
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

Check warning on line 291 in framework/base/BaseObject.php

View check run for this annotation

Codecov / codecov/patch

framework/base/BaseObject.php#L291

Added line #L291 was not covered by tests
{
return static::class;

Check warning on line 293 in framework/base/BaseObject.php

View check run for this annotation

Codecov / codecov/patch

framework/base/BaseObject.php#L293

Added line #L293 was not covered by tests
}
}
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 726e641

Please sign in to comment.