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

Update ServiceMap.php #7

Merged
merged 1 commit into from
May 28, 2024
Merged

Conversation

daniellz
Copy link
Contributor

fix: correct FQCN retrieval in getServiceClassFromNode method

In the getServiceClassFromNode method, replaced the usage of $node->class->getFirst() with $node->class->toString() to correctly retrieve the full class name (FQCN). This fix ensures proper handling of fully qualified class names in class constant fetches.

fix: correct FQCN retrieval in getServiceClassFromNode method

In the getServiceClassFromNode method, replaced the usage of $node->class->getFirst() 
with $node->class->toString() to correctly retrieve the full class name (FQCN). 
This fix ensures proper handling of fully qualified class names in class constant fetches.
@erickskrauch erickskrauch self-requested a review May 28, 2024 16:05
Copy link
Owner

@erickskrauch erickskrauch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please provide some code samples to understand, which case it covers? You can just send the code in a reply, no need to try to invent a test.

@daniellz
Copy link
Contributor Author

Can you please provide some code samples to understand, which case it covers? You can just send the code in a reply, no need to try to invent a test.

For cases where we have FQCN as keys in the DI config, like:

$config['container']['definitions'][Client::class] => function ($container, $params = [], $config = []) : Client
{
    //some params preparations
    return new Client($params);
}

And before fix we get error on this code:

$client = Yii::$container->get(Client::class);
$res = $client->get($url);

phpstan: Call to an undefined method object::get().

@erickskrauch erickskrauch merged commit f561249 into erickskrauch:master May 28, 2024
4 checks passed
@erickskrauch
Copy link
Owner

@daniellz, thanks for this PR :)

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.

2 participants