From c7df023181631df6ad4837eda12f09e1c32afe07 Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Wed, 21 Aug 2024 18:45:44 +0200 Subject: [PATCH] Enable `trailing_comma_in_multiline` only for arrays --- .php-cs-fixer.dist.php | 3 ++- spec/Prophecy/Call/CallCenterSpec.php | 6 +++--- .../Doubler/Generator/ClassCodeGeneratorSpec.php | 4 ++-- .../Doubler/Generator/Node/ClassNodeSpec.php | 4 ++-- spec/Prophecy/Prophecy/ObjectProphecySpec.php | 12 ++++++------ spec/Prophecy/Prophecy/RevealerSpec.php | 4 ++-- src/Prophecy/Doubler/Generator/ClassMirror.php | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3bf19ab0a..183dc0c49 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,7 +11,8 @@ ], 'concat_space' => ['spacing' => 'none'], 'method_argument_space' => ['on_multiline' => 'ignore'], - 'trailing_comma_in_multiline' => false, + // Since PHP 7.2 is supported we can't add trailing commas in arguments, parameters and match + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], 'visibility_required' => false, ]) ->setFinder( diff --git a/spec/Prophecy/Call/CallCenterSpec.php b/spec/Prophecy/Call/CallCenterSpec.php index a4535bbc1..1e3b5dd88 100644 --- a/spec/Prophecy/Call/CallCenterSpec.php +++ b/spec/Prophecy/Call/CallCenterSpec.php @@ -65,7 +65,7 @@ function it_executes_promise_of_method_prophecy_that_matches_signature_passed_to $objectProphecy->getMethodProphecies()->willReturn(array( 'method1' => array($method1), - 'method2' => array($method2, $method3) + 'method2' => array($method2, $method3), )); $objectProphecy->getMethodProphecies('getName')->willReturn(array($method1, $method3)); $objectProphecy->reveal()->willReturn(new \stdClass()); @@ -107,10 +107,10 @@ function it_executes_promise_of_method_prophecy_that_matches_with_highest_score_ $objectProphecy->getMethodProphecies()->willReturn(array( 'method1' => array($method1), - 'method2' => array($method2, $method3) + 'method2' => array($method2, $method3), )); $objectProphecy->getMethodProphecies('getName')->willReturn(array( - $method1, $method2, $method3 + $method1, $method2, $method3, )); $objectProphecy->reveal()->willReturn(new \stdClass()); diff --git a/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php b/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php index 03e8811d8..6f728de69 100644 --- a/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php +++ b/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php @@ -28,7 +28,7 @@ function it_generates_proper_php_code_for_specific_ClassNode( ) { $class->getParentClass()->willReturn('RuntimeException'); $class->getInterfaces()->willReturn(array( - 'Prophecy\Doubler\Generator\MirroredInterface', 'ArrayAccess', 'ArrayIterator' + 'Prophecy\Doubler\Generator\MirroredInterface', 'ArrayAccess', 'ArrayIterator', )); $class->getProperties()->willReturn(array('name' => 'public', 'email' => 'private')); $class->getMethods()->willReturn(array($method1, $method2, $method3, $method4, $method5)); @@ -155,7 +155,7 @@ function it_generates_proper_php_code_for_variadics( $class->getInterfaces()->willReturn(array('Prophecy\Doubler\Generator\MirroredInterface')); $class->getProperties()->willReturn(array()); $class->getMethods()->willReturn(array( - $method1, $method2, $method3, $method4 + $method1, $method2, $method3, $method4, )); $class->isReadOnly()->willReturn(false); diff --git a/spec/Prophecy/Doubler/Generator/Node/ClassNodeSpec.php b/spec/Prophecy/Doubler/Generator/Node/ClassNodeSpec.php index d1b73ea28..0c5e07f6c 100644 --- a/spec/Prophecy/Doubler/Generator/Node/ClassNodeSpec.php +++ b/spec/Prophecy/Doubler/Generator/Node/ClassNodeSpec.php @@ -78,7 +78,7 @@ function it_can_has_methods(MethodNode $method1, MethodNode $method2) $this->getMethods()->shouldReturn(array( '__construct' => $method1, - 'getName' => $method2 + 'getName' => $method2, )); } @@ -126,7 +126,7 @@ function it_is_able_to_have_properties() $this->addProperty('text', 'private'); $this->getProperties()->shouldReturn(array( 'title' => 'public', - 'text' => 'private' + 'text' => 'private', )); } diff --git a/spec/Prophecy/Prophecy/ObjectProphecySpec.php b/spec/Prophecy/Prophecy/ObjectProphecySpec.php index 08266be85..55f298c0d 100644 --- a/spec/Prophecy/Prophecy/ObjectProphecySpec.php +++ b/spec/Prophecy/Prophecy/ObjectProphecySpec.php @@ -125,7 +125,7 @@ function its_addMethodProphecy_adds_method_prophecy( $this->addMethodProphecy($methodProphecy); $this->getMethodProphecies()->shouldReturn(array( - 'getusername' => array($methodProphecy) + 'getusername' => array($methodProphecy), )); } @@ -148,7 +148,7 @@ function its_addMethodProphecy_handles_prophecies_with_different_arguments( 'getusername' => array( $methodProphecy1, $methodProphecy2, - ) + ), )); } @@ -171,7 +171,7 @@ function its_addMethodProphecy_handles_prophecies_for_caseinsensitive_method_nam 'getusername' => array( $methodProphecy1, $methodProphecy2, - ) + ), )); } @@ -192,11 +192,11 @@ function its_addMethodProphecy_handles_prophecies_for_different_methods( $this->getMethodProphecies()->shouldReturn(array( 'getusername' => array( - $methodProphecy1 + $methodProphecy1, ), 'isusername' => array( - $methodProphecy2 - ) + $methodProphecy2, + ), )); } diff --git a/spec/Prophecy/Prophecy/RevealerSpec.php b/spec/Prophecy/Prophecy/RevealerSpec.php index fcaa7ca3a..514787343 100644 --- a/spec/Prophecy/Prophecy/RevealerSpec.php +++ b/spec/Prophecy/Prophecy/RevealerSpec.php @@ -30,10 +30,10 @@ function it_reveals_instances_of_ProphecyInterface_inside_array( $this->reveal(array( array('item' => $prophecy2), - $prophecy1 + $prophecy1, ))->shouldReturn(array( array('item' => $object2), - $object1 + $object1, )); } diff --git a/src/Prophecy/Doubler/Generator/ClassMirror.php b/src/Prophecy/Doubler/Generator/ClassMirror.php index b664e14f9..5a6f0d0e1 100644 --- a/src/Prophecy/Doubler/Generator/ClassMirror.php +++ b/src/Prophecy/Doubler/Generator/ClassMirror.php @@ -38,7 +38,7 @@ class ClassMirror '__wakeup', '__toString', '__call', - '__invoke' + '__invoke', ); /**