Bug #53945 [Opn->Bgs]: Self descriptive
| From: | johannes@php.net | Date: | Mon, 07 Feb 2011 11:48:49 +0000 |
| Subject: | Bug #53945 [Opn->Bgs]: Self descriptive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158543@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53945&edit=1
ID: 53945
Updated by: johannes@php.net
Reported by: knight_adi2000 at yahoo dot com
Summary: Self descriptive
-Status: Open
+Status: Bogus
Type: Bug
Package: Compile Failure
Operating System: Windows Vista ultimate
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
PHP does not require types to be declared at compile time. Code like
this is absolutely valid:
main.php:
<?php
for ($i = 0; $i < 10; ++$i) {
include "$i.php";
if ($throw == 1) throw new Excepion('Exception thrown.<br>');
}
an then in 5.php or so:
<?php
class Excepion extends Exception {}
Or there's __autoload ...
Previous Comments:
------------------------------------------------------------------------
[2011-02-07 10:16:32] knight_adi2000 at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/language.exceptions
---
Notice the line
if($throw_exception === 1) throw new Excepion('Exception thrown.<br>');
has Excepion NOT Exception word inside the code .
This is not detected by the compiler when compiling the code , unless
you set the
value Int 1 as parameter, in order to make the function throw the error
, and
there is no class that i defined as Excepion , it can be replaced with
any class
not only Excepion (Not Exception) .
Unless the function is made to throw an Exception, it does not detect
that the
actual object simply does NOT exist(in this case the object caled
Excepion) .
Be carefull with writing your code .
Test script:
---------------
<?php
function test_compiler($throw_exception)
{
try {
if($throw_exception === 1) throw new Excepion('Exception
thrown.<br>');
}
catch(Exception $exception)
{
echo "Error caught from test_compiler". $exception->getMessage();
}
return 1;
}
echo test_compiler(2);
?>
Expected result:
----------------
When i set the $throw_exception to other value than 1 integer type, the
compiler
should detect that the Excepion (NOT Exception ) object does NOT exist
.
Actual result:
--------------
The compiler detects that the Excepion object DOES NOT exist ONLY IF the
value is
set to integer 1 , than and only than the compiler works right in this
case .
Please Php Staff take this into your atention .
Thank you .
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53945&edit=1