-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
When a class depends on an interface, that takes a callable argument, after changing the typehint in docblock on the interface, the class is still analysed as-if the previous typehint was present
Code snippet that reproduces the problem
- Create TestInterface.php:
<?php
interface TestInterface
{
/**
* @param callable(string): void $do
*/
public function test(callable $do): void;
}
and Executor.php:
<?php
final class Executor implements TestInterface
{
public function test($do): void
{
$do('z');
}
}
- Run ./vendor/bin/phpstan analyse --level 8 TestInterface.php Executor.php (there will be no errors - as expected)
- Change the typehint on TestInterface (the closure got a second argument):
<?php
interface TestInterface
{
/**
* @param callable(string, string): void $do
*/
public function test(callable $do): void;
}
- Run ./vendor/bin/phpstan analyse --level 8 TestInterface.php Executor.php (there will be no errors, which is now incorrect). If any change to Executor.php is made, the errors appear as expected.
Expected output
2/2 [============================] 100%
------ -------------------------------------------------------------------------------
Line Executor.php
------ -------------------------------------------------------------------------------
6 Callable callable(string, string): void invoked with 1 parameter, 2 required.
------ -------------------------------------------------------------------------------
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels