Allow is_subclass_of with second parameter of type class-string#397
Closed
romm wants to merge 1 commit intophpstan:1.5.xfrom
Closed
Allow is_subclass_of with second parameter of type class-string#397romm wants to merge 1 commit intophpstan:1.5.xfrom
is_subclass_of with second parameter of type class-string#397romm wants to merge 1 commit intophpstan:1.5.xfrom
Conversation
d45166a to
3526237
Compare
The following code should not report an error anymore:
```php
class SomeClass
{
/**
* @param class-string $classString
*/
public function foo(string $classString): bool
{
return is_subclass_of(DateTimeInterface::class, $classString);
}
/**
* @param class-string<object> $classString
*/
public function bar(string $classString): bool
{
return is_subclass_of(DateTimeInterface::class, $classString);
}
}
```
But this one will still report an error:
```php
class SomeClass
{
/**
* @param class-string<DateTimeInterface> $classString
*/
public function foo(string $classString): bool
{
return is_subclass_of(DateTimeInterface::class, $classString);
}
}
```
e417b79 to
f39ebd3
Compare
efd31ce to
0471f87
Compare
Contributor
|
both mentioned cases of the PR description seem to be fixed https://phpstan.org/r/f10c4833-22f6-4836-a2df-d6fd9cd822b1 I guess this can be closed. @romm could you confirm? |
Contributor
|
looking at the example in phpstan/phpstan#2755 which this PR is trying to fix, it seems there is still a issue though..? |
Contributor
|
Yeah, my original issue isn't fixed yet. I'm not sure if this PR would fix it though since that case isn't in the tests. |
ddd20b4 to
95d480b
Compare
Member
Contributor
|
@ondrejmirtes I fixed the origin problem with #1321 this PR here as is does no longer fix a real issue and can be closed IMO |
Member
|
Okay :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following code should not report an error anymore:
But this one will still report an error:
Closes phpstan/phpstan#2755