ID:               27406
 Updated by:       [EMAIL PROTECTED]
 Reported By:      thomas at stauntons dot org
-Status:           Bogus
+Status:           Open
-Bug Type:         Zend Engine 2 problem
+Bug Type:         Unknown/Other Function
 Operating System: OS X
-PHP Version:      5.0.0b4 (beta4)
+PHP Version:      5.0.0
 Assigned To:      iliaa
 New Comment:

So should this function actually execute the code (like an include())
or should it be a simple lint check (identical to php -l).  The doc
team assumed the later.  Please advise with specific information on how
this should be documented or if this is indeed a bug, say so.

http://cvs.php.net/co.php/phpdoc/en/reference/misc/functions/php-check-syntax.xml



Previous Comments:
------------------------------------------------------------------------

[2004-08-08 18:59:20] phpbug at bigredspark dot com

Bogus? Could someone document this function so we know what the
"proper" usage is? Is this funtion meant to load the file into the
current scope as it's syntax is checked? If so, please say so in the
documentation. Otherwise, I have another bug report to file.

original.php
<?php
$bool = php_check_syntax('checkme.php');
foo();
$bar = new Bar;
$bar->foo();
?>

checkme.php
<?php
function foo()
{ echo "checkme::foo\n"; }
class Bar {
    function foo()
    { echo "checkme::bar::foo\n"; }
}
?>

results in

checkme::foo
checkme::bar::foo

for example, when my assumption of how the function works should have
the code results in undefined function and class errors.

------------------------------------------------------------------------

[2004-04-13 13:12:03] [EMAIL PROTECTED]

Don't misuse the function.


------------------------------------------------------------------------

[2004-02-26 15:18:57] [EMAIL PROTECTED]

Ilia, maybe this function wasn't such a good idea after all?
Here's the first misuse of it already..


------------------------------------------------------------------------

[2004-02-26 11:00:17] thomas at stauntons dot org

Description:
------------
I am writing a class that will include another file 
containing a class that needs to implement a specific 
interface. When calling php_check_syntax on the file its 
behavious differs depending on whether or not the class 
implements my interface. If the file implements my 
interface the class will not show up in 
get_declared_classes() and an include() of the file will 
work, but if the class doesn't implement my interface the 
class will be in get_declared_classes() and the include 
will fail with 'cannot redeclareclass'

Reproduce code:
---------------
in Main.php
<?php
interface MustImplement {}
if (!php_check_syntax('includeme.php'))
        die('Bad Syntax\n');
else include('includeme.php');
?>
in includeme.php (Case 1)
<?php
class AClass implements MustImplement
{}
?>
in includeme.php (Case 2)
<?php
class AClass
{}
?>

Expected result:
----------------
Case 1 of includeme.php will work OK, php_syntax_check will 
succeed and include will load the file OK, AClass will be 
available. 

Case 2 will fail, php_syntax_check will work but include 
will fail with 'cannot redeclare class' & Illegal 
Instruction

Actual result:
--------------
Just as Above. 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27406&edit=1

Reply via email to