Skip to content

Decouple PHPStan Type to function resolver logic#2742

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
Lctrs:decouple
Feb 10, 2020
Merged

Decouple PHPStan Type to function resolver logic#2742
TomasVotruba merged 1 commit intorectorphp:masterfrom
Lctrs:decouple

Conversation

@Lctrs
Copy link
Copy Markdown
Contributor

@Lctrs Lctrs commented Jan 22, 2020

No description provided.

Comment thread src/PHPStan/Reflection/CallReflectionResolver.php Outdated
Comment thread config/services.yaml Outdated
@TomasVotruba
Copy link
Copy Markdown
Member

Any update on this? Looks like stale

@Lctrs
Copy link
Copy Markdown
Contributor Author

Lctrs commented Feb 6, 2020

Yeah sorry. Didn't had much time lately. Will try to finish this tomorrow.

@Lctrs
Copy link
Copy Markdown
Contributor Author

Lctrs commented Feb 7, 2020

@TomasVotruba Done.

Comment thread config/services.yaml Outdated
/**
* @param ClosureType $type
*/
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There should be return type, in interface and it's implementations

/**
* @param ClosureType $type
*/
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There should be return type, in interface and it's implementations

/**
* @return FunctionReflection|MethodReflection|null
*/
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer);
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer): ?\ReflectionFunctionAbstract`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Won't work. We're not returning a core reflection instance, but an instance of PHPStan's reflection (or null). A return type is not possible here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about object?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do they have any common parent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked and no. FunctionReflection and MethodReflection are two independant interfaces.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:(

/**
* @return FunctionReflection|MethodReflection|null
*/
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer)
public function resolve(Type $type, ClassMemberAccessAnswerer $classMemberAccessAnswerer): ?\ReflectionFunctionAbstract

@TomasVotruba
Copy link
Copy Markdown
Member

CI needs fixing

@Lctrs
Copy link
Copy Markdown
Contributor Author

Lctrs commented Feb 10, 2020

@TomasVotruba It's green 🎉

@TomasVotruba TomasVotruba merged commit a8a9886 into rectorphp:master Feb 10, 2020
@Lctrs Lctrs deleted the decouple branch February 10, 2020 14:10
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