Problem/Motivation
This is a child issue of #3376057: [META] Add declare(strict_types = 1) to all tests. After adding enabling strict types to all tests there were around 3000 errors. Fixing them all in one issue will lead to an enormous merge request that's difficult to review, as per the issue scope guidelines.
Steps to reproduce
Create the rector.php file:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(DeclareStrictTypesRector::class);
$rectorConfig->skip([
DeclareStrictTypesRector::class => [
__DIR__ . '/core/tests/Drupal/Tests/Composer/ComposerIntegrationTrait.php',
__DIR__ . '/core/tests/Drupal/Tests/Listeners/',
__DIR__ . '/core/tests/Drupal/Tests/Component/DependencyInjection/Fixture/',
__DIR__ . '/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/fixtures',
__DIR__ . '/core/tests/Drupal/Tests/Traits',
],
]);
};
Process all unit tests:
composer require rector/rector --dev
find core/tests/Drupal/Tests/ -type d -mindepth 1 -maxdepth 1 | xargs php vendor/bin/rector process
find core -type d -path "core/*/tests/src/Unit" | xargs php vendor/bin/rector process
Run the test suite:
./vendor/bin/phpunit -c core/phpunit.xml.dist --bootstrap=core/tests/bootstrap.php --testsuite=unit
Proposed resolution
- Fix all strict type issues in unit tests in this issue
- Follow up #3399373: Add declare(strict_types=1) to all Unit tests
Remaining tasks
Review updated MR