php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53945 Self descriptive
Submitted: 2011-02-07 10:16 UTC Modified: 2011-02-07 12:48 UTC
From: knight_adi2000 at yahoo dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: Irrelevant OS: Windows Vista ultimate
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: knight_adi2000 at yahoo dot com
New email:
PHP Version: OS:

 

 [2011-02-07 10:16 UTC] 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 .

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 12:48 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2011-02-07 12:48 UTC] johannes@php.net
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 ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC