mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-7.4'
* PHP-7.4: Similar problem (#79022) also exists in Interfaces Fixed bug #79022 (class_exists returns True for classes that are not ready to be used)
This commit is contained in:
commit
3f3c1ad848
39
Zend/tests/bug79022.phpt
Normal file
39
Zend/tests/bug79022.phpt
Normal file
@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
Bug #79022 (class_exists returns True for classes that are not ready to be used)
|
||||
--FILE--
|
||||
<?php
|
||||
function my_autoloader($class) {
|
||||
if (class_exists('Foo', 0)) {
|
||||
new Foo();
|
||||
}
|
||||
if ($class == 'Foo') {
|
||||
eval("class Foo extends Bar{}");
|
||||
}
|
||||
|
||||
if ($class == 'Bar') {
|
||||
eval("class Bar {}");
|
||||
}
|
||||
|
||||
if ($class == 'Dummy') {
|
||||
eval ("class Dummy implements iFoo {}");
|
||||
}
|
||||
|
||||
|
||||
if (interface_exists('iFoo', 0)) {
|
||||
new Dummy();
|
||||
}
|
||||
if ($class == 'iFoo') {
|
||||
eval ("interface iFoo extends iBar {}");
|
||||
}
|
||||
|
||||
if ($class == 'iBar') {
|
||||
eval ("interface iBar {}");
|
||||
}
|
||||
}
|
||||
spl_autoload_register('my_autoloader');
|
||||
new Foo();
|
||||
new Dummy();
|
||||
echo "okey";
|
||||
?>
|
||||
--EXPECT--
|
||||
okey
|
@ -1248,7 +1248,7 @@ static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, in
|
||||
}
|
||||
|
||||
if (ce) {
|
||||
RETURN_BOOL((flags == 0 || (ce->ce_flags & flags)) && !(ce->ce_flags & skip_flags));
|
||||
RETURN_BOOL(((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags));
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -1259,7 +1259,7 @@ static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, in
|
||||
Checks if the class exists */
|
||||
ZEND_FUNCTION(class_exists)
|
||||
{
|
||||
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
|
||||
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1267,7 +1267,7 @@ ZEND_FUNCTION(class_exists)
|
||||
Checks if the class exists */
|
||||
ZEND_FUNCTION(interface_exists)
|
||||
{
|
||||
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_INTERFACE, 0);
|
||||
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED|ZEND_ACC_INTERFACE, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user