- Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
As you probably know, PHP 7 introduced scalar type declarations (previously known as TypeHints) so that "string", "int", "float", "bool" can be declared in a method parameter and return type.
PHPCS does cope with these when they have a leading backslash such as:
namespace x\y\z; class test { /** * @param \string $name */ public function (\string $name) ....
However, a recent commit relating to PHP 7.0.1 (see php/php-src@569763c "Fixed \int (or generally every scalar type name with leading backslash) to not be accepted as type name. (Bob)" and php/php-src@00865ae) which means the backslashed scalars/builtins are technically incorrect in PHP 7.0.1 onwards (and throws a fatal error if set).
Running PHPCS without the variables backslashes results in a load of:
Unknown type hint "string" found for $keyName (Squiz.Commenting.FunctionComment.InvalidTypeHint)
Can the code sniffer allow these types without the backslash?
[tested using PHPCS commit 43ac634 , PHP 7.0.1 on an upgraded rasmus PHPdev VM]