On 11 February 2015 06:36:52 GMT, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
>  And in Drupal8 *without turning on strict*:
>
>  use Drupal\Component\Utility\String;
>
> it dies with: "Fatal error: "string" cannot be used as a class name in
>/var/www/drupal/core/includes/bootstrap.inc on line 11"
>
>  That String class is everywhere in Drupal. They are going to have a
>  fun time with that. See
>https://gist.githubusercontent.com/anonymous/d9252deeeb2aae1a5af5/raw/053155130d22551b1404d0a9b94e27424544b6d1/gistfile1

That could potentially be avoided if scalar types were reserved as some kind of 
pseudo-class rather than just keywords, because then they would follow 
namespace resolution rules. Theoretically, you could still have a class 
"Drupal\Component\Utility\String", and "\string" would be available as a scalar 
typehint while you were in that namespace.

I'm guessing it's not as simple as that, because the compiler needs to 
distinguish between scalar and classname typehints, but doesn't know what 
classes exist.

In which case, perhaps "string" as a typehint could always mean "\string", and 
if you want to typehint the class you should always use "foo\string"? Or you 
could ban "string" as a typehint, and require people to type "\string". Either 
seems a little bit magic, though.

Theoretically, I guess they ought to be "php\string" etc, which would 
accomplish the goal but make them rather unwieldy. It might be worth 
considering, though, given we know the situation's not just hypothetical.

Regards,
-- 
Rowan Collins
[IMSoP]


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to