php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59165 bcompiling a file that has the same function name causes failure
Submitted: 2010-04-15 23:50 UTC Modified: 2010-04-16 11:17 UTC
From: alecgorge at gmail dot com Assigned:
Status: Not a bug Package: bcompiler (PECL)
PHP Version: 5.3.2 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alecgorge at gmail dot com
New email:
PHP Version: OS:

 

 [2010-04-15 23:50 UTC] alecgorge at gmail dot com
Description:
------------
If you try bcompiling a file that has the same function or class names, it gives you a fatal error about redeclaring functions.

I cannot think of a reason this should happen, but if I am missing one, tell me!

Reproduce code:
---------------
<?php
// bcompile.php

// move to right dir when running in CLI
chdir(dirname(__FILE__));

function bcompileFile ($file) {
	$fhandle = fopen('temp.txt', 'w');
	bcompiler_write_header($fhandle);
	bcompiler_write_file($fhandle, $file);
	bcompiler_write_footer($fhandle);
	fclose($fhandle);
}

bcompileFile('bcompile.php');
?>

Expected result:
----------------
no output and temp.txt containing the bcompiled file

Actual result:
--------------
H:\bcompiler\php>php -f H:\bcompiler\bcompile.php

Fatal error: Cannot redeclare bcompileFile() (previously declared in H:\bcompiler\bcompile.php:7) in H:\bcompiler\bcompile.php on line 13


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-16 02:09 UTC] alan at akbkhome dot com
Sorry, but your problem does not imply a bug in PECL itself.  For a
list of more appropriate places to ask for help using PECL, please
visit http://pecl.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PECL.

bcompiler_write_file($fhandle, $file);
will import the file into the global context - since you are compiling the file you are running - this will be just the same as including it hence redefining the function.

basically do compile the file you are running..
 [2010-04-16 02:10 UTC] alan at akbkhome dot com
that should have said do not...
 [2010-04-16 07:44 UTC] alecgorge at gmail dot com
this is an unexpected behavior isn't documented anywhere, and doesn't make any sense from a users perspective, which I think makes it perfectly valid for a bug report.

if this is for some reason the intended performance, I would love to know why.

you have to at least agree that not importing it into the global scope would make more sense--if possible.
 [2010-04-16 11:17 UTC] val@php.net
Compiling a file is the same as including it to the global scope. Actually, bcompiler_write_file() works exactly like include() up to the execution stage.

If you want to include some parts of an already included file, you can use bcompuiler_write_class() or bcompiler_write_function().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC