Closed enl closed 2 years ago
A bit more details on what's the issue:
When I run phpcs in single process mode, phpcs returns 255 status code and successfully fails my Jenkins build
% vendor/bin/phpcs -standard=ci/phpcs.xml -parallel=1
..............PHP Fatal error: Uncaught TypeError: Argument 5 passed to SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct() must be an instance of PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode or null, instance of PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31
Stack trace:
#0 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(357): SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation->__construct('@param', 1181, 1183, '$types', Object(PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode))
#1 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/Sl in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31Fatal error: Uncaught TypeError: Argument 5 passed to SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct() must be an instance of PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode or null, instance of PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31
Stack trace:
#0 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(357): SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation->__construct('@param', 1181, 1183, '$types', Object(PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode))
#1 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/Sl in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31
aleksandrpanshin@Aleksandrs-MacBook-Pro phpcs-rulesets % echo $?
255
But if I do the same in parallel, then I get 0
status:
aleksandrpanshin@Aleksandrs-MacBook-Pro phpcs-rulesets % vendor/bin/phpcs -standard=ci/phpcs.xml -parallel=2
.PHP Fatal error: Uncaught TypeError: Argument 5 passed to SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct() must be an instance of PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode or null, instance of PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31
Stack trace:
#0 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(357): SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation->__construct('@param', 1181, 1183, '$types', Object(PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode))
#1 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/Sl in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31Fatal error: Uncaught TypeError: Argument 5 passed to SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct() must be an instance of PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode or null, instance of PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31
Stack trace:
#0 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(357): SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation->__construct('@param', 1181, 1183, '$types', Object(PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode))
#1 /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/Sl in /Users/aleksandrpanshin/work/modules/phpcs-rulesets/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31
. 2 / 2 (100%)
Time: 1.4 secs; Memory: 12MBaleksandrpanshin@Aleksandrs-MacBook-Pro phpcs-rulesets % echo $?
0
Thanks for submitted a fix for this. I simplified the logic a bit by just reusing the $success
variable as this was only an issue when no errors were reported by the child process (as you said).
When a child process fails, e.g. with a FatalError, it might still return empty list of errors. Although, child process failure is definitely not a thing we want to ignore.
Therefore, we check exit status of each child process and make sure parent process fails (and returns non-zero status code) as well.