Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101176 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98443 invoked from network); 28 Nov 2017 09:54:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2017 09:54:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:36862] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/EF-26862-B523D1A5 for ; Tue, 28 Nov 2017 04:54:36 -0500 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 62BB810C8A5; Tue, 28 Nov 2017 09:54:32 +0000 (GMT) Date: Tue, 28 Nov 2017 09:54:32 +0000 (GMT) X-X-Sender: derick@singlemalt.home.derickrethans.nl To: Michael Morris cc: PHP internals In-Reply-To: Message-ID: References: <12F58DFE-B842-44FB-ACF6-FB62F4BB1F7A@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] Changes in namespace importing From: derick@php.net (Derick Rethans) 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