From b0ab30b2da06989e3f6576705000be782ae19738 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Wed, 21 Jul 2021 08:14:09 +1000 Subject: [PATCH] Renamed index from attributes to has_attributes --- src/Files/File.php | 10 +-- tests/Core/File/GetMethodParametersTest.php | 98 ++++++++++----------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Files/File.php b/src/Files/File.php index 2e9c5b4bbb..e551dcbbf1 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -1283,7 +1283,7 @@ public function getDeclarationName($stackPtr) * 'name' => '$var', // The variable name. * 'token' => integer, // The stack pointer to the variable name. * 'content' => string, // The full content of the variable definition. - * 'attributes' => boolean, // Does the parameter have one or more attributes attached ? + * 'has_attributes' => boolean, // Does the parameter have one or more attributes attached ? * 'pass_by_reference' => boolean, // Is the variable passed by reference? * 'reference_token' => integer, // The stack pointer to the reference operator * // or FALSE if the param is not passed by reference. @@ -1356,7 +1356,7 @@ public function getMethodParameters($stackPtr) $defaultStart = null; $equalToken = null; $paramCount = 0; - $attributes = false; + $hasAttributes = false; $passByReference = false; $referenceToken = false; $variableLength = false; @@ -1389,7 +1389,7 @@ public function getMethodParameters($stackPtr) switch ($this->tokens[$i]['code']) { case T_ATTRIBUTE: - $attributes = true; + $hasAttributes = true; // Skip to the end of the attribute. $i = $this->tokens[$i]['attribute_closer']; @@ -1510,7 +1510,7 @@ public function getMethodParameters($stackPtr) $vars[$paramCount]['default_equal_token'] = $equalToken; } - $vars[$paramCount]['attributes'] = $attributes; + $vars[$paramCount]['has_attributes'] = $hasAttributes; $vars[$paramCount]['pass_by_reference'] = $passByReference; $vars[$paramCount]['reference_token'] = $referenceToken; $vars[$paramCount]['variable_length'] = $variableLength; @@ -1536,7 +1536,7 @@ public function getMethodParameters($stackPtr) $paramStart = ($i + 1); $defaultStart = null; $equalToken = null; - $attributes = false; + $hasAttributes = false; $passByReference = false; $referenceToken = false; $variableLength = false; diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index 6de4622aed..e7692a7153 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -26,7 +26,7 @@ public function testPassByReference() $expected[0] = [ 'name' => '$var', 'content' => '&$var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => false, 'type_hint' => '', @@ -49,7 +49,7 @@ public function testArrayHint() $expected[0] = [ 'name' => '$var', 'content' => 'array $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'array', @@ -72,7 +72,7 @@ public function testTypeHint() $expected[0] = [ 'name' => '$var1', 'content' => 'foo $var1', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'foo', @@ -82,7 +82,7 @@ public function testTypeHint() $expected[1] = [ 'name' => '$var2', 'content' => 'bar $var2', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'bar', @@ -105,7 +105,7 @@ public function testSelfTypeHint() $expected[0] = [ 'name' => '$var', 'content' => 'self $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'self', @@ -128,7 +128,7 @@ public function testNullableTypeHint() $expected[0] = [ 'name' => '$var1', 'content' => '?int $var1', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?int', @@ -138,7 +138,7 @@ public function testNullableTypeHint() $expected[1] = [ 'name' => '$var2', 'content' => '?\bar $var2', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?\bar', @@ -161,7 +161,7 @@ public function testVariable() $expected[0] = [ 'name' => '$var', 'content' => '$var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -184,7 +184,7 @@ public function testSingleDefaultValue() $expected[0] = [ 'name' => '$var1', 'content' => '$var1=self::CONSTANT', - 'attributes' => false, + 'has_attributes' => false, 'default' => 'self::CONSTANT', 'pass_by_reference' => false, 'variable_length' => false, @@ -208,7 +208,7 @@ public function testDefaultValues() $expected[0] = [ 'name' => '$var1', 'content' => '$var1=1', - 'attributes' => false, + 'has_attributes' => false, 'default' => '1', 'pass_by_reference' => false, 'variable_length' => false, @@ -218,7 +218,7 @@ public function testDefaultValues() $expected[1] = [ 'name' => '$var2', 'content' => "\$var2='value'", - 'attributes' => false, + 'has_attributes' => false, 'default' => "'value'", 'pass_by_reference' => false, 'variable_length' => false, @@ -243,7 +243,7 @@ public function testBitwiseAndConstantExpressionDefaultValue() 'name' => '$a', 'content' => '$a = 10 & 20', 'default' => '10 & 20', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -266,7 +266,7 @@ public function testArrowFunction() $expected[0] = [ 'name' => '$a', 'content' => 'int $a', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'int', @@ -276,7 +276,7 @@ public function testArrowFunction() $expected[1] = [ 'name' => '$b', 'content' => '...$b', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => true, 'type_hint' => '', @@ -299,7 +299,7 @@ public function testPHP8MixedTypeHint() $expected[0] = [ 'name' => '$var1', 'content' => 'mixed &...$var1', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => true, 'type_hint' => 'mixed', @@ -322,7 +322,7 @@ public function testPHP8MixedTypeHintNullable() $expected[0] = [ 'name' => '$var1', 'content' => '?Mixed $var1', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?Mixed', @@ -345,7 +345,7 @@ public function testNamespaceOperatorTypeHint() $expected[0] = [ 'name' => '$var1', 'content' => '?namespace\Name $var1', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?namespace\Name', @@ -368,7 +368,7 @@ public function testPHP8UnionTypesSimple() $expected[0] = [ 'name' => '$number', 'content' => 'int|float $number', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'int|float', @@ -377,7 +377,7 @@ public function testPHP8UnionTypesSimple() $expected[1] = [ 'name' => '$obj', 'content' => 'self|parent &...$obj', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => true, 'type_hint' => 'self|parent', @@ -400,7 +400,7 @@ public function testPHP8UnionTypesWithSpreadOperatorAndReference() $expected[0] = [ 'name' => '$paramA', 'content' => 'float|null &$paramA', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => false, 'type_hint' => 'float|null', @@ -409,7 +409,7 @@ public function testPHP8UnionTypesWithSpreadOperatorAndReference() $expected[1] = [ 'name' => '$paramB', 'content' => 'string|int ...$paramB', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => true, 'type_hint' => 'string|int', @@ -433,7 +433,7 @@ public function testPHP8UnionTypesSimpleWithBitwiseOrInDefault() 'name' => '$var', 'content' => 'int|float $var = CONSTANT_A | CONSTANT_B', 'default' => 'CONSTANT_A | CONSTANT_B', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'int|float', @@ -456,7 +456,7 @@ public function testPHP8UnionTypesTwoClasses() $expected[0] = [ 'name' => '$var', 'content' => 'MyClassA|\Package\MyClassB $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'MyClassA|\Package\MyClassB', @@ -479,7 +479,7 @@ public function testPHP8UnionTypesAllBaseTypes() $expected[0] = [ 'name' => '$var', 'content' => 'array|bool|callable|int|float|null|object|string $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'array|bool|callable|int|float|null|object|string', @@ -502,7 +502,7 @@ public function testPHP8UnionTypesAllPseudoTypes() $expected[0] = [ 'name' => '$var', 'content' => 'false|mixed|self|parent|iterable|Resource $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'false|mixed|self|parent|iterable|Resource', @@ -525,7 +525,7 @@ public function testPHP8UnionTypesNullable() $expected[0] = [ 'name' => '$number', 'content' => '?int|float $number', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?int|float', @@ -549,7 +549,7 @@ public function testPHP8PseudoTypeNull() 'name' => '$var', 'content' => 'null $var = null', 'default' => 'null', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'null', @@ -573,7 +573,7 @@ public function testPHP8PseudoTypeFalse() 'name' => '$var', 'content' => 'false $var = false', 'default' => 'false', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'false', @@ -597,7 +597,7 @@ public function testPHP8PseudoTypeFalseAndBool() 'name' => '$var', 'content' => 'bool|false $var = false', 'default' => 'false', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'bool|false', @@ -620,7 +620,7 @@ public function testPHP8ObjectAndClass() $expected[0] = [ 'name' => '$var', 'content' => 'object|ClassName $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'object|ClassName', @@ -643,7 +643,7 @@ public function testPHP8PseudoTypeIterableAndArray() $expected[0] = [ 'name' => '$var', 'content' => 'iterable|array|Traversable $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'iterable|array|Traversable', @@ -666,7 +666,7 @@ public function testPHP8DuplicateTypeInUnionWhitespaceAndComment() $expected[0] = [ 'name' => '$var', 'content' => 'int | string /*comment*/ | INT $var', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'int|string|INT', @@ -690,7 +690,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes() 'name' => '$x', 'content' => 'public $x = 0.0', 'default' => '0.0', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -701,7 +701,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes() 'name' => '$y', 'content' => 'protected $y = \'\'', 'default' => "''", - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -712,7 +712,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes() 'name' => '$z', 'content' => 'private $z = null', 'default' => 'null', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -736,7 +736,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes() $expected[0] = [ 'name' => '$x', 'content' => 'protected float|int $x', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'float|int', @@ -747,7 +747,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes() 'name' => '$y', 'content' => 'public ?string &$y = \'test\'', 'default' => "'test'", - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => false, 'type_hint' => '?string', @@ -757,7 +757,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes() $expected[2] = [ 'name' => '$z', 'content' => 'private mixed $z', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'mixed', @@ -781,7 +781,7 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam() $expected[0] = [ 'name' => '$promotedProp', 'content' => 'public int $promotedProp', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'int', @@ -791,7 +791,7 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam() $expected[1] = [ 'name' => '$normalArg', 'content' => '?int $normalArg', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?int', @@ -814,7 +814,7 @@ public function testPHP8ConstructorPropertyPromotionGlobalFunction() $expected[0] = [ 'name' => '$x', 'content' => 'private $x', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -838,7 +838,7 @@ public function testPHP8ConstructorPropertyPromotionAbstractMethod() $expected[0] = [ 'name' => '$y', 'content' => 'public callable $y', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'callable', @@ -848,7 +848,7 @@ public function testPHP8ConstructorPropertyPromotionAbstractMethod() $expected[1] = [ 'name' => '$x', 'content' => 'private ...$x', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => false, 'variable_length' => true, 'type_hint' => '', @@ -873,7 +873,7 @@ public function testCommentsInParameter() 'name' => '$param', 'content' => '// Leading comment. ?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ \'default value\' . /*-*/ \'second part\' // Trailing comment.', - 'attributes' => false, + 'has_attributes' => false, 'pass_by_reference' => true, 'variable_length' => true, 'type_hint' => '?MyClass', @@ -896,7 +896,7 @@ public function testParameterAttributesInFunctionDeclaration() $expected[0] = [ 'name' => '$constructorPropPromTypedParamSingleAttribute', 'content' => '#[\MyExample\MyAttribute] private string $constructorPropPromTypedParamSingleAttribute', - 'attributes' => true, + 'has_attributes' => true, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'string', @@ -908,7 +908,7 @@ public function testParameterAttributesInFunctionDeclaration() 'content' => '#[MyAttr([1, 2])] Type|false $typedParamSingleAttribute', - 'attributes' => true, + 'has_attributes' => true, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => 'Type|false', @@ -917,7 +917,7 @@ public function testParameterAttributesInFunctionDeclaration() $expected[2] = [ 'name' => '$nullableTypedParamMultiAttribute', 'content' => '#[MyAttribute(1234), MyAttribute(5678)] ?int $nullableTypedParamMultiAttribute', - 'attributes' => true, + 'has_attributes' => true, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '?int', @@ -926,7 +926,7 @@ public function testParameterAttributesInFunctionDeclaration() $expected[3] = [ 'name' => '$nonTypedParamTwoAttributes', 'content' => '#[WithoutArgument] #[SingleArgument(0)] $nonTypedParamTwoAttributes', - 'attributes' => true, + 'has_attributes' => true, 'pass_by_reference' => false, 'variable_length' => false, 'type_hint' => '', @@ -936,7 +936,7 @@ public function testParameterAttributesInFunctionDeclaration() 'name' => '$otherParam', 'content' => '#[MyAttribute(array("key" => "value"))] &...$otherParam', - 'attributes' => true, + 'has_attributes' => true, 'pass_by_reference' => true, 'variable_length' => true, 'type_hint' => '',