-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Debug] Support @final
on methods
#21465
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,6 +289,28 @@ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true); | |
|
||
$this->assertSame($xError, $lastError); | ||
} | ||
|
||
public function testExtendedFinalMethod() | ||
{ | ||
set_error_handler(function () { return false; }); | ||
$e = error_reporting(0); | ||
trigger_error('', E_USER_NOTICE); | ||
|
||
class_exists(__NAMESPACE__.'\\Fixtures\\ExtendedFinalMethod', true); | ||
|
||
error_reporting($e); | ||
restore_error_handler(); | ||
|
||
$lastError = error_get_last(); | ||
unset($lastError['file'], $lastError['line']); | ||
|
||
$xError = array( | ||
'type' => E_USER_DEPRECATED, | ||
'message' => 'The Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod() method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be possible to turn this into an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I just followed the rest of the file, I guess it was done to not add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed! |
||
); | ||
|
||
$this->assertSame($xError, $lastError); | ||
} | ||
} | ||
|
||
class ClassLoader | ||
|
@@ -324,6 +346,10 @@ public function findFile($class) | |
return $fixtureDir.'DeprecatedInterface.php'; | ||
} elseif (__NAMESPACE__.'\Fixtures\FinalClass' === $class) { | ||
return $fixtureDir.'FinalClass.php'; | ||
} elseif (__NAMESPACE__.'\Fixtures\FinalMethod' === $class) { | ||
return $fixtureDir.'FinalMethod.php'; | ||
} elseif (__NAMESPACE__.'\Fixtures\ExtendedFinalMethod' === $class) { | ||
return $fixtureDir.'ExtendedFinalMethod.php'; | ||
} elseif ('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent' === $class) { | ||
eval('namespace Symfony\Bridge\Debug\Tests\Fixtures; class ExtendsDeprecatedParent extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}'); | ||
} elseif ('Test\\'.__NAMESPACE__.'\DeprecatedParentClass' === $class) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Debug\Tests\Fixtures; | ||
|
||
class ExtendedFinalMethod extends FinalMethod | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function finalMethod() | ||
{ | ||
} | ||
|
||
public function anotherMethod() | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Debug\Tests\Fixtures; | ||
|
||
class FinalMethod | ||
{ | ||
/** | ||
* @final since version 3.3. | ||
*/ | ||
public function finalMethod() | ||
{ | ||
} | ||
|
||
public function anotherMethod() | ||
{ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also apply to
@final
on the class above, isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but I think we should wait for this to be merged before doing it, to avoid conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact it's not a big deal, I can just rebase this PR if we do it in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done