# New namespace implementation

- Thread: https://externals.io/message/42093
- Original archive: https://news-web.php.net/php.internals/42093
- Started by David Grudl on 2008-12-02T21:25:03+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #42093 — David Grudl — 2008-12-02T21:25:03+00:00

URL: https://externals.io/message/42093#42093

I just read the new namespace documentation and I must say that the new 
implementation is much more flexible.
Great work!

I had only two objections:

1) False warnings

As http://php.net/manual/en/language.namespaces.importing.php says, it 
is possible to import non-compound name.

    // importing a global class
    use ArrayObject;
 
but it generates Warning: The use statement with non-compound name 
'ArrayObject' has no effect.

2) Relative Resolving

I pointed out to inappropriate relative resolving earlier 
(http://news.php.net/php.internals/41837). In the world of well-written 
namespaced frameworks the ratio of usage of "more nested" classes vs. 
"less nested" is in large majority in favor of the second 
(http://news.php.net/php.internals/41980), but PHP prefer the first way. 
Now, the new implementation offers way to resolve names relative when it 
is needed - using 'namespace' operator (as equivalent of the 'self' 
operator). So I think now there is no reason to use default relative 
resolving and it should be removed.

What about voting?

David Grudl

---

## #42094 — Stanislav Malyshev — 2008-12-02T22:08:53+00:00

URL: https://externals.io/message/42093#42094 · In reply to: #42093

Hi!

> but it generates Warning: The use statement with non-compound name 
> 'ArrayObject' has no effect.

The warning is correct.

> What about voting?

We already voted a lot, let's actually release something for a change.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #42095 — Lukas Kahwe Smith — 2008-12-02T22:12:06+00:00

URL: https://externals.io/message/42093#42095 · In reply to: #42093

> 2) Relative Resolving
>
> I pointed out to inappropriate relative resolving earlier (http://news.php.net/php.internals/41837 
> ). In the world of well-written namespaced frameworks the ratio of  
> usage of "more nested" classes vs. "less nested" is in large  
> majority in favor of the second (http://news.php.net/php.internals/41980 
> ), but PHP prefer the first way. Now, the new implementation offers  
> way to resolve names relative when it is needed - using 'namespace'  
> operator (as equivalent of the 'self' operator). So I think now  
> there is no reason to use default relative resolving and it should  
> be removed.


Like Stas said, lets go with what we have and collect some feedback.  
Hopefully we will not have to do any larger changes to namespaces  
after alpha3, but if we have to we will. That being said I really hope  
that people honor the thought process that went into the current  
implementation by really giving things a go without prejudice.

Your comments are noted and not ignored.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #42096 — David Grudl — 2008-12-02T22:25:25+00:00

URL: https://externals.io/message/42093#42096 · In reply to: #42094

Hi!
>
> > […]
>
> The warning is correct.
It is not correct - the use statement has effect, as documented in 
manual http://php.net/manual/en/language.namespaces.importing.php.

DG.

---

## #42097 — Stanislav Malyshev — 2008-12-02T22:32:09+00:00

URL: https://externals.io/message/42093#42097 · In reply to: #42096

> > […]
> It is not correct - the use statement has effect, as documented in 
> manual http://php.net/manual/en/language.namespaces.importing.php.

The manual is wrong. Importing global object is use \ArrayObject - note 
the \.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #42098 — Stanislav Malyshev — 2008-12-02T22:34:36+00:00

URL: https://externals.io/message/42093#42098 · In reply to: #42097

> > […]
> 
> The manual is wrong. Importing global object is use \ArrayObject - note 
> the \.

 From the look of it it seems like the page there has all \'s in the 
code skipped (compare comments to the code). Could somebody from the 
docs team please fix it?
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #42099 — Hannes Magnusson — 2008-12-02T22:38:56+00:00

URL: https://externals.io/message/42093#42099 · In reply to: #42098

> > […]
>
> From the look of it it seems like the page there has all \'s in the code
> skipped (compare comments to the code). Could somebody from the docs team
> please fix it?

Already fixed. The problem is the `highlight_string()` function didn't
understand namespaces and magically (and very annoyingly) strip stuff
it doesn't understand.

The box has been upgraded and the weekly updates on friday will fix it.
In the meantime please use
http://docs.php.net/manual/en/language.namespaces.importing.php

-Hannes

---

## #42100 — David Grudl — 2008-12-02T22:39:58+00:00

URL: https://externals.io/message/42093#42100 · In reply to: #42097

Snapshot 5.3.0alpha3-dev acts like manual, I think the manual is correct.

BTW - this is very useful feature. A "wrong-relative-resolving" rescuer ;)

DG.
