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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection issue with bleeding edge rules in 1.6 #7112

Closed
kevinpapst opened this issue Apr 26, 2022 · 11 comments
Closed

Reflection issue with bleeding edge rules in 1.6 #7112

kevinpapst opened this issue Apr 26, 2022 · 11 comments

Comments

@kevinpapst
Copy link

kevinpapst commented Apr 26, 2022

Bug report

After upgrading my composer packages, my CI started failing.
This is expected and appreciated if a new phpstan release was included 馃榿 but in this case it seems to be a false-negative.

EDIT:

  • Error goes away after a manual downgrade back to 1.5.2
  • Error goes away when removing phpstan/conf/bleedingEdge.neon => fully static reflection engine?

I am running a Symfony project and I see dozens of errors like this:

        Reflection error: Psr\EventDispatcher\EventDispatcherInterface not found.  
         馃挕 Learn more at https://phpstan.org/user-guide/discovering-symbols         

I think the error is raised is in every class where a EventDispatcher is constructor injected.

I am not useing this class in my code and therefor don't mention it in my composer require section, the only place I can see it being used is in Symfony EventDispatcher, you know the code:

namespace Symfony\Contracts\EventDispatcher;

use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;

if (interface_exists(PsrEventDispatcherInterface::class)) {
    /**
     * Allows providing hooks on domain-specific lifecycles by dispatching events.
     */
    interface EventDispatcherInterface extends PsrEventDispatcherInterface
    {

Did PHPStan help you today? Did it make you happy in any way?

Always makes me happy :) that's why I am using it in every project.

@mergeable
Copy link

mergeable bot commented Apr 26, 2022

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@kevinpapst kevinpapst changed the title Regression in 1.6 Regression in 1.6 with bleeding edge Apr 26, 2022
@kevinpapst kevinpapst changed the title Regression in 1.6 with bleeding edge Reflection issue with bleeding edge rules in 1.6 Apr 26, 2022
@calvera
Copy link

calvera commented Apr 26, 2022

i have the similar issue and i have to add the error to ignore list:
message: "#^Call to method setParameter\\(\\) on an unknown class Symfony\\\\Component\\\\Validator\\\\Test\\\\ConstraintViolationAssertion\\.$#"

@calvera
Copy link

calvera commented Apr 26, 2022

see https://github.com/calvera/phpstan-bug ... run composer install and vendor/bin/phpstan

@ondrejmirtes
Copy link
Member

@calvera This class is not reachable via the configured PSR-4 autoloading. A piece of code like this will cause PHPStan to crash with an unknown class too:

<?php

use Symfony\Component\Validator\Test\ConstraintViolationAssertion;

require_once __DIR__ . "/vendor/autoload.php";

$a = new ConstraintViolationAssertion();

So I consider this a Symfony quirk. You can fix this for yourself with any method mentioned here https://phpstan.org/user-guide/discovering-symbols, or you can send a PR to Symfony so that it's fixed for everyone.

@kevinpapst
Copy link
Author

@ondrejmirtes I have the feeling that my initial report has nothing to do with @calvera issue

@ondrejmirtes
Copy link
Member

@kevinpapst Yes, it doesn't.

Yours is fixed now: ondrejmirtes/BetterReflection@72bb305 + reproduction 17b309a

@kevinpapst
Copy link
Author

Damn, your super-power is awesome: fixing bugs with the speed of light ... over and over again, very much appreciated 馃憤

I know this question is annoying, but I'd like to stick with enabled bleedingEdge rules and therefor I have to ask:
will there be a patch release soon'ish?

@ondrejmirtes
Copy link
Member

Yes, later today :)

@ondrejmirtes
Copy link
Member

@calvera I managed to fix your issue: phpstan/phpstan-src@e40474b No extra configuration will be needed in PHPStan 1.6.6 and ConstraintViolationAssertion will be discovered anyway.

@calvera
Copy link

calvera commented May 4, 2022

great! thanks

@github-actions
Copy link

github-actions bot commented Jun 5, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants