Re: merging Controversial changes back into PEAR2 Standards
| From: | Travis Swicegood | Date: | Mon, 24 Sep 2007 01:16:59 +0000 |
| Subject: | Re: merging Controversial changes back into PEAR2 Standards | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-48143@lists.php.net to get a copy of this message | ||
On Sep 23, 2007, at 5:53 PM, Gregory Beaver wrote:
<?php import Blah::Blah; $a = new Blah; ?> yields: Fatal error: Class 'Blah::Blah' not found in /home/cellog/workspace/php6/test.php on line 3Excellent...
import is unaffected by anything, it is not file-conscious except that it only applies to the file that it is within. As far as PHP is concerned, Phar files are identical to filesystem files.Also excellent on both accounts. I knew the namespace keyword was file level and it would make sense that the import keyword would be the same, but you never know :-)
I had proposed renaming "import" to "alias" but this was thrown out :).Seems like there is/has been a lot of things being thrown out that make sense... :-(
PHP namespaces are designed solely to solve the problem of conflicting classnames and of long class names. As such, import does not actually load any code, "import X as Y;" only tells the PHP interpreter "when you see X, pretend it was actually Y" and only until the end of the current file. However, import is all-powerful. You can, for instance, choose to import internal classes under new names and then redeclare them, as in: <?php namespace Mine; import Exception as X; class Exception extends X { } ?>/me must not let himself get drug into a "yes verbage means a lot" discussion... ;-)
What import really does is make fatal errors clearer. For instance: <?php $a = new Mine; ?> Fatal error: Class 'Mine' not found in /home/cellog/workspace/php6/test.php on line 2 Compare to: <?php import PEAR2::Mine; $a = new Mine; ?> Fatal error: Class 'PEAR2::Mine' not found in /home/cellog/workspace/php6/test.php on line 3Is there any sort of hit on performance for importing? What kind of hit is there when using an aliased class versus its original form? At this point, that would be my only final concern, pending, of course, actual beta quality php-src code to work with. So let me amend my vote: 0 now leaning +1 while reserving my final vote until we see what kind of effect a bunch of import statements has on the final code. -T