Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method className(), don't break BC third party extensions. #19973

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
{
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
Loading