Adding return types to runtime code has BC concerns, but adding to test code should be straightforward and can be at least partially automated with rector.
Use rector with type coverage on core/tests.
Install rector
$ composer require --dev rector/rector
Configure rector.php file
<?php
declare(strict_types=1);
use Rector\TypeDeclaration\Rector\ClassMethod;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector;
return Rector\Config\RectorConfig::configure()
->withPaths([
__DIR__ . '/core/tests',
])
// First level before param and property types are affected.
->withTypeCoverageLevel(22)
->withSkip([
// Skip as this adds unwanted phpdoc changes.
ClassMethod\ReturnTypeFromStrictNewArrayRector::class,
ClassMethod\ReturnTypeFromMockObjectRector::class,
TypedPropertyFromCreateMockAssignRector::class,
])
// Additional rules above level 22 that are useful
->withRules([
ClassMethod\ReturnTypeFromStrictTypedCallRector::class,
ClassMethod\ReturnUnionTypeRector::class,
ClassMethod\ReturnTypeFromStrictParamRector::class,
ClassMethod\ReturnTypeFromStrictFluentReturnRector::class,
ClassMethod\ReturnNeverTypeRector::class,
]);
Run rector
$ ./vendor/bin/rector
Fix code style
$ composer phpcbf
Update baseline
$ ./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --generate-baseline=core/.phpstan-baseline.php --memory-limit=2G
Active
11.0 🔥
other
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.