[PHP] Consistent Class Renaming (Simple Refactoring)

2011-05-16 Thread Tony Mak

Hi there,

i have following problem:

Assume we have a "cron.php" which is called every hour by a cron job. 
This cron.php should then be used to execute other php-scripts 
"script1.php", "script2.php".


For a pitty our server has Safe-Mode activated so we arent able to 
shell_exec / exec those files. So we came up with the idea: Lets include 
those scripts using include(). But this lead us to another problem: 
Namespace conflicts (our server is running php 2.7.2) especially with 
classes and constants.


Example:
<>


<>


<>



Cron.php will raise a "cannot redefine class A" error.

So my idea is to continously rename every occurence of class names and 
constants in the scripts by adding a suffix (ie. class A_123 and class 
A_234). Do you have an idea how to implement this during the deployment 
step?


Sincerly yours

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Consistent Class Renaming (Simple Refactoring)

2011-05-16 Thread Tony Mak

Hi there,

i have following problem:

Assume we have a "cron.php" which is called every hour by a cron job. 
This cron.php should then be used to execute other php-scripts 
"script1.php", "script2.php".


For a pitty our server has Safe-Mode activated so we arent able to 
shell_exec / exec those files. So we came up with the idea: Lets include 
those scripts using include(). But this lead us to another problem: 
Namespace conflicts (our server is running php 2.7.2) especially with 
classes and constants.


Example:
<>


<>


<>



Cron.php will raise a "cannot redefine class A" error.

So my idea is to continously rename every occurence of class names and 
constants in the scripts by adding a suffix (ie. class A_123 and class 
A_234). Do you have an idea how to implement this during the deployment 
step?


Sincerly yours

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Consistent Class Renaming (Simple Refactoring)

2011-05-17 Thread Tony Mak

Thanks for your replys.

Of course >>PHP 2.7.2<< was a careless mistake, i meant PHP 5.2.7, to 
underline i'm not able to use those neat namespace features in PHP 5.3.



Let me provide you with more details.

As already mentioned cron.php should include at least two other 
php-scripts because shell_exec cannot be called in safe-mode (which is 
on). I am able to manipulate those scripts but as they could be quite 
complex i dont want to check precisely.
But if I include them they probably could share the same classnames for 
a semantically different class.
I just wanted to know if there is already a solution which could detect 
those overlappings or prevent them by consistently renaming the classes 
(ie class A in script1 gets class A_1 and class A in script2 gets class 
A_2, and all class-calls get "new A"=> ("new A_1" | "new A_2") and 
"A::xx" => ("A_1::xx" | "A_2::xx") ).



Is there a specification in php which says how classes could exactly be 
defined and called? Because im afraid that there will be more 
dependencies to change then (ie Same-named constructor methods (backward 
compatibility)). If there is i could write a script which renames the 
classes automatically.


Otherwise i would have to wait until server updates to >=5.3
Sincerly yours,
toni

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php