Re: [VOTE] Scalar Type Hints
| From: | Andrea Faulds | Date: | Wed, 11 Feb 2015 18:42:49 +0000 |
| Subject: | Re: [VOTE] Scalar Type Hints | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82489@lists.php.net to get a copy of this message | ||
Hi Rasmus,
> On 11 Feb 2015, at 06:36, Rasmus Lerdorf <rasmus@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
Such classes will unfortunately have to be renamed. However, this is only true if the code needs to
run on PHP 7. For PHP 5 codebase compatibility, Drupal can do this:
class StringHelper {
…
}
if (version_compare(phpversion(), “7.0") < 0) {
class_alias(“Drupal\\Component\\Utility\\StringHelper”,
“Drupal\\Component\\Utility\\String”);
}
This way, only code made “PHP 7-ready" will have to replace its references to String with,
say, StringHelper. Drupal can work on both PHP 5 and PHP 7, but codebases using it can migrate at
their own pace.
--
Andrea Faulds
http://ajf.me/