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
Adding better types #2614
Adding better types #2614
Conversation
@@ -35,7 +35,6 @@ public function has(string $name): bool | |||
return isset($this->filesystems[$name]); | |||
} | |||
|
|||
/** @return array<string> */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the interface.
|
||
if (is_array($path)) { | ||
return self::fromParts($path); | ||
} | ||
|
||
if ($path instanceof SplFileInfo) { | ||
return self::fromSplFileInfo($path); | ||
} | ||
|
||
throw new RuntimeException(sprintf( | ||
'Do not know how to create FilePath from "%s"', | ||
is_object($path) ? get_class($path) : gettype($path) | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those were only used in tests. The rest of the code already uses the correct function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they were used by tests though, removing this changes the purpose of the function (fromUnknown
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can rename to fromFilePathOrString
for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mean most other function that deal with paths also except both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible I would like to remove those kinds of methods entirely and reduce the amount of "unknown"s from phpactor. :D
/** | ||
* @return Generator<string,array{string,string,Closure(ReflectionTrait): void}> | ||
*/ | ||
public function provideReflectionTrait(): Generator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was partly returning an array and partly generator. So now there are more tests at the end that now also get executed.
692b8b7
to
d9ed777
Compare
thanks |
Using phpactor to generate return types for phpactor code.
What is in here:
isClass
andisInterface
calls from the code and replaced them with instanceof calls.