Could you elaborate on this? Let's say we have the following situation:

- a.php does a full namespace import of "my_namespace".
- The <class_path>/my_namespace directory has two files (classes),
class1.php and class2.php.
- a.php has the following code:
<?php
import namespace my_namespace;
$c1 = new class1();
$c2 = new class2();
?>
- After a.php is first run, a new file, class3.php, is added.

With the above scenario, nothing will be affected if there is an opcode
cache or not. The only situation I can think of where an opcode cache can
affect this is when the script DYNAMICALLY creates classes from the imported
namespace. Maybe there's other situations, but I can't come up with any at
the moment.

Either way, I'm not sure if full namespace imports are a good idea anyways.
Issues like the one you presented are one reason, and the other is that it
is bad practice. If multiple namespaces are imported, readability is
affected (which class belongs to which namespace?). Also, if two namespaces
are imported, and one day a new class is added to one which has the same
name as another, then there will suddenly be a compile error, and the error
will be elusive.


--
Jessie


"Stanislav Malyshev" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> JH>>// 1) "my_namespace:class1" is added to the import hashtable.
> JH>>// 2) The opcode for
> JH>>"require_once('/usr/local/php-classes/my_namespace/class1.php')" is
> JH>>generated.
> JH>>// 3) "my_namespace:class2" is added to the import hashtable.
> JH>>// 4) The opcode for
> JH>>"require_once('/usr/local/php-classes/my_namespace/class2.php')" is
> JH>>generated.
> JH>>?>
>
> This means, of course, that such file could not be used with bytecode
> caches, because between runs contents of the directory can change.
>
> -- 
> Stanislav Malyshev, Zend Products Engineer
> [EMAIL PROTECTED]  http://www.zend.com/ +972-3-6139665 ext.115

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to