-
Notifications
You must be signed in to change notification settings - Fork 504
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
Fix ImpossibleCheckTypeFunctionCallRule for is_subclass_of
and is_a
#3404
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
10eb37a
Solve bug 3979
VincentLanglet 5660991
Improve test
VincentLanglet 9a83639
Proof
VincentLanglet 231568c
Improve
VincentLanglet 8d67889
Fix test
VincentLanglet febbb63
More failing tests
VincentLanglet de163dc
Try another fix
VincentLanglet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
|
||
namespace Bug3979; | ||
|
||
class A { } | ||
class B extends A { } | ||
class C { } | ||
|
||
/** | ||
* @param mixed $value | ||
* @param string $class_type | ||
*/ | ||
function check_class($value, $class_type): bool | ||
{ | ||
if (!is_string($value) || !class_exists($value) || | ||
($class_type && !is_subclass_of($value, $class_type))) | ||
return false; | ||
return true; | ||
} | ||
|
||
var_dump(check_class("B", "A")); // true | ||
var_dump(check_class("C", "A")); // false | ||
|
||
/** | ||
* @param class-string $value | ||
* @param string $class_type | ||
*/ | ||
function check_class2($value, $class_type): bool | ||
{ | ||
if (is_a($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param class-string|object $value | ||
* @param string $class_type | ||
*/ | ||
function check_class3($value, $class_type): bool | ||
{ | ||
if (is_a($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param class-string|object $value | ||
* @param string $class_type | ||
*/ | ||
function check_class4($value, $class_type): bool | ||
{ | ||
if (is_subclass_of($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param object $value | ||
* @param string $class_type | ||
*/ | ||
function check_class5($value, $class_type): bool | ||
{ | ||
if (is_a($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param object $value | ||
* @param string $class_type | ||
*/ | ||
function check_class6($value, $class_type): bool | ||
{ | ||
if (is_subclass_of($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param object $value | ||
* @param class-string $class_type | ||
*/ | ||
function check_class7($value, $class_type): bool | ||
{ | ||
if (is_a($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param object $value | ||
* @param class-string $class_type | ||
*/ | ||
function check_class8($value, $class_type): bool | ||
{ | ||
if (is_subclass_of($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param class-string $value | ||
* @param class-string $class_type | ||
*/ | ||
function check_class9($value, $class_type): bool | ||
{ | ||
if (is_a($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param class-string $value | ||
* @param class-string $class_type | ||
*/ | ||
function check_class10($value, $class_type): bool | ||
{ | ||
if (is_subclass_of($value, $class_type, true)) { | ||
return true; | ||
} | ||
return false; | ||
} |
Oops, something went wrong.
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.
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.
specified
$object
asobject
but this was already known so it's not a big loss.