What does mean if (\false) (yes, with backslash) in PHP?

Viewed 1841

This morning, I've been notified that a new Twig_Extensions release is available! Yay!

Before integrating it to twigfiddle, I wanted to see changes. This is mainly adding support to namespaces using class_alias function, and then add PSR-4 correspoding classes that just include the legacy one.

But each new (namespaced) classes are implemented like this:

<?php

namespace Twig\Extensions;

require __DIR__.'/../lib/Twig/Extensions/Extension/Text.php';

if (\false) {
    class TextExtension extends \Twig_Extensions_Extension_Text
    {
    }
}

What does this notation mean?

4 Answers
if (\false) {
    class TextExtension extends \Twig_Extensions_Extension_Text
    {
    }
}

The code is still reachable by code sniffers and IDEs. However I think it should have deprecation note there. So that developers would be notified about using deprecated classes.

Here is an example from main Twig repository. https://github.com/twigphp/Twig/blob/v2.10.0/lib/Twig/Token.php

This is a no sense code, simply this is a Unreachable code because \false is always false!

Related