Bug #55246 [Bgs]: instanceof does not complain even if class is never defined
| From: | x11 at arturaz dot net | Date: | Wed, 20 Jul 2011 08:34:57 +0000 |
| Subject: | Bug #55246 [Bgs]: instanceof does not complain even if class is never defined | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162027@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55246&edit=1
ID: 55246
User updated by: x11 at arturaz dot net
Reported by: x11 at arturaz dot net
Summary: instanceof does not complain even if class is never
defined
Status: Bogus
Type: Bug
Package: Compile Failure
Operating System: Ubuntu Linux
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
How it's possibly useful to test if object is an instance of class which is not even defined?
Previous Comments:
------------------------------------------------------------------------
[2011-07-20 04:33:47] pajoye@php.net
That's the exact idea of instanceof to test something without getting noises.
------------------------------------------------------------------------
[2011-07-20 04:31:42] x11 at arturaz dot net
Description:
------------
PHP does not complain if you check for non-existant class with instanceof.
This provides space for subtle errors, like checking for DateRange when only Date_Range class is
defined.
Test script:
---------------
<?php
echo PHP_VERSION . "\n";
error_reporting(E_ALL);
class Foo {}
$a = new Foo;
// Notice that Bar class is never defined, however PHP does not complain about missing class.
if ($a instanceof Bar) { echo "Should be an error\n"; }
else { echo "PHP fail\n"; }
Expected result:
----------------
Compiler error thrown saying that Bar was not found.
Actual result:
--------------
Nothing happens.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55246&edit=1