Bug #80721 [Com]: class_exists produce PHP Fatal error
Edit report at https://bugs.php.net/bug.php?id=80721&edit=1
ID: 80721
Comment by: rtrtrtrtrt at dfdfdfdf dot dfd35
Reported by: parviz at engineer dot com
Summary: class_exists produce PHP Fatal error
Status: Open
Type: Bug
Package: *General Issues
Operating System: Windows 10 Pro 64 Bit
PHP Version: 7.4Git-2021-02-07 (Git)
Block user comment: N
Private report: N
New Comment:
jesus christ your code is nonsense and results ina compile time error, class_exists() is not called
at all when invalid code is loaded and the script get killed
php -l test.php
Fatal error: Constant expression contains invalid operations in test.php on line 4
Errors parsing test.php
Previous Comments:
------------------------------------------------------------------------
[2021-02-07 11:00:00] parviz at engineer dot com
Description:
------------
when we declare a variable in a class that and initialize it like in 'Test script', and
than use class_exists with that class name, it will produce PHP Fatal error
Test script:
---------------
<?php
class TestClass {
public object $testVar = (object) [
'status' => false
];
}
var_dump( class_exists('TestClass') );
Expected result:
----------------
return bool that tell us the class exists or not
Actual result:
--------------
Fatal error: Constant expression contains invalid operations in D:\XAMPP\htdocs\test.php on line 4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80721&edit=1
Thread (5 messages)