diff --git a/src/Generator/ValueGenerator.php b/src/Generator/ValueGenerator.php index c7b552d9..3c7b4c3b 100644 --- a/src/Generator/ValueGenerator.php +++ b/src/Generator/ValueGenerator.php @@ -185,7 +185,7 @@ public function getConstants() */ public function isValidConstantType() { - if ($this->type == self::TYPE_AUTO) { + if ($this->type === self::TYPE_AUTO) { $type = $this->getAutoDeterminedType($this->value); } else { $type = $this->type; @@ -336,13 +336,13 @@ public function generate() { $type = $this->type; - if ($type != self::TYPE_AUTO) { + if ($type !== self::TYPE_AUTO) { $type = $this->getValidatedType($type); } $value = $this->value; - if ($type == self::TYPE_AUTO) { + if ($type === self::TYPE_AUTO) { $type = $this->getAutoDeterminedType($value); } @@ -388,12 +388,12 @@ public function generate() case self::TYPE_ARRAY: case self::TYPE_ARRAY_LONG: case self::TYPE_ARRAY_SHORT: - if ($type == self::TYPE_ARRAY_SHORT) { - $startArray = '['; - $endArray = ']'; - } else { + if ($type === self::TYPE_ARRAY_LONG) { $startArray = 'array('; - $endArray = ')'; + $endArray = ')'; + } else { + $startArray = '['; + $endArray = ']'; } $output .= $startArray; diff --git a/test/Generator/MethodGeneratorTest.php b/test/Generator/MethodGeneratorTest.php index 9aacce00..fac4e884 100644 --- a/test/Generator/MethodGeneratorTest.php +++ b/test/Generator/MethodGeneratorTest.php @@ -233,7 +233,7 @@ public function testDefaultValueGenerationDoesNotIncludeTrailingSemicolon() $method->setParameter($param); $generated = $method->generate(); - self::assertRegExp('/array \$options = array\(\)\)/', $generated, $generated); + self::assertContains('array $options = [])', $generated); } public function testCreateFromArray() diff --git a/test/Generator/ParameterGeneratorTest.php b/test/Generator/ParameterGeneratorTest.php index 009bf6e7..08f3b3b2 100644 --- a/test/Generator/ParameterGeneratorTest.php +++ b/test/Generator/ParameterGeneratorTest.php @@ -181,8 +181,8 @@ public function dataFromReflectionGenerate() ['defaultNull', '$value = null'], ['fromArray', 'array $array'], ['hasNativeDocTypes', '$integer'], - ['defaultArray', '$array = array()'], - ['defaultArrayWithValues', '$array = array(1, 2, 3)'], + ['defaultArray', '$array = []'], + ['defaultArrayWithValues', '$array = [1, 2, 3]'], ['defaultFalse', '$val = false'], ['defaultTrue', '$val = true'], ['defaultZero', '$number = 0'], diff --git a/test/Generator/PropertyGeneratorTest.php b/test/Generator/PropertyGeneratorTest.php index 7c08efa3..fd23ac0f 100644 --- a/test/Generator/PropertyGeneratorTest.php +++ b/test/Generator/PropertyGeneratorTest.php @@ -108,14 +108,14 @@ public function testPropertyMultilineValue() : void ]; $expectedSource = << 1, 'two' => '2', 'null' => null, 'true' => true, 'bar\'s' => 'bar\'s', - ); + ]; EOS; $property = new PropertyGenerator('myFoo', $targetValue); diff --git a/test/Generator/TestAsset/ParameterClass.php b/test/Generator/TestAsset/ParameterClass.php index 953861c1..72e5ed6b 100644 --- a/test/Generator/TestAsset/ParameterClass.php +++ b/test/Generator/TestAsset/ParameterClass.php @@ -40,7 +40,7 @@ public function fromArray(array $array) } - public function defaultArray($array = array()) + public function defaultArray($array = []) { } @@ -70,7 +70,7 @@ public function defaultFloat($float = 1.34) } - public function defaultArrayWithValues($array = array(0 => 1, 1 => 2, 2 => 3)) + public function defaultArrayWithValues($array = [0 => 1, 1 => 2, 2 => 3]) { } diff --git a/test/Generator/TestAsset/TestClassWithManyProperties.php b/test/Generator/TestAsset/TestClassWithManyProperties.php index 26b96b89..f5f571bb 100644 --- a/test/Generator/TestAsset/TestClassWithManyProperties.php +++ b/test/Generator/TestAsset/TestClassWithManyProperties.php @@ -27,17 +27,17 @@ class TestClassWithManyProperties private static $_bazStaticProperty = self::FOO; - private $_bazProperty = array(true, false, true); + private $_bazProperty = [true, false, true]; - protected $_complexType = array( + protected $_complexType = [ 5, 'one' => 1, 'two' => '2', - array( + [ 'bar', 'baz', "\n" - ) - ); + ] + ]; } diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index 725cb13b..c9e04c90 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -92,7 +92,7 @@ public function validConstantTypes() return [ [ new PropertyValueGenerator([], PropertyValueGenerator::TYPE_ARRAY, ValueGenerator::OUTPUT_SINGLE_LINE), - ' const FOO = array();', + ' const FOO = [];', ], [ new PropertyValueGenerator( @@ -139,12 +139,12 @@ protected function generateArrayData($longOutput, array $value) 'auto' => [ ValueGenerator::TYPE_AUTO, $value, - $longOutput, + $shortOutput, ], 'array' => [ ValueGenerator::TYPE_ARRAY, $value, - $longOutput, + $shortOutput, ], 'array long' => [ ValueGenerator::TYPE_ARRAY_LONG, diff --git a/test/Reflection/ClassReflectionTest.php b/test/Reflection/ClassReflectionTest.php index 9d51c00e..0f084487 100644 --- a/test/Reflection/ClassReflectionTest.php +++ b/test/Reflection/ClassReflectionTest.php @@ -100,7 +100,7 @@ public function getProp2(\$param1, TestSampleClass \$param2) public function getIterator() { - return array(); + return []; } } @@ -133,7 +133,7 @@ public function getProp2(\$param1, TestSampleClass \$param2) public function getIterator() { - return array(); + return []; } } diff --git a/test/Reflection/TestAsset/TestSampleClass2.php b/test/Reflection/TestAsset/TestSampleClass2.php index 2add32aa..579e4922 100644 --- a/test/Reflection/TestAsset/TestSampleClass2.php +++ b/test/Reflection/TestAsset/TestSampleClass2.php @@ -25,7 +25,7 @@ public function getProp2($param1, TestSampleClass $param2) public function getIterator() { - return array(); + return []; } } diff --git a/test/Reflection/TestAsset/TestSampleClass9.php b/test/Reflection/TestAsset/TestSampleClass9.php index 58af8269..63d14cb4 100644 --- a/test/Reflection/TestAsset/TestSampleClass9.php +++ b/test/Reflection/TestAsset/TestSampleClass9.php @@ -27,7 +27,7 @@ public function getProp2($param1, TestSampleClass $param2) public function getIterator() { - return array(); + return []; } } diff --git a/test/Scanner/MethodScannerTest.php b/test/Scanner/MethodScannerTest.php index 854d5daa..9facabcf 100644 --- a/test/Scanner/MethodScannerTest.php +++ b/test/Scanner/MethodScannerTest.php @@ -95,7 +95,7 @@ public function testMethodScannerMethodSignatureLatestOptionalParamHasParenthese $method = $class->getMethod('four'); $paramTwo = $method->getParameter(1); $optionalValue = $paramTwo->getDefaultValue(); - self::assertEquals('array(array(array(\'default\')))', $optionalValue); + self::assertEquals('array([array(\'default\')])', $optionalValue); } /** diff --git a/test/TestAsset/AbstractClass.php b/test/TestAsset/AbstractClass.php index 1fc62336..f6bbe466 100644 --- a/test/TestAsset/AbstractClass.php +++ b/test/TestAsset/AbstractClass.php @@ -11,7 +11,7 @@ abstract class AbstractClass { - protected $config = array(); + protected $config = []; public function getConfig() { diff --git a/test/TestAsset/BarClass.php b/test/TestAsset/BarClass.php index aa977dfb..c56d8deb 100644 --- a/test/TestAsset/BarClass.php +++ b/test/TestAsset/BarClass.php @@ -30,7 +30,7 @@ protected function three(\ArrayObject $o, &$t = 2, FooBarBaz\BazBarFoo $bbf = se $y = 'this string'; } - protected function four($one, $two = array(array(array('default')))) + protected function four($one, $two = array([array('default')])) { // four }