-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch refs/heads/1.12.x into 2.1.x
- Loading branch information
Showing
6 changed files
with
168 additions
and
9 deletions.
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; | ||
} |