Fix incorrect type hint and make daily "updated deps" QA jobs pass

Created on 25 April 2023, about 1 year ago
Updated 1 May 2023, about 1 year ago

Problem/Motivation

Currently our daily "updated deps" QA job fails on 10.0.x and 10.1.x with a nice:

PHP Fatal error:  Uncaught TypeError: SlevomatCodingStandard\Helpers\Annotation\TypeAliasAnnotation::__construct(): Argument #5 ($contentNode) must be of type ?PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasTagValueNode, PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode given, called in /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 359 and defined in /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/TypeAliasAnnotation.php:21
Stack trace:
#0 /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(359): SlevomatCodingStandard\Helpers\Annotation\TypeAliasAnnotation->__construct('@type', 81, 83, 'string', Object(PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode))
#1 /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/SniffLocalCache.php(42): SlevomatCodingStandard\Helpers\AnnotationHelper::SlevomatCodingStandard\Helpers\{closure}()
#2 /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/SniffLocalCache.php(31): SlevomatCodingStandard\Helpers\SniffLocalCache::setIfNotCached(0, '/var/www/html/c...', Object(Closure))
#3 /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(374): SlevomatCodingStandard\Helpers\SniffLocalCache::getAndSetIfNotCached(Object(PHP_CodeSniffer\Files\LocalFile), 'annotations-60', Object(Closure))
#4 /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/ForbiddenAnnotationsSniff.php(49): SlevomatCodingStandard\Helpers\AnnotationHelper::getAnnotations(Object(PHP_CodeSniffer\Files\LocalFile), 60)
#5 /var/www/html/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): SlevomatCodingStandard\Sniffs\Commenting\ForbiddenAnnotationsSniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 60)
#6 /var/www/html/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#7 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(632): PHP_CodeSniffer\Files\LocalFile->process()
#8 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(504): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
#9 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(116): PHP_CodeSniffer\Runner->run()
#10 /var/www/html/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#11 /var/www/html/vendor/bin/phpcs(120): include('/var/www/html/v...')
#12 {main}
  thrown in /var/www/html/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/TypeAliasAnnotation.php on line 21
PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: One or more child processes failed to run in /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php:546
Stack trace:
#0 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(116): PHP_CodeSniffer\Runner->run()
#1 /var/www/html/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#2 /var/www/html/vendor/bin/phpcs(120): include('/var/www/html/v...')
#3 {main}
  thrown in /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php on line 546

(See https://www.drupal.org/node/3060/qa )

Steps to reproduce

See https://www.drupal.org/node/3060/qa and notice the failures on both updated deps jobs for 10.0.x and 10.1.x

After some research it turns out that the update of drupal/coder which updates (amongst other dependencies) slevomat/coding-standard in combination with a incorrect type hint is the root cause.

Run:
- composer update drupal/coder -W
- vendor/bin/phpcs -ps --parallel=$(nproc) --standard="./core/phpcs.xml.dist" core/lib/Drupal/Core/Template/DebugExtension.php -vvv\
- CLUNK!

Proposed resolution

- Fix incorrect type hint in core/lib/Drupal/Core/Template/DebugExtension.php

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.1

Component
Composer 

Last updated about 23 hours ago

No maintainer
Created by

🇳🇱Netherlands Spokje

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024