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

Add type for ObjectManager helper for tests #47

Merged

Conversation

shochdoerfer
Copy link
Member

No description provided.

): Type {
$className = $scope->getType($methodCall->args[0]->value)->getValue();
if (!is_subclass_of($className, \Magento\Framework\Data\Collection::class)) {
new \PHPStan\Type\MixedType();
Copy link
Member Author

Choose a reason for hiding this comment

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

@ondrejmirtes would it be possible here to return "an error" when a wrong implementation is passed? I tried to throw a ShouldNotHappenException but that killed phpstan ;(

MethodCall $methodCall,
Scope $scope
): Type {
return TypeCombinator::addNull(new ArrayType(new StringType(), new MixedType()));
Copy link
Member Author

Choose a reason for hiding this comment

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

@ondrejmirtes would it be possible here to define the keys and values of the array? Magento would filter out the array that is passed the method and return only valid dependencies. Would be cool to mimic this there if phpstan could also check further on the contents of the array.

@shochdoerfer shochdoerfer changed the title WIP: Add type for ObjectManager helper for tests Add type for ObjectManager helper for tests Jan 6, 2021
@shochdoerfer shochdoerfer merged commit 609c91f into bitExpert:master Jan 6, 2021
@shochdoerfer shochdoerfer deleted the feature/objectmanager_unittests branch August 7, 2021 08:05
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.

None yet

1 participant