Test failures with PHPStan dev-master
ondrejmirtes opened this issue · 4 comments
Hi @eiriksm, after your latest changes in phpstan-src, there are now failures in this repo:
1) PHPStan\Rules\Deprecations\CallToDeprecatedMethodRuleTest::testDeprecatedMethodCall
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
'07: Call to deprecated method deprecatedFoo() of class CheckDeprecatedMethodCall\Foo.
+10: Call to deprecated method deprecatedFoo() of class CheckDeprecatedMethodCall\Bar.
11: Call to deprecated method deprecatedFoo2() of class CheckDeprecatedMethodCall\Foo.
14: Call to deprecated method deprecatedFooFromTrait() of class CheckDeprecatedMethodCall\Foo.
15: Call to deprecated method deprecatedWithDescription() of class CheckDeprecatedMethodCall\Foo:
Call a different method instead.
'
phar:///home/runner/work/phpstan/phpstan/extension/vendor/phpstan/phpstan/phpstan.phar/src/Testing/RuleTestCase.php:84
/home/runner/work/phpstan/phpstan/extension/tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php:23
2) PHPStan\Rules\Deprecations\CallToDeprecatedStaticMethodRuleTest::testDeprecatedStaticMethodCall
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
'06: Call to deprecated method deprecatedFoo() of class CheckDeprecatedStaticMethodCall\Foo.
+08: Call to deprecated method deprecatedFoo() of class CheckDeprecatedStaticMethodCall\Bar.
09: Call to deprecated method deprecatedFoo2() of class CheckDeprecatedStaticMethodCall\Foo.
11: Call to method foo() of deprecated class CheckDeprecatedStaticMethodCall\Foo.
12: Call to method deprecatedFoo() of deprecated class CheckDeprecatedStaticMethodCall\Foo.
@@ @@
Do not touch this at all.
16: Call to deprecated method deprecatedWithDescription() of class CheckDeprecatedStaticMethodCall\Foo:
This is probably a singleton.
-24: Call to deprecated method deprecatedFoo() of class CheckDeprecatedStaticMethodCall\Foo.
'
Can you please look into it so we know what needs fixing? If the tests asserts here are reasonable then phpstan-src needs fixing, or these asserts need to be edited.
OK so the reason is
class Bar extends Foo
{
public function deprecatedFoo()
{
}
}
// Shortened for relevance.
class Foo
{
/**
* @deprecated
*/
public function deprecatedFoo()
{
}
}
Now Bar::deprecatedFoo is marked as deprecated. My editor thinks it's not deprecated. Only when I add
/**
* {@inheritdoc}
*/
to the method, phpstorm thinks so. Personally I think we should have the current behaviour (that's failing the tests), so just adjust the assertions. What do you think?
The same is the case for the other test failure regarding static methods. Except the missing error, which is now not marked as deprecated because of the first line where
if (DeprecatedScopeHelper::isScopeDeprecated($scope)) {
return [];
}
Scope is apparently deprecated when it's a static function? Not sure about this one.
Will open a PR which fixes the tests at least (with adjusting them).
Hi, I'm having this problem with PHPStan 1.3.0 with this kind of code:
class LifecycleEventArgs
{
private object $object;
public function __construct(object $object)
{
$this->object = $object;
}
/**
* @deprecated
*/
public function getEntity(): object
{
return $this->object;
}
public function getObject(): object
{
return $this->object;
}
}
class ORMLifecycleEventArgs extends BaseLifecycleEventArgs
{
public function getEntity(): object
{
return $this->getObject();
}
}I'm getting:
Call to deprecated method getEntity() of class Doctrine\ORM\Event\LifecycleEventArgs.
@franmomu This is an expected change after phpstan/phpstan-src#792. Feel free to ignore it: https://phpstan.org/user-guide/ignoring-errors
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.