Re: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7
On 11 November 2014 04:11, Robert Stoll p...@tutteli.ch wrote: I always found it very ugly that it is possible to define a use outside of a namespace. Consider the following: namespace{ //default namespace } use foo\Bar; namespace test{ new Bar(); //error, test\Bar not found } After some thoughts it is quite clear that Bar is test\Bar and not foo\Bar inside of the namespace test. But consider the following example which is not so obvious: use foo\Bar; namespace test; new Bar(); //error, test\Bar not found The use declaration looks like a normal use declaration at first glance. I do not see why we should actually support this feature any longer and thus suggest to remove it in PHP 7. Although, it is not a bug (the use declaration is simply ignored as far as I can tell) I suppose it confuses the user. Nevertheless, even if we declare it as a feature I think it should at least not be a feature of the specification of PHP 7. Sorry, I apparently missed this the first time. Would this mean that this sort of script (where we're using use statements without a namespace) would no longer work? ?php use GuzzleHttp\Client; include __DIR__.'/vendor/autoload.php'; $client = new Client; // $client is a GuzzleHttp\Client object ? Because that strikes me as an irritating and unnecessary BC break for people who are writing throwaway scripts (with no need to live in namespaces) that pull in namespaced libraries to me. Adam -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7
On 11 November 2014 12:11, Robert Stoll p...@tutteli.ch wrote: -Ursprüngliche Nachricht- Von: Robert Stoll [mailto:p...@tutteli.ch] Gesendet: Mittwoch, 29. Oktober 2014 20:55 An: 'PHP Internals' Betreff: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7 Heya, I always found it very ugly that it is possible to define a use outside of a namespace. Consider the following: namespace{ //default namespace } use foo\Bar; namespace test{ new Bar(); //error, test\Bar not found } After some thoughts it is quite clear that Bar is test\Bar and not foo\Bar inside of the namespace test. But consider the following example which is not so obvious: use foo\Bar; namespace test; new Bar(); //error, test\Bar not found The use declaration looks like a normal use declaration at first glance. I do not see why we should actually support this feature any longer and thus suggest to remove it in PHP 7. Although, it is not a bug (the use declaration is simply ignored as far as I can tell) I suppose it confuses the user. Nevertheless, even if we declare it as a feature I think it should at least not be a feature of the specification of PHP 7. Thoughts? Cheers, Robert ps: I first started the discussion @standards, just if you should wonder why it pops up here now as well: http://news.php.net/php.standards/528 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php No one else who thinks this feature should be removed in PHP 7 ? I would say that the lack of anyone saying no, don't do this probably means everyone is OK with it. Suggest you work up a patch and PR it, then ping the list to highlight it for further discussion. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7
On 11 Nov 2014, at 13:20, Robert Stoll p...@tutteli.ch wrote: I would say that the lack of anyone saying no, don't do this probably means everyone is OK with it. Suggest you work up a patch and PR it, then ping the list to highlight it for further discussion. Sounds reasonable but unfortunately I do not have time at the moment to work up a patch and when I have time (in half a year or so) it might be too late for PHP 7 and the change would need to wait for PHP 8 since it is not backward compatible. That is the reason why I hope we could agree on the topic, remove the corresponding sentence from the spec and I could patch up a fix when I have time for it. I don’t like the sound of changing the spec before the implementation. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7
Hi! I don’t like the sound of changing the spec before the implementation. I agree - whatever are our considerations and limitations on what we can and can not do in PHP 7, the spec should reflect what is there. Otherwise we end up releasing an implementation that does not match our own spec, that'd be embarrassing. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php