https://wiki.php.net/rfc/changes_to_include_and_require
Since the reaction to the first of the two suggestions was largely
negative I've withdrawn it for now to focus on the second of the two
changes. In all honestly, these two suggestions should have had
independent RFC's from the start.
Of the two suggestions this one has the more profound implications to
the language even if it is simpler to implement. Thoughts?
On Thu, 08 Mar 2012 17:05:19 +0100, Michael Morris
dmgx.michael@gmail.com wrote:
https://wiki.php.net/rfc/changes_to_include_and_require
Since the reaction to the first of the two suggestions was largely
negative I've withdrawn it for now to focus on the second of the two
changes. In all honestly, these two suggestions should have had
independent RFC's from the start.Of the two suggestions this one has the more profound implications to
the language even if it is simpler to implement. Thoughts?
How exactly would this be useful?
The purpose of namespaces is to avoid collision of symbols. Are you
saying they did not solve this problem and you have to rename already
namespaced files?
I also don't understand your template argument. Why would you need to
namespace templates? Typically they are included from inside a function
(and therefore don't change/access the global namespace).
I only see some usefulness as a transitional measure, which would save
from namespacing 'legacy' libraries. But PHP 5.5 seems a bit late to
introduce such measure.
--
Gustavo Lopes
Michael,
Quick question: how would this work with require_once?
Let's say that I have a class Foo defined in a file without a
namespace declaration.
What happens if I require_once with a namespace first (so Foo gets
imported into the namespace), and then require_once later without a
namespace? Should it require twice? Which then could break things
(if there was procedural or initialization code in there)... If not,
then you won't have Foo in the root namespace, and lead to other
errors.
Anthony
https://wiki.php.net/rfc/changes_to_include_and_require
Since the reaction to the first of the two suggestions was largely
negative I've withdrawn it for now to focus on the second of the two
changes. In all honestly, these two suggestions should have had
independent RFC's from the start.Of the two suggestions this one has the more profound implications to
the language even if it is simpler to implement. Thoughts?
At first glance, this is technically impossible, with regards to our
current resolution rules:
http://php.net/manual/en/language.namespaces.rules.php
Assuming you have an un-namespaced:
class Db {
public function __construct() {
$this->conn = new PDO(..);
}
}
and you require this as:
require ./path/to/Db.php, 'Some\SubDb';
How does PDO get resolved? Automatically as \PDO or as \Some\SubDb\PDO?
Isn't it just easier to change the code? ;)
-ralph
https://wiki.php.net/rfc/changes_to_include_and_require
Since the reaction to the first of the two suggestions was largely
negative I've withdrawn it for now to focus on the second of the two
changes. In all honestly, these two suggestions should have had
independent RFC's from the start.Of the two suggestions this one has the more profound implications to
the language even if it is simpler to implement. Thoughts?
On Thu, 08 Mar 2012 17:51:34 +0100, Michael Morris
dmgx.michael@gmail.com wrote
I also don't understand your template argument. Why would you need to
namespace templates? Typically they are included from inside a function
(and therefore don't change/access the global namespace).You forget that variable scope and namespace scope have absolutely
nothing to do with each other. At all. If I have a template that
needs to call a function from within my project's namespace it must
either use the fully qualified name of the function or it must declare
the namespace it is part of on the first line.
Sorry, I confused things here for a moment. This in fact seems to be a
valid use case. But you're only saving a line, and you can't rely on the
fallback to globals because it would create an ambiguity.
--
Gustavo Lopes
Am 08.03.2012 17:05, schrieb Michael Morris:
Thoughts?
Sounds pointless/useless to me.
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/ http://thePHP.cc/
Am 08.03.2012 17:05, schrieb Michael Morris:
Thoughts?
Sounds pointless/useless to me.
Could you answer more than one liner to RFCs? Even if you totally
disagree with the idea(s) behind it. Thanks.
Cheers,
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
2012/3/8 Sebastian Bergmann sebastian@php.net:
Am 08.03.2012 17:05, schrieb Michael Morris:
Thoughts?
Sounds pointless/useless to me.
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/ http://thePHP.cc/--
Hi,
I understand the point why you wanna use that ... but I think
personally it does not seem to be implementable, if you'd ask me.
There are too many things we would have to change or specify a behavior for ...
- what if the included file contains direct code or a bunch of functions?
- what about *_once file-includes inside this files?
- what if the included file provides an auto-class-loader?
If you just have class-files and not direct code there are still some
opened questions ...
The idea makes sense to me, but currently there are too much opened
questions for me to take a closer look at it.
Bye
Simon
2012/3/8 Sebastian Bergmann sebastian@php.net:
Am 08.03.2012 17:05, schrieb Michael Morris:
Thoughts?
Sounds pointless/useless to me.
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/ http://thePHP.cc/--
Hi,
I understand why you want to have this feature ...
Let me just put a view questions in here:
- what if the included file contains direct code or a bunch of functions?
- what about *_once file-includes inside this files?
- what if the included file provides an auto-class-loader?
If you just have class-files and not direct code there are still some
opened questions ...
The idea makes sense to me, but currently there are too much opened
questions for me to take a closer look at it.
Bye
Simon