Bug #74454 [Ver->Csd]: Wrong exception being thrown when using ReflectionMethod

From: Date: Wed, 05 Sep 2018 13:12:49 +0000
Subject: Bug #74454 [Ver->Csd]: Wrong exception being thrown when using ReflectionMethod
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216890@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74454&edit=1 ID: 74454 Updated by: cmb@php.net Reported by: premavansmuuf at gmail dot com Summary: Wrong exception being thrown when using ReflectionMethod -Status: Verified +Status: Closed Type: Bug Package: Reflection related Operating System: WSL/Ubuntu 16.04 PHP Version: 7.0.18 Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=c0a389a9277070f5ef53c230f34aa5072a9f0985 Log: Fix #74454: Wrong exception being thrown when using ReflectionMethod Previous Comments: ------------------------------------------------------------------------ [2018-09-05 12:44:05] cmb@php.net Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2017-04-16 12:19:08] premavansmuuf at gmail dot com Description: ------------ Trying to get a reflection of method of class located inside a file with syntax error that is being included via autoloader results in a ReflectionException instead of ParseError. Note that if one tries $x = new ReflectionClass('A'); instead, correct expected ParseError is thrown. Test script: --------------- --- FILE index.php <?php spl_autoload_register('load_file'); try { $x = new ReflectionMethod('A', 'b'); } catch (\Throwable $e) { echo get_class($e) . ': ' . $e->getMessage(); } function load_file() { require __DIR__ . '/syntaxerror.php'; } --- FILE syntaxerror.php <?php class A { if (wrongsyntax) } Expected result: ---------------- ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) Actual result: -------------- ReflectionException: Class A does not exist ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74454&edit=1

« previous php.bugs (#216890) next »