-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Deprecation warnings "Non-static method should not be called statically" after upgrading to v6.3.0 #746
Comments
Well, you are giving the class name and the method name. If no magic happens somewhere else (reading the docs for silly, I think there is no magic), then this array (first element a string with a classname, second element a string with a method name) is a callable resolving into a static call. If you really need an instance of Otherwise you may also switch the |
Hi thanks for the report. It does sound like a bug though 🤔 I will be assuming that you setup PHP-DI with Silly and that:
What PHP-DI should do (expected behavior) is detect that For some reason there may be a regression here. |
If you did configure |
I have autowiring enabled so I did not configure the command manually. Indeed PHP-DI still seems to work properly, the method gets called, it's just this warning that now shows up. I have multiple commands like this configured and every time I run any CLI command I get a warning for each of those commands. |
We were still using Symfony v4 components in our codebase, and after upgrading everything to v5.* the deprecation warnings also seemed to disappear. |
Sorry I spoke too soon. I thought it was working, but it was only working because Invoker 2.1.0 was still in my composer.lock file. When it updated to 2.2.0 again I got the same errors again. |
Ideally if you're able to show how to reproduce that with a minimal example that would be great. |
Setting error_reporting to all gives you the deprecation notice even with a minimal setup: <?php
error_reporting(E_ALL);
require __DIR__ . '/vendor/autoload.php';
$app = new Silly\Edition\PhpDi\Application();
$app->command('test', [\Chris\Test\Foo::class, 'bar']);
$app->run(); <?php
namespace Chris\Test;
use Symfony\Component\Console\Output\OutputInterface;
class Foo
{
public function bar(OutputInterface $output)
{
$output->writeln('Test');
}
} It doesn't give the deprecation notice with Invoker 2.1 |
Looking into this a bit more, by removing the "callable" type hint in CallableReflection::create the notice seems to be gone. But that's weird since the callable seems to be valid (even in PHP8) The callable before it's resolved:
The callable after it's resolved:
The string gets correctly replaced with the class instance.. and that should be a valid callable? Yet the deprecation notice is triggered. |
This should be fixed by upgrading Let me know if the problem is still there. |
Hi,
We use PHP-DI in combination with Silly and since upgrading to PHP-DI 6.3.0 we get these kind of warnings when running CLI commands:
This is the command definition:
It does still seem to work fine though, it only seems to be a notice.
I guess this is a bug in Invoker but since we do not explicitly depend on that ourselves I thought I'd make the issue in this project. I can add this issue in that project as well if you prefer.
The text was updated successfully, but these errors were encountered: