Skip to content

Commit

Permalink
Add native types to class properties, by Rector PHP
Browse files Browse the repository at this point in the history
```bash
./rector.phar process src --config=rector.php
```

config:

```php
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();

    $services->set(TypedPropertyRector::class);

        $parameters = $containerConfigurator->parameters();

        $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersionFeature::TYPED_PROPERTIES);
};
```
  • Loading branch information
maks-rafalko committed Oct 30, 2020
1 parent 6fcf9c8 commit 17372e9
Show file tree
Hide file tree
Showing 141 changed files with 442 additions and 550 deletions.
5 changes: 1 addition & 4 deletions src/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
*/
abstract class BaseCommand extends Command
{
/**
* @var IO|null
*/
private $io;
private ?IO $io = null;

final public function getApplication(): Application
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config/ConsoleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
class ConsoleHelper
{
private $formatterHelper;
private FormatterHelper $formatterHelper;

public function __construct(FormatterHelper $formatterHelper)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Guesser/PhpUnitPathGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class PhpUnitPathGuesser
{
private const CURRENT_DIR_PATH = '.';

private $composerJsonContent;
private stdClass $composerJsonContent;

public function __construct(stdClass $composerJsonContent)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Guesser/SourceDirGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
class SourceDirGuesser
{
private $composerJsonContent;
private stdClass $composerJsonContent;

public function __construct(stdClass $composerJsonContent)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Config/ValueProvider/ExcludeDirsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ final class ExcludeDirsProvider
{
public const EXCLUDED_ROOT_DIRS = ['vendor', 'tests', 'test'];

private $consoleHelper;
private $questionHelper;
private $filesystem;
private ConsoleHelper $consoleHelper;
private QuestionHelper $questionHelper;
private Filesystem $filesystem;

public function __construct(ConsoleHelper $consoleHelper, QuestionHelper $questionHelper, Filesystem $filesystem)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
*/
final class PhpUnitCustomExecutablePathProvider
{
private $phpUnitExecutableFinder;
private $consoleHelper;
private $questionHelper;
private TestFrameworkFinder $phpUnitExecutableFinder;
private ConsoleHelper $consoleHelper;
private QuestionHelper $questionHelper;

public function __construct(TestFrameworkFinder $phpUnitExecutableFinder, ConsoleHelper $consoleHelper, QuestionHelper $questionHelper)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Config/ValueProvider/SourceDirsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
*/
final class SourceDirsProvider
{
private $consoleHelper;
private $questionHelper;
private $sourceDirGuesser;
private ConsoleHelper $consoleHelper;
private QuestionHelper $questionHelper;
private SourceDirGuesser $sourceDirGuesser;

public function __construct(
ConsoleHelper $consoleHelper,
Expand Down
6 changes: 3 additions & 3 deletions src/Config/ValueProvider/TestFrameworkConfigPathProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
*/
final class TestFrameworkConfigPathProvider
{
private $testFrameworkConfigLocator;
private $consoleHelper;
private $questionHelper;
private TestFrameworkConfigLocatorInterface $testFrameworkConfigLocator;
private ConsoleHelper $consoleHelper;
private QuestionHelper $questionHelper;

public function __construct(TestFrameworkConfigLocatorInterface $testFrameworkConfigLocator, ConsoleHelper $consoleHelper, QuestionHelper $questionHelper)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Config/ValueProvider/TextLogFileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ final class TextLogFileProvider
{
public const TEXT_LOG_FILE_NAME = 'infection.log';

private $consoleHelper;
private $questionHelper;
private ConsoleHelper $consoleHelper;
private QuestionHelper $questionHelper;

public function __construct(ConsoleHelper $consoleHelper, QuestionHelper $questionHelper)
{
Expand Down
61 changes: 33 additions & 28 deletions src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,39 @@ class Configuration
'default',
];

private $timeout;
private $sourceDirectories;
private $sourceFiles;
private $sourceFilesFilter;
private $sourceFilesExcludes;
private $logs;
private $logVerbosity;
private $tmpDir;
private $phpUnit;
private $mutators;
private $testFramework;
private $bootstrap;
private $initialTestsPhpOptions;
private $testFrameworkExtraOptions;
private $coveragePath;
private $skipCoverage;
private $skipInitialTests;
private $debug;
private $onlyCovered;
private $noProgress;
private $ignoreMsiWithNoMutations;
private $minMsi;
private $showMutations;
private $minCoveredMsi;
private $msiPrecision;
private $threadCount;
private $dryRun;
private $ignoreSourceCodeMutatorsMap;
private float $timeout;
/** @var string[] */
private array $sourceDirectories;
/** @var iterable<SplFileInfo> */
private iterable $sourceFiles;
private string $sourceFilesFilter;
/** @var string[] */
private array $sourceFilesExcludes;
private Logs $logs;
private string $logVerbosity;
private string $tmpDir;
private PhpUnit $phpUnit;
/** @var array<string, Mutator> */
private array $mutators;
private string $testFramework;
private ?string $bootstrap = null;
private ?string $initialTestsPhpOptions = null;
private string $testFrameworkExtraOptions;
private string $coveragePath;
private bool $skipCoverage;
private bool $skipInitialTests;
private bool $debug;
private bool $onlyCovered;
private bool $noProgress;
private bool $ignoreMsiWithNoMutations;
private ?float $minMsi = null;
private bool $showMutations;
private ?float $minCoveredMsi = null;
private int $msiPrecision;
private int $threadCount;
private bool $dryRun;
/** @var array<string, array<int, string>> */
private array $ignoreSourceCodeMutatorsMap;

/**
* @param string[] $sourceDirectories
Expand Down
12 changes: 6 additions & 6 deletions src/Configuration/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class ConfigurationFactory
*/
private const DEFAULT_TIMEOUT = 10;

private $tmpDirProvider;
private $mutatorResolver;
private $mutatorFactory;
private $mutatorParser;
private $sourceFileCollector;
private $ciDetector;
private TmpDirProvider $tmpDirProvider;
private MutatorResolver $mutatorResolver;
private MutatorFactory $mutatorFactory;
private MutatorParser $mutatorParser;
private SourceFileCollector $sourceFileCollector;
private CiDetector $ciDetector;

public function __construct(
TmpDirProvider $tmpDirProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Entry/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
final class Badge
{
private $branch;
private string $branch;

public function __construct(string $branch)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Configuration/Entry/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
*/
final class Logs
{
private $textLogFilePath;
private $summaryLogFilePath;
private $jsonLogFilePath;
private $debugLogFilePath;
private $perMutatorFilePath;
private $badge;
private ?string $textLogFilePath;
private ?string $summaryLogFilePath;
private ?string $jsonLogFilePath;
private ?string $debugLogFilePath;
private ?string $perMutatorFilePath;
private ?Badge $badge;

public function __construct(
?string $textLogFilePath,
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Entry/PhpUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
*/
final class PhpUnit
{
private $configDir;
private $customPath;
private ?string $configDir;
private ?string $customPath;

public function __construct(?string $configDir, ?string $executablePath)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Configuration/Entry/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
*/
final class Source
{
private $directories;
private $excludes;
/** @var string[] */
private array $directories;
/** @var string[] */
private array $excludes;

/**
* @param string[] $directories
Expand Down
29 changes: 15 additions & 14 deletions src/Configuration/Schema/SchemaConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@
*/
final class SchemaConfiguration
{
private $file;
private $timeout;
private $source;
private $logs;
private $tmpDir;
private $phpUnit;
private $ignoreMsiWithNoMutations;
private $minMsi;
private $minCoveredMsi;
private $mutators;
private $testFramework;
private $bootstrap;
private $initialTestsPhpOptions;
private $testFrameworkExtraOptions;
private string $file;
private ?float $timeout;
private Source $source;
private Logs $logs;
private ?string $tmpDir;
private PhpUnit $phpUnit;
private ?bool $ignoreMsiWithNoMutations;
private ?float $minMsi;
private ?float $minCoveredMsi;
/** @var array<string, mixed> */
private array $mutators;
private ?string $testFramework;
private ?string $bootstrap;
private ?string $initialTestsPhpOptions;
private ?string $testFrameworkExtraOptions;

/**
* @param array<string, mixed> $mutators
Expand Down
7 changes: 2 additions & 5 deletions src/Configuration/Schema/SchemaConfigurationFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@
*/
final class SchemaConfigurationFile
{
private $path;
private string $path;

/**
* @var stdClass|null
*/
private $decodedContents;
private ?stdClass $decodedContents = null;

public function __construct(string $path)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Schema/SchemaConfigurationFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
*/
class SchemaConfigurationFileLoader
{
private $schemaValidator;
private $factory;
private SchemaValidator $schemaValidator;
private SchemaConfigurationFactory $factory;

public function __construct(SchemaValidator $schemaValidator, SchemaConfigurationFactory $factory)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Schema/SchemaConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ final class SchemaConfigurationLoader
public const DEFAULT_DIST_CONFIG_FILE = 'infection.json.dist';
public const DEFAULT_CONFIG_FILE = 'infection.json';

private $locator;
private $fileLoader;
private Locator $locator;
private SchemaConfigurationFileLoader $fileLoader;

public function __construct(Locator $locator, SchemaConfigurationFileLoader $fileLoader)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class Application extends BaseApplication
';

private $container;
private Container $container;

public function __construct(Container $container)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ConsoleOutput
private const RUNNING_WITH_DEBUGGER_NOTE = 'You are running Infection with %s enabled.';
private const MIN_MSI_CAN_GET_INCREASED_NOTICE = 'The %s is %s%% percentage points over the required %s. Consider increasing the required %s percentage the next time you run Infection.';

private $logger;
private ConsoleLogger $logger;

public function __construct(ConsoleLogger $logger)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Console/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*/
final class IO extends SymfonyStyle
{
private $input;
private $output;
private InputInterface $input;
private OutputInterface $output;

public function __construct(InputInterface $input, OutputInterface $output)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Console/OutputFormatter/AbstractOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ abstract class AbstractOutputFormatter implements OutputFormatter
*/
public const UNKNOWN_COUNT = 0;

/**
* @var int
*/
protected $callsCount = 0;
protected int $callsCount = 0;

public function start(int $mutationCount): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/OutputFormatter/DotFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class DotFormatter extends AbstractOutputFormatter
{
private const DOTS_PER_ROW = 50;

private $output;
private OutputInterface $output;

public function __construct(OutputInterface $output)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/OutputFormatter/FormatterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
final class FormatterFactory
{
private $output;
private OutputInterface $output;

public function __construct(OutputInterface $output)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/OutputFormatter/ProgressFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
final class ProgressFormatter extends AbstractOutputFormatter
{
private $progressBar;
private ProgressBar $progressBar;

public function __construct(ProgressBar $progressBar)
{
Expand Down

0 comments on commit 17372e9

Please sign in to comment.