Re: Consistent Class Renaming (Simple Refactoring)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 16, 2011 at 11:05:07PM +0200, Tony Mak wrote:

> 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.

Pretty sure you're *not* running PHP 2.7.2. If you are, give up now.

> 
> Example:
> <<script1.php>>
> <?php
> class A {
>   public function test(){ echo "im class A at script 1"; }
> }
> ?>
> 
> <<script2.php>>
> <?php
> class A {
>   public function test(){ echo "im class A at script 2"; }
> }
> ?>
> 
> <<cron.php>>
> <?php
> 
> include('./script1.php');
> include('./script2.php');
> ?>
> 
> 
> Cron.php will raise a "cannot redefine class A" error.

Well of course, you would get that error. But I'm completely lost beyond
that point. Why must both scripts use the same class names in them? Why
not call the class in script2.php "B" instead of "A"? I'm guessing you
left out a huge piece of explanation here.

> 
> 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?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux