PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
src
/
Standards
/
Generic
/
Tests
/
PHP
<?php $foo = (int) $bar; $foo = (integer) $bar; $foo = (bool) $bar; $foo = (boolean) $bar; $foo = (float) $bar; $foo = (double) $bar; $foo = (real) $bar; $foo = (string) $bar; $foo = (array) $bar; $foo = (object) $bar; $foo = (unset) $bar; $foo = (int) $bar; $foo = (integer) $bar; $foo = (bool) $bar; $foo = (string) $bar; $foo = ( array ) $bar; function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : int {} function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : Foo\Bar {} function foo(int $a, Bar $b, bool $c, array $d, Foo\Bar $e) : Bar {} function foo(callable $a, callable $b, self $c, iterable $d, iterable $e) : float {} $foo = function (int $a, bool $b) {}; $foo = function (int $a, callable $b) :int{}; $foo = function (bool $a, float $b) use ($foo) : int {}; $foo = function (Foo $a, Foo\Bar $b) use ($foo) : \Foo\Bar {}; $foo = function (bool $a, callable $b) use ($foo) : Bar {}; class Testing { public function TestThis(self $a, object $b, parent $c) : void {} } function foo( ?float $a, ? string $b, ?iterable $c, ? object $d, ?Foo\Bar $e ) : ?Foo\Bar {} $foo = function (?int $a, ? callable $b) :?int{}; $var = (binary) $string; $var = (binary)$string; function unionParamTypesA (bool|array| /* nullability operator not allowed in union */ null $var) {} function unionParamTypesB (\Package\ClassName | int | \Package\Other_Class | false $var) {} function unionReturnTypesA ($var): bool|array| /* nullability operator not allowed in union */ null {} function unionReturnTypesB ($var): \Package\ClassName | int | \Package\Other_Class | false {} class TypedProperties { protected ClassName $class; public int $int; private ?bool $bool; public self $self; protected parent $parent; private array $array; public float $float; protected ?string $string; private iterable $iterable; public object $object; protected mixed $mixed; public iterable|false|null $unionTypeA; protected self|parent /* comment */ |\Fully\Qualified\ClassName|UnQualifiedClass $unionTypeB; private ClassName|/*comment*/float|string|false $unionTypeC; public string | array | false $unionTypeD; } class ConstructorPropertyPromotionWithTypes { public function __construct(protected float|int $x, public(set) ?string &$y = 'test', private mixed $z) {} } class ConstructorPropertyPromotionAndNormalParams { public function __construct(public int $promotedProp, ?int $normalArg) {} } function (): never { exit; }; function intersectionParamTypes (\Package\ClassName&\Package\Other_Class $var) {} function intersectionReturnTypes ($var): \Package\ClassName&\Package\Other_Class {} $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : int => $a * $b; $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : float => $a * $b; $cl = function (false $a, true $b, null $c): ?true {}; class TypedClassConstants { const UNTYPED = null; const FLOAT = 'Reserved keyword as name is valid and should not be changed'; const OBJECT = 'Reserved keyword as name is valid and should not be changed'; const ClassName FIRST = null; public const int SECOND = 0; private const ?bool THIRD = false; public const self FOURTH = null; } interface TypedInterfaceConstants { protected const parent FIRST = null; private const array SECOND = []; public const float THIRD = 2.5; final const ?string FOURTH = 'fourth'; } trait TypedTraitConstants { const iterable FIRST = null; const object SECOND = null; const mixed THIRD = 'third'; } enum TypedEnumConstants { public const iterable|false|null FIRST = null; protected const self|parent /* comment */ |\Fully\Qualified\ClassName|UnQualifiedClass SECOND = null; private const ClassName|/*comment*/float|string|false THIRD = 'third'; public const string | array | false FOURTH = 'fourth'; } class DNFTypes { const (parent&Something)|float CONST_NAME = 1.5; public readonly true|(\A&B) $prop; function DNFParamTypes ( null|(\Package\ClassName&\Package\Other_Class)|int $DNFinMiddle, (\Package\ClassName&\Package\Other_Class)|array $parensAtStart, false|(\Package\ClassName&\Package\Other_Class) $parentAtEnd, ) {} function DNFReturnTypes ($var): object|(self&\Package\Other_Class)|string|false {} } // Intentional error, should be ignored by the sniff. interface PropertiesNotAllowed { public $notAllowed; }
[-] LowerCaseKeywordUnitTest.inc.fixed
[edit]
[-] DeprecatedFunctionsUnitTest.inc
[edit]
[-] DisallowAlternativePHPTagsUnitTest.1.inc
[edit]
[-] DisallowShortOpenTagUnitTest.5.inc
[edit]
[-] CharacterBeforePHPOpeningTagUnitTest.1.inc
[edit]
[-] RequireStrictTypesUnitTest.7.inc
[edit]
[-] DisallowRequestSuperglobalUnitTest.inc
[edit]
[-] DisallowAlternativePHPTagsUnitTest.2.inc.fixed
[edit]
[-] RequireStrictTypesUnitTest.3.inc
[edit]
[-] NoSilencedErrorsUnitTest.inc
[edit]
[-] RequireStrictTypesUnitTest.5.inc
[edit]
[-] LowerCaseConstantUnitTest.js
[edit]
[-] DisallowShortOpenTagUnitTest.3.inc
[edit]
[-] RequireStrictTypesUnitTest.php
[edit]
[+]
..
[-] LowerCaseTypeUnitTest.php
[edit]
[-] RequireStrictTypesUnitTest.11.inc
[edit]
[-] LowerCaseTypeUnitTest.inc.fixed
[edit]
[-] RequireStrictTypesUnitTest.13.inc
[edit]
[-] DisallowAlternativePHPTagsUnitTest.1.inc.fixed
[edit]
[-] ClosingPHPTagUnitTest.1.inc
[edit]
[-] ForbiddenFunctionsUnitTest.php
[edit]
[-] SAPIUsageUnitTest.php
[edit]
[-] DiscourageGotoUnitTest.php
[edit]
[-] RequireStrictTypesUnitTest.11.inc.fixed
[edit]
[-] RequireStrictTypesUnitTest.2.inc
[edit]
[-] NoSilencedErrorsUnitTest.php
[edit]
[-] DisallowAlternativePHPTagsUnitTest.php
[edit]
[-] RequireStrictTypesUnitTest.15.inc.fixed
[edit]
[-] CharacterBeforePHPOpeningTagUnitTest.2.inc
[edit]
[-] UpperCaseConstantUnitTest.inc
[edit]
[-] RequireStrictTypesUnitTest.14.inc
[edit]
[-] DisallowShortOpenTagUnitTest.1.inc.fixed
[edit]
[-] LowerCaseKeywordUnitTest.php
[edit]
[-] UpperCaseConstantUnitTest.inc.fixed
[edit]
[-] RequireStrictTypesUnitTest.8.inc
[edit]
[-] LowerCaseConstantUnitTest.php
[edit]
[-] DisallowShortOpenTagUnitTest.1.inc
[edit]
[-] LowerCaseConstantUnitTest.1.inc.fixed
[edit]
[-] DisallowAlternativePHPTagsUnitTest.3.inc
[edit]
[-] LowerCaseTypeUnitTest.inc
[edit]
[-] CharacterBeforePHPOpeningTagUnitTest.php
[edit]
[-] DeprecatedFunctionsUnitTest.php
[edit]
[-] LowerCaseConstantUnitTest.js.fixed
[edit]
[-] DisallowAlternativePHPTagsUnitTest.2.inc
[edit]
[-] DiscourageGotoUnitTest.inc
[edit]
[-] DisallowRequestSuperglobalUnitTest.php
[edit]
[-] DisallowShortOpenTagUnitTest.2.inc
[edit]
[-] RequireStrictTypesUnitTest.12.inc
[edit]
[-] RequireStrictTypesUnitTest.14.inc.fixed
[edit]
[-] LowerCaseConstantUnitTest.2.inc
[edit]
[-] UpperCaseConstantUnitTest.php
[edit]
[-] BacktickOperatorUnitTest.inc
[edit]
[-] CharacterBeforePHPOpeningTagUnitTest.3.inc
[edit]
[-] ForbiddenFunctionsUnitTest.inc
[edit]
[-] ClosingPHPTagUnitTest.php
[edit]
[-] LowerCaseKeywordUnitTest.inc
[edit]
[-] RequireStrictTypesUnitTest.15.inc
[edit]
[-] SyntaxUnitTest.php
[edit]
[-] DisallowShortOpenTagUnitTest.2.inc.fixed
[edit]
[-] SAPIUsageUnitTest.inc
[edit]
[-] RequireStrictTypesUnitTest.1.inc
[edit]
[-] SyntaxUnitTest.2.inc
[edit]
[-] BacktickOperatorUnitTest.php
[edit]
[-] DisallowShortOpenTagUnitTest.4.inc
[edit]
[-] RequireStrictTypesUnitTest.6.inc
[edit]
[-] RequireStrictTypesUnitTest.12.inc.fixed
[edit]
[-] RequireStrictTypesUnitTest.4.inc
[edit]
[-] DisallowShortOpenTagUnitTest.php
[edit]
[-] RequireStrictTypesUnitTest.9.inc
[edit]
[-] LowerCaseConstantUnitTest.1.inc
[edit]
[-] SyntaxUnitTest.1.inc
[edit]
[-] RequireStrictTypesUnitTest.10.inc
[edit]
[-] ClosingPHPTagUnitTest.2.inc
[edit]