Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68116 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78954 invoked from network); 14 Jul 2013 10:40:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2013 10:40:03 -0000 Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:63815] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/42-52897-10082E15 for ; Sun, 14 Jul 2013 06:40:02 -0400 Received: by mail-wi0-f177.google.com with SMTP id ey16so1961014wid.16 for ; Sun, 14 Jul 2013 03:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=VtyrGOCP6tKTjtDwHjRq4xaSCfnky1tpTuHToC61YL4=; b=OYaiIgMdQfcluaXiP4MHVI3pAtHWNOeexmD3+ubKBW/JekqEzMkS6mLeAxcjgqSp8y S9Ue0qMrGERun5/wsdQzX/qQlIdDpbw2pQyF2ggp5yEkqOPbXJG+vVLlGa/nQqEg9ndq xeUGdLHgGh05OHbTUYgM2yYALWU7dDS2kfUIlF4yO7kU+HZOJVBGfpkl0B6Zr9Nme1VQ wFfd2ptm4pRVQHSCkmjcGKeU4FMn25pmlYMcr69lnidCfjK04Q6/HIPY4B7w06+dOXFj vuZzDIVQCDgHnP6P1Oq/67KwcLvdBT/vOSC1hOrTxvmaTuM1HVTS+n8CpK6+RGGMJQBe sh5w== X-Received: by 10.194.174.38 with SMTP id bp6mr29466607wjc.83.1373798398834; Sun, 14 Jul 2013 03:39:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.224.129 with HTTP; Sun, 14 Jul 2013 03:39:18 -0700 (PDT) In-Reply-To: References: Date: Sun, 14 Jul 2013 12:39:18 +0200 Message-ID: To: Giuseppe Ronca Cc: PHP internals list Content-Type: multipart/alternative; boundary=089e0141aa2a8e3ca604e1765d3e Subject: Re: [PHP-DEV] PHP proposal on modular systems From: krebs.seb@gmail.com (Sebastian Krebs) --089e0141aa2a8e3ca604e1765d3e Content-Type: text/plain; charset=ISO-8859-1 2013/7/14 Giuseppe Ronca > Php is now used by many CMS, many of which use a modular system with a wide > range of add-ons developed by third parties. This can cause various > conflicts, such as when two or more external components using the same > library (i.g. with a different version) in this case the classes / > namespace will be in collision. This can become unmanageable by the > webmaster because they are not always able to change third parties code and > there aren't other "clean" methods to solve this kind of problem ( complex > and dirty eval methods excluded ). > > here you are a thread related to this issue: > > http://stackoverflow.com/questions/17628475/php-include-different-version-of-same-library > > *One possible solution* would be to extend the scoping for the inclusions > of files using something like:* local_include_** > > in this way you can also create a sort of "nesting" system for classes > making possible a syntax like this: > > class foo { > public static function bar () { > local_include "test.php" / / file which includes "test" class; > return new test (); > } > } > > echo get_class (foo :: bar ()) / / output: "test" > > new test () / / raise an error instead > > > *Also this could work:* > > namespace {oldversion > local_include / lib/api-1.0/library.php; > } > namespace {newversion > local_include / lib/api-2.0/library.php; > } > > $ oldlibary = new oldversion \ Library (); > $ newlibrary = new newversion \ Library (); > > It shouldn't have backward compatibility issues since it's a new > implementation and you shouldn't change anything else. > What do you think about that? > You can have multiple objects from the same type in different implemenations in the same process? What should happen, when I instanciate an object of "test" in version X and pass it to a function, that expect it as version Y? To be consistent PHP _must_ trigger an error too, if something from the locally included file leaves its scope class foo { public static function bar () { local_include "test.php" / / file which includes "test" class; return new test (); // <-- error here } } Because else it is not a local scope anymore. Backward compatibility (or compatibility in general) between component is something the plugin maintainer should take care of, not the language. Regards, Sebastian -- github.com/KingCrunch --089e0141aa2a8e3ca604e1765d3e--