diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 992ba728..9c2f683d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -114,9 +114,9 @@ jobs: docker run -i --rm -v $PWD:/churn ${{ matrix.vcs }} /churn/vendor/bin/simple-phpunit -c /churn/phpunit.xml.dist /churn/tests/EndToEnd/${vcs^}Test.php --coverage-clover=/churn/coverage-${{ matrix.vcs }}.xml sed -i 's/\/churn\/src/\/home\/runner\/work\/${{ github.event.repository.name }}\/${{ github.event.repository.name }}\/src/g' coverage-${{ matrix.vcs }}.xml - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-${{ matrix.vcs }} path: ./coverage-${{ matrix.vcs }}.xml coverage: @@ -146,9 +146,10 @@ jobs: run: "vendor/bin/simple-phpunit --colors=always --testdox --testsuite churn-tests --coverage-clover=coverage.xml" - name: "Download other code coverage reports" - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: coverage + pattern: coverage-* + merge-multiple: true path: ./coverage - name: "List all coverage reports" @@ -269,7 +270,7 @@ jobs: run: diff -u <(build/bin/churn --format=csv | sort) <(./churn.phar --format=csv | sort) - name: "Save Phar" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: churn.phar path: ./churn.phar @@ -300,7 +301,7 @@ jobs: tools: none - name: Download churn.phar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: churn.phar @@ -342,7 +343,7 @@ jobs: tools: none - name: Download churn.phar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: churn.phar diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a30a263c..cbfae846 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,10 +20,10 @@ jobs: with: coverage: "pcov" ini-values: "error_reporting=-1, display_errors=On, display_startup_errors=On, zend.assertions=1" - php-version: "8.1" + php-version: "8.2" tools: composer:v2, infection - - uses: "ramsey/composer-install@v2" + - uses: "ramsey/composer-install@v3" with: dependency-versions: "highest" composer-options: "--no-scripts" diff --git a/phpcs-tests.xml b/phpcs-tests.xml index 14bef834..0d1ea2dd 100644 --- a/phpcs-tests.xml +++ b/phpcs-tests.xml @@ -65,5 +65,10 @@ + + + + + diff --git a/phpcs.xml b/phpcs.xml index cdefdb7b..ef7b08ff 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -59,6 +59,11 @@ + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 85baba37..01e06e48 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -25,6 +25,5 @@ - diff --git a/psalm.xml b/psalm.xml index 92ca14cd..d7227a87 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,6 +17,7 @@ + diff --git a/src/Assessor/CyclomaticComplexityAssessor.php b/src/Assessor/CyclomaticComplexityAssessor.php index fb7e6a70..361e700e 100644 --- a/src/Assessor/CyclomaticComplexityAssessor.php +++ b/src/Assessor/CyclomaticComplexityAssessor.php @@ -43,6 +43,7 @@ public function __construct() * * @param string $contents The contents of a PHP file. */ + #[\Override] public function assess(string $contents): int { $score = 0; diff --git a/src/Command/AssessComplexityCommand.php b/src/Command/AssessComplexityCommand.php index fe7a057b..1a3c6a09 100644 --- a/src/Command/AssessComplexityCommand.php +++ b/src/Command/AssessComplexityCommand.php @@ -44,6 +44,7 @@ public static function newInstance(): self /** * Configure the command */ + #[\Override] protected function configure(): void { $this->setName('assess-complexity') @@ -57,6 +58,7 @@ protected function configure(): void * @param InputInterface $input Input. * @param OutputInterface $output Output. */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output): int { $file = (string) $input->getArgument('file'); diff --git a/src/Command/Helper/ProgressBarSubscriber.php b/src/Command/Helper/ProgressBarSubscriber.php index 019dd02b..e6d6bf9d 100644 --- a/src/Command/Helper/ProgressBarSubscriber.php +++ b/src/Command/Helper/ProgressBarSubscriber.php @@ -34,6 +34,7 @@ public function __construct(OutputInterface $output) /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->progressBar->finish(); @@ -42,6 +43,7 @@ public function onAfterAnalysis(AfterAnalysisEvent $event): void /** * @param BeforeAnalysisEvent $event The event triggered when the analysis starts. */ + #[\Override] public function onBeforeAnalysis(BeforeAnalysisEvent $event): void { $this->progressBar->start(); @@ -50,6 +52,7 @@ public function onBeforeAnalysis(BeforeAnalysisEvent $event): void /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->progressBar->advance(); diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index 32e9cd0f..d6d927ef 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -84,6 +84,7 @@ public static function newInstance(): self /** * Configure the command */ + #[\Override] protected function configure(): void { $this->setName('run') @@ -104,6 +105,7 @@ protected function configure(): void * @param InputInterface $input Input. * @param OutputInterface $output Output. */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output): int { if (true === $input->getOption('quiet')) { diff --git a/src/Configuration/Validator/BaseValidator.php b/src/Configuration/Validator/BaseValidator.php index f4ab55dc..d444a2d2 100644 --- a/src/Configuration/Validator/BaseValidator.php +++ b/src/Configuration/Validator/BaseValidator.php @@ -34,6 +34,7 @@ public function __construct(string $key) /** * Returns the configuration key. */ + #[\Override] public function getKey(): string { return $this->key; @@ -43,6 +44,7 @@ public function getKey(): string * @param EditableConfig $config The configuration object. * @param array $configuration The array containing the configuration values. */ + #[\Override] public function validate(EditableConfig $config, array $configuration): void { if (!\array_key_exists($this->key, $configuration)) { diff --git a/src/Configuration/Validator/CachePath.php b/src/Configuration/Validator/CachePath.php index d2cb14b6..3f927965 100644 --- a/src/Configuration/Validator/CachePath.php +++ b/src/Configuration/Validator/CachePath.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/CommitsSince.php b/src/Configuration/Validator/CommitsSince.php index dac2d6e7..4beb5096 100644 --- a/src/Configuration/Validator/CommitsSince.php +++ b/src/Configuration/Validator/CommitsSince.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param array $configuration The array containing the configuration values. */ + #[\Override] public function validate(EditableConfig $config, array $configuration): void { if (!$this->hasConfigurationKey($configuration)) { @@ -40,6 +41,7 @@ public function validate(EditableConfig $config, array $configuration): void * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::string($value, 'Commits since should be a string'); diff --git a/src/Configuration/Validator/DirectoriesToScan.php b/src/Configuration/Validator/DirectoriesToScan.php index 15c29d86..a2601bf8 100644 --- a/src/Configuration/Validator/DirectoriesToScan.php +++ b/src/Configuration/Validator/DirectoriesToScan.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Directories to scan should be an array of strings'); diff --git a/src/Configuration/Validator/FileExtensions.php b/src/Configuration/Validator/FileExtensions.php index 857194bf..23b87172 100644 --- a/src/Configuration/Validator/FileExtensions.php +++ b/src/Configuration/Validator/FileExtensions.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'File extensions should be an array of strings'); diff --git a/src/Configuration/Validator/FilesToIgnore.php b/src/Configuration/Validator/FilesToIgnore.php index b9246032..ed227771 100644 --- a/src/Configuration/Validator/FilesToIgnore.php +++ b/src/Configuration/Validator/FilesToIgnore.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Files to ignore should be an array of strings'); diff --git a/src/Configuration/Validator/FilesToShow.php b/src/Configuration/Validator/FilesToShow.php index efcb0493..b4f874ab 100644 --- a/src/Configuration/Validator/FilesToShow.php +++ b/src/Configuration/Validator/FilesToShow.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::integer($value, 'Files to show should be an integer'); diff --git a/src/Configuration/Validator/Hooks.php b/src/Configuration/Validator/Hooks.php index 7ed7490a..d783a3b5 100644 --- a/src/Configuration/Validator/Hooks.php +++ b/src/Configuration/Validator/Hooks.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Hooks should be an array of strings'); diff --git a/src/Configuration/Validator/MaxScoreThreshold.php b/src/Configuration/Validator/MaxScoreThreshold.php index 90d6623e..a08fc627 100644 --- a/src/Configuration/Validator/MaxScoreThreshold.php +++ b/src/Configuration/Validator/MaxScoreThreshold.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/MinScoreToShow.php b/src/Configuration/Validator/MinScoreToShow.php index 880ee39e..5ee13d29 100644 --- a/src/Configuration/Validator/MinScoreToShow.php +++ b/src/Configuration/Validator/MinScoreToShow.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/ParallelJobs.php b/src/Configuration/Validator/ParallelJobs.php index 72a17c2d..8caa41d0 100644 --- a/src/Configuration/Validator/ParallelJobs.php +++ b/src/Configuration/Validator/ParallelJobs.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::integer($value, 'Amount of parallel jobs should be an integer'); diff --git a/src/Configuration/Validator/Vcs.php b/src/Configuration/Validator/Vcs.php index bfece928..1619431c 100644 --- a/src/Configuration/Validator/Vcs.php +++ b/src/Configuration/Validator/Vcs.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::string($value, 'VCS should be a string'); diff --git a/src/Event/BrokerImpl.php b/src/Event/BrokerImpl.php index fc71381b..84a372e7 100644 --- a/src/Event/BrokerImpl.php +++ b/src/Event/BrokerImpl.php @@ -39,6 +39,7 @@ public function __construct() /** * @param object $subscriber A subscriber object. */ + #[\Override] public function subscribe($subscriber): void { foreach ($this->channels as $channel) { @@ -53,6 +54,7 @@ public function subscribe($subscriber): void /** * @param Event $event The triggered event. */ + #[\Override] public function notify(Event $event): void { foreach ($this->subscribers as $eventClass => $subscribers) { diff --git a/src/Event/Channel/AfterAnalysisChannel.php b/src/Event/Channel/AfterAnalysisChannel.php index 175f42d1..acc974ef 100644 --- a/src/Event/Channel/AfterAnalysisChannel.php +++ b/src/Event/Channel/AfterAnalysisChannel.php @@ -18,6 +18,7 @@ final class AfterAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof AfterAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return AfterAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param AfterAnalysis $subscriber * @psalm-return Closure(AfterAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (AfterAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Channel/AfterFileAnalysisChannel.php b/src/Event/Channel/AfterFileAnalysisChannel.php index 3bc3b1bd..3b80c64c 100644 --- a/src/Event/Channel/AfterFileAnalysisChannel.php +++ b/src/Event/Channel/AfterFileAnalysisChannel.php @@ -18,6 +18,7 @@ final class AfterFileAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof AfterFileAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return AfterFileAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param AfterFileAnalysis $subscriber * @psalm-return Closure(AfterFileAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (AfterFileAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Channel/BeforeAnalysisChannel.php b/src/Event/Channel/BeforeAnalysisChannel.php index 3718b3f5..4e698f80 100644 --- a/src/Event/Channel/BeforeAnalysisChannel.php +++ b/src/Event/Channel/BeforeAnalysisChannel.php @@ -18,6 +18,7 @@ final class BeforeAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof BeforeAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return BeforeAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param BeforeAnalysis $subscriber * @psalm-return Closure(BeforeAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (BeforeAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Event/AfterAnalysisEvent.php b/src/Event/Event/AfterAnalysisEvent.php index 1b6b2c40..33979ac7 100644 --- a/src/Event/Event/AfterAnalysisEvent.php +++ b/src/Event/Event/AfterAnalysisEvent.php @@ -27,6 +27,7 @@ public function __construct(ResultReporter $resultReporter) /** * Returns the total number of files analysed. */ + #[\Override] public function getNumberOfFiles(): int { return $this->resultReporter->getNumberOfFiles(); @@ -35,6 +36,7 @@ public function getNumberOfFiles(): int /** * Returns the max number of changes among the analysed files. */ + #[\Override] public function getMaxNumberOfChanges(): int { return $this->resultReporter->getMaxCommits(); @@ -43,6 +45,7 @@ public function getMaxNumberOfChanges(): int /** * Returns the max cyclomatic complexity among the analysed files. */ + #[\Override] public function getMaxCyclomaticComplexity(): int { return $this->resultReporter->getMaxComplexity(); @@ -51,6 +54,7 @@ public function getMaxCyclomaticComplexity(): int /** * Returns the highest score among the analysed files. */ + #[\Override] public function getMaxScore(): ?float { return $this->resultReporter->getMaxScore(); diff --git a/src/Event/Event/AfterFileAnalysisEvent.php b/src/Event/Event/AfterFileAnalysisEvent.php index a92fc7d9..7157e223 100644 --- a/src/Event/Event/AfterFileAnalysisEvent.php +++ b/src/Event/Event/AfterFileAnalysisEvent.php @@ -35,6 +35,7 @@ public function getResult(): ResultInterface /** * Returns the absolute path of the file. */ + #[\Override] public function getFilePath(): string { return $this->result->getFile()->getFullPath(); @@ -43,6 +44,7 @@ public function getFilePath(): string /** * Returns the number of times the file has been changed. */ + #[\Override] public function getNumberOfChanges(): int { return $this->result->getCommits(); @@ -51,6 +53,7 @@ public function getNumberOfChanges(): int /** * Returns the cyclomatic complexity of the file. */ + #[\Override] public function getCyclomaticComplexity(): int { return $this->result->getComplexity(); diff --git a/src/Event/Subscriber/AfterAnalysisHookDecorator.php b/src/Event/Subscriber/AfterAnalysisHookDecorator.php index f5b58229..134c7b82 100644 --- a/src/Event/Subscriber/AfterAnalysisHookDecorator.php +++ b/src/Event/Subscriber/AfterAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->hook::afterAnalysis($event); diff --git a/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php b/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php index 83acd71b..6f628c18 100644 --- a/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php +++ b/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->hook::afterFileAnalysis($event); diff --git a/src/Event/Subscriber/BeforeAnalysisHookDecorator.php b/src/Event/Subscriber/BeforeAnalysisHookDecorator.php index 9a27b938..893697de 100644 --- a/src/Event/Subscriber/BeforeAnalysisHookDecorator.php +++ b/src/Event/Subscriber/BeforeAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param BeforeAnalysisEvent $event The event triggered when the analysis starts. */ + #[\Override] public function onBeforeAnalysis(BeforeAnalysisEvent $event): void { $this->hook::beforeAnalysis($event); diff --git a/src/Process/CacheProcessFactory.php b/src/Process/CacheProcessFactory.php index 58a07f7c..ea8683e1 100644 --- a/src/Process/CacheProcessFactory.php +++ b/src/Process/CacheProcessFactory.php @@ -57,6 +57,7 @@ public function __construct(string $cachePath, ProcessFactory $processFactory) * @param File $file File that the processes will execute on. * @return iterable The list of processes to execute. */ + #[\Override] public function createProcesses(File $file): iterable { if (!$this->isCached($file)) { @@ -75,6 +76,7 @@ public function createProcesses(File $file): iterable /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->writeCache(); @@ -83,6 +85,7 @@ public function onAfterAnalysis(AfterAnalysisEvent $event): void /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->addToCache( diff --git a/src/Process/ChangesCount/FossilChangesCountProcess.php b/src/Process/ChangesCount/FossilChangesCountProcess.php index 40ad8208..9fd4a869 100644 --- a/src/Process/ChangesCount/FossilChangesCountProcess.php +++ b/src/Process/ChangesCount/FossilChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $dateSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { $count = 0; diff --git a/src/Process/ChangesCount/GitChangesCountProcess.php b/src/Process/ChangesCount/GitChangesCountProcess.php index 098223ad..86cef9ca 100644 --- a/src/Process/ChangesCount/GitChangesCountProcess.php +++ b/src/Process/ChangesCount/GitChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $commitsSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return (int) $this->getOutput(); diff --git a/src/Process/ChangesCount/MercurialChangesCountProcess.php b/src/Process/ChangesCount/MercurialChangesCountProcess.php index c7ab289e..5ad32daf 100644 --- a/src/Process/ChangesCount/MercurialChangesCountProcess.php +++ b/src/Process/ChangesCount/MercurialChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $dateSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return \substr_count($this->getOutput(), "\n"); diff --git a/src/Process/ChangesCount/NoVcsChangesCountProcess.php b/src/Process/ChangesCount/NoVcsChangesCountProcess.php index fc42a158..802ade4c 100644 --- a/src/Process/ChangesCount/NoVcsChangesCountProcess.php +++ b/src/Process/ChangesCount/NoVcsChangesCountProcess.php @@ -32,6 +32,7 @@ public function __construct(File $file) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return 1; @@ -40,6 +41,7 @@ public function countChanges(): int /** * Start the process. */ + #[\Override] public function start(): void { // nothing to do @@ -48,6 +50,7 @@ public function start(): void /** * Determines if the process was successful. */ + #[\Override] public function isSuccessful(): bool { return true; @@ -56,6 +59,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; diff --git a/src/Process/ChangesCount/SubversionChangesCountProcess.php b/src/Process/ChangesCount/SubversionChangesCountProcess.php index d5dcb97e..a76bedde 100644 --- a/src/Process/ChangesCount/SubversionChangesCountProcess.php +++ b/src/Process/ChangesCount/SubversionChangesCountProcess.php @@ -30,6 +30,7 @@ public function __construct(File $file, string $dateRange) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return (int) \floor(\substr_count($this->getOutput(), "\n") / 2); diff --git a/src/Process/ChurnProcess.php b/src/Process/ChurnProcess.php index e947ddf2..68fee03a 100644 --- a/src/Process/ChurnProcess.php +++ b/src/Process/ChurnProcess.php @@ -42,6 +42,7 @@ public function __construct(File $file, Process $process) /** * Start the process. */ + #[\Override] public function start(): void { $this->process->start(); @@ -52,6 +53,7 @@ public function start(): void * * @throws ProcessFailedException If the process failed. */ + #[\Override] public function isSuccessful(): bool { $exitCode = $this->process->getExitCode(); @@ -66,6 +68,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; diff --git a/src/Process/ConcreteProcessFactory.php b/src/Process/ConcreteProcessFactory.php index 1e046153..a7f0677f 100644 --- a/src/Process/ConcreteProcessFactory.php +++ b/src/Process/ConcreteProcessFactory.php @@ -45,6 +45,7 @@ public function __construct(string $vcs, string $commitsSince) * @param File $file File that the processes will execute on. * @return iterable The list of processes to execute. */ + #[\Override] public function createProcesses(File $file): iterable { $processes = []; diff --git a/src/Process/CyclomaticComplexityProcess.php b/src/Process/CyclomaticComplexityProcess.php index 78c41f6c..6e4cae8b 100644 --- a/src/Process/CyclomaticComplexityProcess.php +++ b/src/Process/CyclomaticComplexityProcess.php @@ -12,6 +12,7 @@ final class CyclomaticComplexityProcess extends ChurnProcess implements Cyclomat /** * Returns the cyclomatic complexity of a file. */ + #[\Override] public function getCyclomaticComplexity(): int { return (int) $this->getOutput(); diff --git a/src/Process/Handler/ParallelProcessHandler.php b/src/Process/Handler/ParallelProcessHandler.php index 5b678415..231e8f36 100644 --- a/src/Process/Handler/ParallelProcessHandler.php +++ b/src/Process/Handler/ParallelProcessHandler.php @@ -54,6 +54,7 @@ public function __construct(int $numberOfParallelJobs, Broker $broker) * @param ProcessFactory $processFactory Process Factory. * @psalm-param Generator<\Churn\File\File> $filesFinder */ + #[\Override] public function process(Generator $filesFinder, ProcessFactory $processFactory): void { $pool = []; diff --git a/src/Process/Handler/SequentialProcessHandler.php b/src/Process/Handler/SequentialProcessHandler.php index e61274ec..4976a24d 100644 --- a/src/Process/Handler/SequentialProcessHandler.php +++ b/src/Process/Handler/SequentialProcessHandler.php @@ -36,6 +36,7 @@ public function __construct(Broker $broker) * @param ProcessFactory $processFactory Process Factory. * @psalm-param Generator<\Churn\File\File> $filesFinder */ + #[\Override] public function process(Generator $filesFinder, ProcessFactory $processFactory): void { foreach ($filesFinder as $file) { diff --git a/src/Process/PredefinedProcess.php b/src/Process/PredefinedProcess.php index 515b110a..872f2a22 100644 --- a/src/Process/PredefinedProcess.php +++ b/src/Process/PredefinedProcess.php @@ -41,6 +41,7 @@ public function __construct(File $file, int $countChanges, int $cyclomaticComple /** * Start the process. */ + #[\Override] public function start(): void { // nothing to do @@ -49,6 +50,7 @@ public function start(): void /** * Determines if the process was successful. */ + #[\Override] public function isSuccessful(): bool { return true; @@ -57,6 +59,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; @@ -65,6 +68,7 @@ public function getFile(): File /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return $this->countChanges; @@ -73,6 +77,7 @@ public function countChanges(): int /** * Returns the cyclomatic complexity of a file. */ + #[\Override] public function getCyclomaticComplexity(): int { return $this->cyclomaticComplexity; diff --git a/src/Result/Render/ConsoleResultsRenderer.php b/src/Result/Render/ConsoleResultsRenderer.php index 5e6f2dcf..af0b04da 100644 --- a/src/Result/Render/ConsoleResultsRenderer.php +++ b/src/Result/Render/ConsoleResultsRenderer.php @@ -18,6 +18,7 @@ final class ConsoleResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $table = new Table($output); diff --git a/src/Result/Render/CsvResultsRenderer.php b/src/Result/Render/CsvResultsRenderer.php index 4629e8cd..1f79e6b3 100644 --- a/src/Result/Render/CsvResultsRenderer.php +++ b/src/Result/Render/CsvResultsRenderer.php @@ -17,12 +17,13 @@ final class CsvResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $output->writeln($this->getHeader()); foreach ($results as $result) { - $output->writeln(\implode(';', ['"' . $result[0] . '"', $result[1], $result[2], $result[3]])); + $output->writeln(\implode(';', ['"' . \strval($result[0]) . '"', $result[1], $result[2], $result[3]])); } } diff --git a/src/Result/Render/JsonResultsRenderer.php b/src/Result/Render/JsonResultsRenderer.php index d40c8f3d..cb21f34f 100644 --- a/src/Result/Render/JsonResultsRenderer.php +++ b/src/Result/Render/JsonResultsRenderer.php @@ -17,6 +17,7 @@ final class JsonResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $data = []; diff --git a/src/Result/Render/MarkdownResultsRenderer.php b/src/Result/Render/MarkdownResultsRenderer.php index a61158aa..ee4a9821 100644 --- a/src/Result/Render/MarkdownResultsRenderer.php +++ b/src/Result/Render/MarkdownResultsRenderer.php @@ -17,6 +17,7 @@ final class MarkdownResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $output->writeln('| File | Times Changed | Complexity | Score |'); diff --git a/src/Result/Result.php b/src/Result/Result.php index 78abb38d..5c8912d3 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -46,6 +46,7 @@ public function __construct(File $file) /** * Return the file. */ + #[\Override] public function getFile(): File { return $this->file; @@ -72,6 +73,7 @@ public function setCommits(int $commits): self /** * Get the number of changes. */ + #[\Override] public function getCommits(): int { return $this->commits; @@ -90,6 +92,7 @@ public function setComplexity(int $complexity): self /** * Get the file complexity. */ + #[\Override] public function getComplexity(): int { return $this->complexity; @@ -98,6 +101,7 @@ public function getComplexity(): int /** * Get the file priority. */ + #[\Override] public function getPriority(): int { return $this->commits * $this->complexity; @@ -110,6 +114,7 @@ public function getPriority(): int * @param integer $maxComplexity The maximum complexity out of any file scanned. * @codingStandardsIgnoreStart */ + #[\Override] public function getScore(int $maxCommits, int $maxComplexity): float { Assert::greaterThan($maxComplexity, 0); @@ -126,16 +131,16 @@ public function getScore(int $maxCommits, int $maxComplexity): float * Normalize these values over time, we first divide by the maximum * values, to always end up with distances between 0 and 1. */ - $normalizedHorizontalDistance = $horizontalDistance / $maxCommits; - $normalizedVerticalDistance = $verticalDistance / $maxComplexity; + $normalizedHorizontalDistance = \floatval($horizontalDistance / $maxCommits); + $normalizedVerticalDistance = \floatval($verticalDistance / $maxComplexity); /* * Calculate the distance of this class from the "top right" corner, * using the simple formula A^2 + B^2 = C^2; or: C = sqrt(A^2 + B^2)). */ $distanceFromTopRightCorner = \sqrt( - $normalizedHorizontalDistance ** 2 - + $normalizedVerticalDistance ** 2 + $normalizedHorizontalDistance ** 2.0 + + $normalizedVerticalDistance ** 2.0 ); /* @@ -143,7 +148,7 @@ public function getScore(int $maxCommits, int $maxComplexity): float * so in order to end up with a high score, we invert the value by * subtracting it from 1. */ - return \round(1 - $distanceFromTopRightCorner, 3); + return \round(1.0 - $distanceFromTopRightCorner, 3); // @codingStandardsIgnoreEnd } } diff --git a/src/Result/ResultAccumulator.php b/src/Result/ResultAccumulator.php index af7eca2e..d8828de0 100644 --- a/src/Result/ResultAccumulator.php +++ b/src/Result/ResultAccumulator.php @@ -54,6 +54,7 @@ public function __construct(int $maxSize, ?float $minScore) /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { if (!($event instanceof AfterFileAnalysisEventWithResult)) { @@ -88,6 +89,7 @@ public function add(ResultInterface $result): void /** * Returns the maximum number of changes for a file. */ + #[\Override] public function getMaxCommits(): int { return $this->maxCommits; @@ -96,6 +98,7 @@ public function getMaxCommits(): int /** * Returns the maximum complexity for a file. */ + #[\Override] public function getMaxComplexity(): int { return $this->maxComplexity; @@ -104,6 +107,7 @@ public function getMaxComplexity(): int /** * Returns the number of files processed. */ + #[\Override] public function getNumberOfFiles(): int { return $this->numberOfFiles; @@ -112,6 +116,7 @@ public function getNumberOfFiles(): int /** * Returns the highest score. */ + #[\Override] public function getMaxScore(): ?float { $result = $this->highestScores->toArray()[0] ?? null; diff --git a/tests/EndToEnd/FossilTest.php b/tests/EndToEnd/FossilTest.php index 80c7bf81..54eef6d0 100644 --- a/tests/EndToEnd/FossilTest.php +++ b/tests/EndToEnd/FossilTest.php @@ -17,6 +17,7 @@ final class FossilTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/EndToEnd/MercurialTest.php b/tests/EndToEnd/MercurialTest.php index 8cfd2005..9c871b3c 100644 --- a/tests/EndToEnd/MercurialTest.php +++ b/tests/EndToEnd/MercurialTest.php @@ -17,6 +17,7 @@ final class MercurialTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/EndToEnd/SubversionTest.php b/tests/EndToEnd/SubversionTest.php index 746b610c..490e6b0c 100644 --- a/tests/EndToEnd/SubversionTest.php +++ b/tests/EndToEnd/SubversionTest.php @@ -17,6 +17,7 @@ final class SubversionTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/Command/AssessComplexityCommandTest.php b/tests/Integration/Command/AssessComplexityCommandTest.php index 48393413..c33506e6 100644 --- a/tests/Integration/Command/AssessComplexityCommandTest.php +++ b/tests/Integration/Command/AssessComplexityCommandTest.php @@ -17,6 +17,7 @@ final class AssessComplexityCommandTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/Command/Assets/PrintHook.php b/tests/Integration/Command/Assets/PrintHook.php index e11048bd..e58a5500 100644 --- a/tests/Integration/Command/Assets/PrintHook.php +++ b/tests/Integration/Command/Assets/PrintHook.php @@ -15,6 +15,7 @@ class PrintHook implements AfterAnalysisHook, BeforeAnalysisHook /** * @param AfterAnalysis $event The event triggered when the analysis is done. */ + #[\Override] public static function afterAnalysis(AfterAnalysis $event): void { echo "DONE"; @@ -23,6 +24,7 @@ public static function afterAnalysis(AfterAnalysis $event): void /** * @param BeforeAnalysis $event The event triggered when the analysis starts. */ + #[\Override] public static function beforeAnalysis(BeforeAnalysis $event): void { echo "Churn: "; diff --git a/tests/Integration/Command/Assets/TestHook.php b/tests/Integration/Command/Assets/TestHook.php index ba4efaa4..033499bc 100644 --- a/tests/Integration/Command/Assets/TestHook.php +++ b/tests/Integration/Command/Assets/TestHook.php @@ -31,6 +31,7 @@ public static function reset(): void /** * @param AfterAnalysis $event The event triggered when the analysis is done. */ + #[\Override] public static function afterAnalysis(AfterAnalysis $event): void { self::$nbAfterAnalysisEvent++; @@ -39,6 +40,7 @@ public static function afterAnalysis(AfterAnalysis $event): void /** * @param AfterFileAnalysis $event The event triggered when the analysis of a file is done. */ + #[\Override] public static function afterFileAnalysis(AfterFileAnalysis $event): void { self::$nbAfterFileAnalysisEvent++; @@ -47,6 +49,7 @@ public static function afterFileAnalysis(AfterFileAnalysis $event): void /** * @param BeforeAnalysis $event The event triggered when the analysis starts. */ + #[\Override] public static function beforeAnalysis(BeforeAnalysis $event): void { self::$nbBeforeAnalysisEvent++; diff --git a/tests/Integration/Command/RunCommandTest.php b/tests/Integration/Command/RunCommandTest.php index 1ba0043b..3ae94a52 100644 --- a/tests/Integration/Command/RunCommandTest.php +++ b/tests/Integration/Command/RunCommandTest.php @@ -29,6 +29,7 @@ final class RunCommandTest extends BaseTestCase private $tmpFile; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -40,6 +41,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/File/FileFinderTest.php b/tests/Integration/File/FileFinderTest.php index 069f8c27..413491af 100644 --- a/tests/Integration/File/FileFinderTest.php +++ b/tests/Integration/File/FileFinderTest.php @@ -16,6 +16,7 @@ final class FileFinderTest extends BaseTestCase private $fileFinder; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Integration/ManifestTest.php b/tests/Integration/ManifestTest.php index 0fb17e5f..45a4908a 100644 --- a/tests/Integration/ManifestTest.php +++ b/tests/Integration/ManifestTest.php @@ -17,6 +17,7 @@ final class ManifestTest extends BaseTestCase private $manifest; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Configuration/Validator/CachePathTest.php b/tests/Unit/Configuration/Validator/CachePathTest.php index b1b94b87..ab729dfa 100644 --- a/tests/Unit/Configuration/Validator/CachePathTest.php +++ b/tests/Unit/Configuration/Validator/CachePathTest.php @@ -12,6 +12,7 @@ final class CachePathTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new CachePath(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getCachePath(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return null; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'CachePath' => ['/tmp/.churn.cache']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'CachePath / int' => [123, 'Cache path should be a string']; diff --git a/tests/Unit/Configuration/Validator/CommitsSinceTest.php b/tests/Unit/Configuration/Validator/CommitsSinceTest.php index ee263fef..1afcc0a7 100644 --- a/tests/Unit/Configuration/Validator/CommitsSinceTest.php +++ b/tests/Unit/Configuration/Validator/CommitsSinceTest.php @@ -16,6 +16,7 @@ final class CommitsSinceTest extends ValidatorBaseTestCase private $validator; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); @@ -24,6 +25,7 @@ public function setUp() } /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return $this->validator; @@ -33,24 +35,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getCommitsSince(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return '10 years ago'; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'CommitsSince' => ['4 years ago']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'CommitsSince / int' => [123, 'Commits since should be a string']; diff --git a/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php b/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php index 0f7d40b8..e45c7f08 100644 --- a/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php +++ b/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php @@ -11,6 +11,7 @@ final class DirectoriesToScanTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new DirectoriesToScan(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getDirectoriesToScan(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'DirectoriesToScan' => [['src', 'tests']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'DirectoriesToScan / string' => ['foo', 'Directories to scan should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FileExtensionsTest.php b/tests/Unit/Configuration/Validator/FileExtensionsTest.php index 5b32c74f..3aab3a55 100644 --- a/tests/Unit/Configuration/Validator/FileExtensionsTest.php +++ b/tests/Unit/Configuration/Validator/FileExtensionsTest.php @@ -11,6 +11,7 @@ final class FileExtensionsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FileExtensions(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFileExtensions(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return ['php']; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FileExtensions' => [['php', 'inc']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FileExtensions / string' => ['foo', 'File extensions should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php b/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php index bedb4b23..7af0f085 100644 --- a/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php +++ b/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php @@ -11,6 +11,7 @@ final class FilesToIgnoreTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FilesToIgnore(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFilesToIgnore(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FilesToIgnore' => [['foo.php', 'bar.php', 'baz.php']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FilesToIgnore / string' => ['foo', 'Files to ignore should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FilesToShowTest.php b/tests/Unit/Configuration/Validator/FilesToShowTest.php index 196b7a0f..2bc9631b 100644 --- a/tests/Unit/Configuration/Validator/FilesToShowTest.php +++ b/tests/Unit/Configuration/Validator/FilesToShowTest.php @@ -11,6 +11,7 @@ final class FilesToShowTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FilesToShow(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFilesToShow(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 10; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FilesToShow' => [13]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FilesToShow / string' => ['foo', 'Files to show should be an integer']; diff --git a/tests/Unit/Configuration/Validator/HooksTest.php b/tests/Unit/Configuration/Validator/HooksTest.php index 0f183749..80e8ba47 100644 --- a/tests/Unit/Configuration/Validator/HooksTest.php +++ b/tests/Unit/Configuration/Validator/HooksTest.php @@ -11,6 +11,7 @@ final class HooksTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new Hooks(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getHooks(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'Hook' => [['Hook1', 'Hook2']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'Hooks / string' => ['foo', 'Hooks should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php b/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php index 4413969c..68f766ca 100644 --- a/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php +++ b/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php @@ -12,6 +12,7 @@ final class MaxScoreThresholdTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new MaxScoreThreshold(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getMaxScoreThreshold(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return null; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'MaxScoreThreshold' => [9.5]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'MaxScoreThreshold / string' => ['foo', 'Maximum score threshold should be a number']; diff --git a/tests/Unit/Configuration/Validator/MinScoreToShowTest.php b/tests/Unit/Configuration/Validator/MinScoreToShowTest.php index 90d8fe4a..e3dd3f3f 100644 --- a/tests/Unit/Configuration/Validator/MinScoreToShowTest.php +++ b/tests/Unit/Configuration/Validator/MinScoreToShowTest.php @@ -12,6 +12,7 @@ final class MinScoreToShowTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new MinScoreToShow(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getMinScoreToShow(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 0.1; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'MinScoreToShow' => [5.0]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'MinScoreToShow / string' => ['foo', 'Minimum score to show should be a number']; diff --git a/tests/Unit/Configuration/Validator/ParallelJobsTest.php b/tests/Unit/Configuration/Validator/ParallelJobsTest.php index 8d63ec4e..fafe9ec8 100644 --- a/tests/Unit/Configuration/Validator/ParallelJobsTest.php +++ b/tests/Unit/Configuration/Validator/ParallelJobsTest.php @@ -11,6 +11,7 @@ final class ParallelJobsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new ParallelJobs(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getParallelJobs(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 10; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'ParallelJobs' => [7]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'ParallelJobs / string' => ['foo', 'Amount of parallel jobs should be an integer']; diff --git a/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php b/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php index f07e8bbd..fb933096 100644 --- a/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php +++ b/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php @@ -44,6 +44,7 @@ abstract public static function provideValidValues(): iterable; abstract public static function provideInvalidValues(): iterable; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Configuration/Validator/VcsTest.php b/tests/Unit/Configuration/Validator/VcsTest.php index 198a9c74..157edc78 100644 --- a/tests/Unit/Configuration/Validator/VcsTest.php +++ b/tests/Unit/Configuration/Validator/VcsTest.php @@ -11,6 +11,7 @@ final class VcsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new Vcs(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getVCS(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 'git'; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'Vcs' => ['none']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'Vcs / int' => [123, 'VCS should be a string']; diff --git a/tests/Unit/File/FileFinderTest.php b/tests/Unit/File/FileFinderTest.php index a3f9f751..596b543a 100644 --- a/tests/Unit/File/FileFinderTest.php +++ b/tests/Unit/File/FileFinderTest.php @@ -17,6 +17,7 @@ final class FileFinderTest extends BaseTestCase protected $fileFinder; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/File/FileHelperTest.php b/tests/Unit/File/FileHelperTest.php index 09f3c6fa..53c782cb 100644 --- a/tests/Unit/File/FileHelperTest.php +++ b/tests/Unit/File/FileHelperTest.php @@ -17,6 +17,7 @@ final class FileHelperTest extends BaseTestCase private static $filesToDelete = []; /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Unit/File/FileTest.php b/tests/Unit/File/FileTest.php index d8e2a2bf..2a6d863f 100644 --- a/tests/Unit/File/FileTest.php +++ b/tests/Unit/File/FileTest.php @@ -15,6 +15,7 @@ final class FileTest extends BaseTestCase private $file; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php b/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php index 29bb5359..5256eec2 100644 --- a/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php +++ b/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php @@ -16,6 +16,7 @@ final class NoVcsChangesCountProcessTest extends BaseTestCase private $process; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); diff --git a/tests/Unit/Process/ConcreteProcessFactoryTest.php b/tests/Unit/Process/ConcreteProcessFactoryTest.php index 36475027..2c224acc 100644 --- a/tests/Unit/Process/ConcreteProcessFactoryTest.php +++ b/tests/Unit/Process/ConcreteProcessFactoryTest.php @@ -21,6 +21,7 @@ final class ConcreteProcessFactoryTest extends BaseTestCase private $processFactory; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Result/ResultTest.php b/tests/Unit/Result/ResultTest.php index 6664bcd6..1c0d4d4f 100644 --- a/tests/Unit/Result/ResultTest.php +++ b/tests/Unit/Result/ResultTest.php @@ -19,6 +19,7 @@ final class ResultTest extends BaseTestCase protected $result; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Result/ResultsRendererFactoryTest.php b/tests/Unit/Result/ResultsRendererFactoryTest.php index 11163e25..1af30ac9 100644 --- a/tests/Unit/Result/ResultsRendererFactoryTest.php +++ b/tests/Unit/Result/ResultsRendererFactoryTest.php @@ -20,6 +20,7 @@ final class ResultsRendererFactoryTest extends BaseTestCase private $factory; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json index f6ddacdd..ff6a2408 100644 --- a/vendor-bin/psalm/composer.json +++ b/vendor-bin/psalm/composer.json @@ -1,9 +1,9 @@ { "require-dev": { "psalm/plugin-mockery": "^0.10.0 || ^1.0", - "psalm/plugin-phpunit": "^0.18.3", + "psalm/plugin-phpunit": ">=0.18.3", "psalm/plugin-symfony": "^2.1 || ^3.0 || ^4.0 || ^5.0", - "vimeo/psalm": "^4.6 || ^5.0" + "vimeo/psalm": "^4.6 || ^5.0 || ^6.0" }, "config": { "allow-plugins": {