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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstantArrayType: fix returned ConstantArrayTypeAndMethod #3372

Open
wants to merge 2 commits into
base: 1.12.x
Choose a base branch
from

Conversation

janedbal
Copy link
Contributor

@janedbal janedbal commented Aug 30, 2024

With this, we can recognize those cases:

class Parnt
{
	public function __construct()
	{
		array_map([self::class, 'method1'], [1]); // calls Parnt::method1
		array_map([$this, 'method1'], [1]); // calls Child::method1
	}

	public function method1(): void {
	    echo 'parent';
	}
	
}

class Child extends Parnt
{
	public function __construct()
	{
		parent::__construct();
	}

	public function method1(): void {
	    echo 'child';
	}
	
}

new Child();

@staabm
Copy link
Contributor

staabm commented Sep 1, 2024

Is missing a test

@janedbal
Copy link
Contributor Author

janedbal commented Sep 2, 2024

I'm not sure if there is any native functionality to test against. I need this function for proper dead-code analysis.

@ondrejmirtes
Copy link
Member

If nothing else is possible then we need a unit test in ConstantArrayTypeTest. Make sure to initialize $this->createReflectionProvider() so that the Type works properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants