On Mon, 27 Nov 2017, Michael Morris wrote:

> I'm sure the internal coders will correct me if I'm wrong on this, but 
> as I understand it PHP has no notion of packages, yet many calls to 
> modify how namespace importing works seem to be under the illusion 
> that packages exist. This is understandable, packages are namespaces 
> are terms used somewhat interchangeably. However, they aren't the 
> same.  In Java, Actionscript 3, and I presume C++ and C# when you 
> import a package you are binding it to the resultant executable the 
> compiler will create. This will affect the size of that executable 
> regardless of how much of the package gets used, or even if it gets 
> used.
> 
> PHP has packages, but they are compiled in when the interpreter is 
> compiled and set up on the machine. Adding a package in PHP requires 
> redoing that compile step and modifying the php.ini to enable the 
> associated .so file. As for libraries looked up by composer - these 
> are never referenced until they are called for at runtime and the 
> autoloader gets invoked.
> 
> As a result of this PHP's "namespace" resolution is nothing more than 
> a set of string replace rules done at call time to try to resolve the 
> name to a known class.

It's not done at call time, but rather at "compile time" (when the 
script is parsed). But you're right that it is basically an internal 
string replace job.

cheers,
Derick

-- 
https://derickrethans.nl | https://xdebug.org | https://dram.io
Like Xdebug? Consider a donation: https://xdebug.org/donate.php
twitter: @derickr and @xdebug

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

Reply via email to