Bug #80721 [Com]: class_exists produce PHP Fatal error

From: Date: Sun, 07 Feb 2021 11:12:21 +0000
Subject: Bug #80721 [Com]: class_exists produce PHP Fatal error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231980@lists.php.net to get a copy of this message
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.4.8 Block user comment: N Private report: N New Comment: you can't do type-casting at that level of code, there are also other limitations besides typed-properties in a class definition virtually forever class TestClass { public int $testVar = (int)'1'; } $x = new TestClass; Previous Comments: ------------------------------------------------------------------------ [2021-02-07 11:07:05] parviz at engineer dot com PHP Version: 7.4.8 ------------------------------------------------------------------------ [2021-02-07 11:05:57] rtrtrtrtrt at dfdfdfdf dot dfd35 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#231980) next »