Req #66889 [Com]: ReflectionException message should have quotes around class name

From: Date: Mon, 17 Mar 2014 21:37:10 +0000
Subject: Req #66889 [Com]: ReflectionException message should have quotes around class name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184816@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66889&edit=1 ID: 66889 Comment by: sam at rmcreative dot ru Reported by: sam at rmcreative dot ru Summary: ReflectionException message should have quotes around class name Status: Open Type: Feature/Change Request Package: Reflection related Operating System: All PHP Version: 5.4.26 Block user comment: N Private report: N New Comment: I'm not parsing it. I'm reading it as a human. The cause of such error is a typo. Previous Comments: ------------------------------------------------------------------------ [2014-03-12 17:21:27] requinix@php.net Don't parse error messages for information. If you want to know if a class exists then use class_exists(). If you don't like that then use a try/catch block. Of course there's also the question of why your code is trying to reflect an invalid class. $class = '\hey\there\is\Space '; try { new ReflectionClass($class); } catch (ReflectionException $re) { echo "'{$class}' does not exist"; } ------------------------------------------------------------------------ [2014-03-12 11:16:56] sam at rmcreative dot ru Description: ------------ Currently if there's a space in class name such as new \ReflectionClass('\hey\there\is\Space '), it's very hard to get it from error message: Fatal error: Uncaught exception 'ReflectionException' with message 'Class \hey\t here\is\Space does not exist' in ... Would be great to have it like the following: Fatal error: Uncaught exception 'ReflectionException' with message 'Class "\hey\t here\is\Space " does not exist' in ... Test script: --------------- <?php new \ReflectionClass('\hey\there\is\Space '); Expected result: ---------------- Exception with class name in quotes Actual result: -------------- Exception with class name w/o quotes ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66889&edit=1

« previous php.bugs (#184816) next »