php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53160 Importing and Legacy Mode suggestion for PHP 6.0 (7.0?)
Submitted: 2010-10-25 22:52 UTC Modified: 2018-07-08 14:28 UTC
Votes:4
Avg. Score:3.2 ± 1.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dmgx dot michael at gmail dot com Assigned:
Status: Suspended Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-10-25 22:52 UTC] dmgx dot michael at gmail dot com
Description:
------------
Currently the internal PHP function library is, well, unique.  Proposed is a 
means to maintain backward compatibility while rectifying the problem and 
hopefully on the engine side speed up the process by reducing what the zend 
engine has to track.

import keyword.
import attaches the specified namespace to the current one. An error is thrown 
if there is a symbol collision between the namespaces.

namespace Bar {
   function Foo(){}
}
namespace Test {
  import \Bar
  Foo() // works
  Bar\Foo() // doesn't work - try use Bar instead.
}

If import is asked to pull a namespace that doesn't exist there's an error. 
Import has one other use.

namespace Test;
import @PDO;

This pulls the PDO library of PHP 6 into the Test namespace. This brings us back 
to the solution of the function library problem.

PHP 6 would ship with a legacy mode set to true. In that mode everything is as 
now - the namespace \ having thousands of functions.

Turn it off though and namespace \ is empty except for a core selection of 
functions and objects. The rest of the function library will be divided into 
libraries that can be imported as needed.

Legacy functions remain available in library legacy so

namespace MyNamespace;
import @Legacy;

would let code in MyNamespace use the current function library.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-26 01:56 UTC] cataphract@php.net
-Type: Bug +Type: Feature/Change Request
 [2018-07-08 14:28 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2018-07-08 14:28 UTC] cmb@php.net
This is certainly a feature request which requires discussion on
the internals@ mailing list, and likely the RFC process.  For the
time being, I'm suspending this ticket.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 16:01:24 2020 UTC