diff --git a/.gitattributes b/.gitattributes index 5cc7e3e5..f4ce6cfb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,18 @@ +* text=auto eol=lf + +*.conf text eol=lf +*.html text eol=lf +*.ico binary +*.ini text eol=lf +*.js text eol=lf +*.json text eol=lf +*.md text eol=lf +*.php text eol=lf +*.png binary +*.sh text eol=lf +*.yaml text eol=lf +*.yml text eol=lf + /.github export-ignore /docs export-ignore /tools export-ignore diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a72c5f8c..74a4270e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -7,27 +7,10 @@ $config = new PhpCsFixer\Config(); return $config->setRules([ // Rule sets + '@PER-CS2.0' => true, '@PHP80Migration:risky' => true, '@PHP81Migration' => true, - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHPUnit84Migration:risky' => true, - - // PHPUnit Rules - 'php_unit_internal_class' => ['types' => ['normal', 'final']], - 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'], - 'php_unit_test_class_requires_covers' => true, - - // Rules - 'align_multiline_comment' => true, - 'phpdoc_line_span' => true, - 'phpdoc_order_by_value' => ['annotations' => ['covers', 'throws']], - 'phpdoc_order' => true, - 'phpdoc_tag_casing' => true, - 'array_indentation' => true, - 'explicit_indirect_variable' => true, - 'binary_operator_spaces' => ['default' => 'align_single_space'], - 'phpdoc_to_comment' => false, + '@PHPUnit100Migration:risky' => true, ]) ->setFinder($finder) ; diff --git a/packages/bard/src/Console/Command/AbstractCommand.php b/packages/bard/src/Console/Command/AbstractCommand.php index ed09213a..f913a2f1 100644 --- a/packages/bard/src/Console/Command/AbstractCommand.php +++ b/packages/bard/src/Console/Command/AbstractCommand.php @@ -9,6 +9,4 @@ /** * @author Joshua Estes */ -abstract class AbstractCommand extends Command -{ -} +abstract class AbstractCommand extends Command {} diff --git a/packages/bard/src/Console/Command/InitCommand.php b/packages/bard/src/Console/Command/InitCommand.php index cd783c29..6ea7ffd3 100644 --- a/packages/bard/src/Console/Command/InitCommand.php +++ b/packages/bard/src/Console/Command/InitCommand.php @@ -17,17 +17,11 @@ final class InitCommand extends AbstractCommand { protected static $defaultName = 'init'; - /** - * {@inheritDoc} - */ // public function __construct() // { // parent::__construct(); // } - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -35,19 +29,11 @@ protected function configure(): void ; } - /** - * {@inheritDoc} - */ - protected function initialize(InputInterface $input, OutputInterface $output): void - { - } + protected function initialize(InputInterface $input, OutputInterface $output): void {} - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { - $filename = $input->getOption('working-dir').'/bard.json'; + $filename = $input->getOption('working-dir') . '/bard.json'; if (file_exists($filename)) { $output->writeln('bard.json file already exists'); diff --git a/packages/bard/src/Console/Command/InstallCommand.php b/packages/bard/src/Console/Command/InstallCommand.php index 4b953bfb..01c75a1c 100644 --- a/packages/bard/src/Console/Command/InstallCommand.php +++ b/packages/bard/src/Console/Command/InstallCommand.php @@ -16,17 +16,11 @@ final class InstallCommand extends AbstractCommand { protected static $defaultName = 'install'; - /** - * {@inheritDoc} - */ // public function __construct() // { // parent::__construct(); // } - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -34,19 +28,11 @@ protected function configure(): void ; } - /** - * {@inheritDoc} - */ - protected function initialize(InputInterface $input, OutputInterface $output): void - { - } + protected function initialize(InputInterface $input, OutputInterface $output): void {} - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { - $bardJsonFile = new JsonFile($input->getOption('working-dir').'/bard.json'); + $bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json'); foreach ($bardJsonFile->getSection('packages') as $pkg) { $process = new Process([ 'composer', diff --git a/packages/bard/src/Console/Command/MergeCommand.php b/packages/bard/src/Console/Command/MergeCommand.php index 08d1ebcb..77de3595 100644 --- a/packages/bard/src/Console/Command/MergeCommand.php +++ b/packages/bard/src/Console/Command/MergeCommand.php @@ -39,9 +39,6 @@ public function __construct() parent::__construct(); } - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -50,12 +47,9 @@ protected function configure(): void ; } - /** - * {@inheritDoc} - */ protected function initialize(InputInterface $input, OutputInterface $output): void { - $bardConfigFile = $input->getOption('working-dir').'/bard.json'; + $bardConfigFile = $input->getOption('working-dir') . '/bard.json'; if (!file_exists($bardConfigFile)) { throw new \RuntimeException(sprintf('"%s" file does not exist', $bardConfigFile)); } @@ -64,33 +58,30 @@ protected function initialize(InputInterface $input, OutputInterface $output): v ->objectAsArray() ->decode(file_get_contents($bardConfigFile)); - $this->mainComposerFile = $input->getOption('working-dir').'/composer.json'; + $this->mainComposerFile = $input->getOption('working-dir') . '/composer.json'; if (!file_exists($this->mainComposerFile)) { throw new \RuntimeException(sprintf('"%s" file does not exist', $this->mainComposerFile)); } } - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->formatter = $this->getHelper('formatter'); - $rootComposerJsonFile = new JsonFile($input->getOption('working-dir').'/composer.json'); + $rootComposerJsonFile = new JsonFile($input->getOption('working-dir') . '/composer.json'); // Clean out a few of the sections in root composer.json file $rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload', []); $rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload-dev', []); foreach ($this->bardConfig['packages'] as $pkg) { - $packageComposerFile = realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json'); + $packageComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'); if (!file_exists($packageComposerFile)) { $output->writeln(sprintf('No "%s" found, skipping', $packageComposerFile)); continue; } - $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json')); + $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json')); $output->writeln($this->formatter->formatSection('bard', sprintf('Merging "%s" into root composer.json', $pkgComposerJsonFile->getSection('name')))); diff --git a/packages/bard/src/Console/Command/PublishCommand.php b/packages/bard/src/Console/Command/PublishCommand.php index 1daf869e..40ae5f0b 100644 --- a/packages/bard/src/Console/Command/PublishCommand.php +++ b/packages/bard/src/Console/Command/PublishCommand.php @@ -22,9 +22,6 @@ final class PublishCommand extends AbstractCommand { protected static $defaultName = 'publish'; - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -33,17 +30,14 @@ protected function configure(): void ; } - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { - $bardConfig = new JsonFile($input->getOption('working-dir').'/bard.json'); + $bardConfig = new JsonFile($input->getOption('working-dir') . '/bard.json'); $formatter = $this->getHelper('formatter'); $io = new SymfonyStyle($input, $output); foreach ($bardConfig->getSection('packages') as $pkg) { - $pkgComposerFile = realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json'); + $pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'); $pkgComposerJsonFile = new JsonFile($pkgComposerFile); $pkgName = $pkgComposerJsonFile->getSection('name'); $io->text(sprintf('Pushing %s', $pkgName)); diff --git a/packages/bard/src/Console/Command/ReleaseCommand.php b/packages/bard/src/Console/Command/ReleaseCommand.php index 2f486244..be61d39d 100644 --- a/packages/bard/src/Console/Command/ReleaseCommand.php +++ b/packages/bard/src/Console/Command/ReleaseCommand.php @@ -28,17 +28,11 @@ final class ReleaseCommand extends AbstractCommand private $releaseVersion; private bool $isDryRun = true; - /** - * {@inheritDoc} - */ // public function __construct() // { // parent::__construct(); // } - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -60,9 +54,6 @@ protected function configure(): void ); } - /** - * {@inheritDoc} - */ protected function initialize(InputInterface $input, OutputInterface $output): void { $version = $input->getArgument('release'); @@ -70,7 +61,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v return; } - $this->bardConfig = new JsonFile($input->getOption('working-dir').'/bard.json'); + $this->bardConfig = new JsonFile($input->getOption('working-dir') . '/bard.json'); $currentVersion = new Version($this->bardConfig->getSection('version')); if (\in_array($version, ['major', 'minor', 'patch'])) { @@ -96,16 +87,8 @@ protected function initialize(InputInterface $input, OutputInterface $output): v $this->isDryRun = $input->getOption('dry-run'); } - /** - * {@inheritDoc} - */ - protected function interact(InputInterface $input, OutputInterface $output): void - { - } + protected function interact(InputInterface $input, OutputInterface $output): void {} - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $formatter = $this->getHelper('formatter'); @@ -124,13 +107,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->getHelper('process')->mustRun($output, $process, sprintf('There was and error running command: %s', $process->getCommandLine())); } - $rootComposerJsonFile = new JsonFile($input->getOption('working-dir').'/composer.json'); + $rootComposerJsonFile = new JsonFile($input->getOption('working-dir') . '/composer.json'); // 1. Update "replace" in main composer.json with the Package Names // "package/name": "self.version" $io->section('updating root composer.json "replace" section with package information'); foreach ($this->bardConfig->getSection('packages') as $pkg) { - $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json')); + $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json')); $output->writeln([ $formatter->formatSection($pkgComposerJsonFile->getSection('name'), 'Updating root composer.json'), ]); @@ -160,8 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int ['git', 'add', '.'], ['git', 'commit', '--allow-empty', '-m', sprintf('"Preparing for Release v%s"', $this->releaseVersion->toString())], ['git', 'push', 'origin', $input->getOption('branch')], - ['git', 'tag', 'v'.$this->releaseVersion->toString()], - ['git', 'push', 'origin', 'v'.$this->releaseVersion->toString()], + ['git', 'tag', 'v' . $this->releaseVersion->toString()], + ['git', 'push', 'origin', 'v' . $this->releaseVersion->toString()], ]; foreach ($processCommands as $cmd) { $process = new Process($cmd); @@ -176,7 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->newLine(); $io->title(sprintf('updating package repos with release %s', $this->releaseVersion->toString())); foreach ($this->bardConfig->getSection('packages') as $pkg) { - $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json')); + $pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json')); $pkgName = $pkgComposerJsonFile->getSection('name'); $io->text(sprintf('Package %s is being released', $pkgName)); $processCommands = [ diff --git a/packages/bard/src/Console/Command/UpdateCommand.php b/packages/bard/src/Console/Command/UpdateCommand.php index 3cba8cd8..4ebee170 100644 --- a/packages/bard/src/Console/Command/UpdateCommand.php +++ b/packages/bard/src/Console/Command/UpdateCommand.php @@ -16,17 +16,11 @@ final class UpdateCommand extends AbstractCommand { protected static $defaultName = 'update'; - /** - * {@inheritDoc} - */ // public function __construct() // { // parent::__construct(); // } - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -34,19 +28,11 @@ protected function configure(): void ; } - /** - * {@inheritDoc} - */ - protected function initialize(InputInterface $input, OutputInterface $output): void - { - } + protected function initialize(InputInterface $input, OutputInterface $output): void {} - /** - * {@inheritDoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { - $bardJsonFile = new JsonFile($input->getOption('working-dir').'/bard.json'); + $bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json'); foreach ($bardJsonFile->getSection('packages') as $pkg) { $process = new Process([ 'composer', diff --git a/packages/bard/src/Worker/File/Bard/UpdateVersion.php b/packages/bard/src/Worker/File/Bard/UpdateVersion.php index 761f567d..529967db 100644 --- a/packages/bard/src/Worker/File/Bard/UpdateVersion.php +++ b/packages/bard/src/Worker/File/Bard/UpdateVersion.php @@ -20,9 +20,6 @@ public function __construct(VersionInterface $version) $this->version = $version; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $bardJsonFile): JsonFile { return $bardJsonFile->setSection('version', $this->version->toString()); diff --git a/packages/bard/src/Worker/File/Composer/Package/Authors.php b/packages/bard/src/Worker/File/Composer/Package/Authors.php index b396c3a6..2619d35c 100644 --- a/packages/bard/src/Worker/File/Composer/Package/Authors.php +++ b/packages/bard/src/Worker/File/Composer/Package/Authors.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile) $this->rootComposerJsonFile = $rootComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $pkgComposerJsonFile): JsonFile { $rootSection = $this->rootComposerJsonFile->getSection('authors'); diff --git a/packages/bard/src/Worker/File/Composer/Package/BranchAlias.php b/packages/bard/src/Worker/File/Composer/Package/BranchAlias.php index 895dea01..f9f8d24f 100644 --- a/packages/bard/src/Worker/File/Composer/Package/BranchAlias.php +++ b/packages/bard/src/Worker/File/Composer/Package/BranchAlias.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile) $this->rootComposerJsonFile = $rootComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $pkgComposerJsonFile): JsonFile { $rootExtraSection = $this->rootComposerJsonFile->getSection('extra'); diff --git a/packages/bard/src/Worker/File/Composer/Package/Funding.php b/packages/bard/src/Worker/File/Composer/Package/Funding.php index e136a628..fb5c8c3e 100644 --- a/packages/bard/src/Worker/File/Composer/Package/Funding.php +++ b/packages/bard/src/Worker/File/Composer/Package/Funding.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile) $this->rootComposerJsonFile = $rootComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $pkgComposerJsonFile): JsonFile { $rootSection = $this->rootComposerJsonFile->getSection('funding'); diff --git a/packages/bard/src/Worker/File/Composer/Package/Support.php b/packages/bard/src/Worker/File/Composer/Package/Support.php index 601dceda..31b9714d 100644 --- a/packages/bard/src/Worker/File/Composer/Package/Support.php +++ b/packages/bard/src/Worker/File/Composer/Package/Support.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile) $this->rootComposerJsonFile = $rootComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $pkgComposerJsonFile): JsonFile { $rootSupportSection = $this->rootComposerJsonFile->getSection('support'); diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php index 174c9a7b..3b805ec8 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $rootDir = pathinfo($rootComposerJsonFile->getFilename(), \PATHINFO_DIRNAME); @@ -38,13 +35,13 @@ public function apply(JsonFile $rootComposerJsonFile): JsonFile foreach ($pkgAutoloadSection as $section => $config) { if ('psr-4' === $section) { foreach ($config as $namespace => $pkgPath) { - $rootAutoloadSection['psr-4'][$namespace] = trim($path.'/'.trim($pkgPath, '/'), '/'); + $rootAutoloadSection['psr-4'][$namespace] = trim($path . '/' . trim($pkgPath, '/'), '/'); } } if ('exclude-from-classmap' === $section) { foreach ($config as $pkgPath) { - $rootAutoloadSection['exclude-from-classmap'][] = trim($path.'/'.trim($pkgPath, '/'), '/'); + $rootAutoloadSection['exclude-from-classmap'][] = trim($path . '/' . trim($pkgPath, '/'), '/'); } } } diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php index 64abccb6..7a445bcf 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $rootDir = pathinfo($rootComposerJsonFile->getFilename(), \PATHINFO_DIRNAME); @@ -37,7 +34,7 @@ public function apply(JsonFile $rootComposerJsonFile): JsonFile $rootAutoloadSection['psr-4'] = []; } foreach ($config as $namespace => $pkgPath) { - $rootAutoloadSection['psr-4'][$namespace] = trim($path.'/'.trim($pkgPath, '/'), '/'); + $rootAutoloadSection['psr-4'][$namespace] = trim($path . '/' . trim($pkgPath, '/'), '/'); } } @@ -46,7 +43,7 @@ public function apply(JsonFile $rootComposerJsonFile): JsonFile $rootAutoloadSection['exclude-from-classmap'] = []; } foreach ($config as $pkgPath) { - $rootAutoloadSection['exclude-from-classmap'][] = trim($path.'/'.trim($pkgPath, '/'), '/'); + $rootAutoloadSection['exclude-from-classmap'][] = trim($path . '/' . trim($pkgPath, '/'), '/'); } } } diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateProvideSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateProvideSection.php index d1364deb..49cbce48 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateProvideSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateProvideSection.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $pkgProvideSection = $this->pkgComposerJsonFile->getSection('provide'); diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php index 5d2980e5..95c2f83f 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php @@ -19,9 +19,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $rootReplace = $rootComposerJsonFile->getSection('replace'); diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php index b94787c4..3b3976fe 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php @@ -22,9 +22,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $rootRequireDev = $rootComposerJsonFile->getSection('require-dev'); diff --git a/packages/bard/src/Worker/File/Composer/Root/UpdateRequireSection.php b/packages/bard/src/Worker/File/Composer/Root/UpdateRequireSection.php index b2049989..2db4dea0 100644 --- a/packages/bard/src/Worker/File/Composer/Root/UpdateRequireSection.php +++ b/packages/bard/src/Worker/File/Composer/Root/UpdateRequireSection.php @@ -22,9 +22,6 @@ public function __construct(JsonFile $pkgComposerJsonFile) $this->pkgComposerJsonFile = $pkgComposerJsonFile; } - /** - * {@inheritDoc} - */ public function apply(JsonFile $rootComposerJsonFile): JsonFile { $rootReplace = $rootComposerJsonFile->getSection('replace'); diff --git a/packages/clock/ClockInterface.php b/packages/clock/ClockInterface.php index 7652d5ec..6b2f0843 100644 --- a/packages/clock/ClockInterface.php +++ b/packages/clock/ClockInterface.php @@ -16,5 +16,5 @@ interface ClockInterface /** * Returns a DateTimeInterface. */ - public function now(): DateTimeInterface; + public function now(): \DateTimeInterface; } diff --git a/packages/clock/Date.php b/packages/clock/Date.php index b3e6bca7..c1db53d3 100644 --- a/packages/clock/Date.php +++ b/packages/clock/Date.php @@ -28,33 +28,21 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return sprintf('%d-%02d-%02d', $this->year, $this->month, $this->day); } - /** - * {@inheritDoc} - */ public function getYear(): int { return $this->year; } - /** - * {@inheritDoc} - */ public function getMonth(): int { return $this->month; } - /** - * {@inheritDoc} - */ public function getDay(): int { return $this->day; diff --git a/packages/clock/DateTime.php b/packages/clock/DateTime.php index d8f568f8..c1d5f7be 100644 --- a/packages/clock/DateTime.php +++ b/packages/clock/DateTime.php @@ -28,9 +28,6 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return sprintf( @@ -41,25 +38,16 @@ public function toString(): string ); } - /** - * {@inheritDoc} - */ public function getDate(): DateInterface { return $this->date; } - /** - * {@inheritDoc} - */ public function getTime(): TimeInterface { return $this->time; } - /** - * {@inheritDoc} - */ public function getZone(): ZoneInterface { return $this->zone; diff --git a/packages/clock/DurationInterface.php b/packages/clock/DurationInterface.php index 97a3c867..6b3974ad 100644 --- a/packages/clock/DurationInterface.php +++ b/packages/clock/DurationInterface.php @@ -11,6 +11,4 @@ * * @author Joshua Estes */ -interface DurationInterface -{ -} +interface DurationInterface {} diff --git a/packages/clock/Exception/ClockException.php b/packages/clock/Exception/ClockException.php index 8e593cef..e1ddf07b 100644 --- a/packages/clock/Exception/ClockException.php +++ b/packages/clock/Exception/ClockException.php @@ -13,6 +13,4 @@ * * @author Joshua Estes */ -class ClockException extends Exception -{ -} +class ClockException extends \Exception {} diff --git a/packages/clock/FixedClock.php b/packages/clock/FixedClock.php index 9dcf9d6f..c5332d06 100644 --- a/packages/clock/FixedClock.php +++ b/packages/clock/FixedClock.php @@ -4,9 +4,6 @@ namespace SonsOfPHP\Component\Clock; -use DateTimeImmutable; -use DateTimeInterface; -use DateTimeZone; use SonsOfPHP\Component\Clock\Exception\ClockException; /** @@ -19,32 +16,26 @@ */ final class FixedClock implements ClockInterface { - private DateTimeZone $zone; - private DateTimeInterface $time; + private \DateTimeZone $zone; + private \DateTimeInterface $time; - /** - * @param DateTimeZone $zone - */ - public function __construct(?DateTimeZone $zone = null) + public function __construct(\DateTimeZone $zone = null) { - $this->zone = $zone ?? new DateTimeZone('UTC'); + $this->zone = $zone ?? new \DateTimeZone('UTC'); $this->tick(); } public function __toString(): string { - return 'FixedClock['.$this->zone->getName().']'; + return 'FixedClock[' . $this->zone->getName() . ']'; } - /** - * {@inheritDoc} - */ - public function now(): DateTimeInterface + public function now(): \DateTimeInterface { return $this->time; } - public function getZone(): DateTimeZone + public function getZone(): \DateTimeZone { return $this->zone; } @@ -54,7 +45,7 @@ public function getZone(): DateTimeZone */ public function tick(): void { - $this->time = new DateTimeImmutable('now', $this->zone); + $this->time = new \DateTimeImmutable('now', $this->zone); } /** @@ -70,7 +61,7 @@ public function tick(): void */ public function tickTo(string $input): void { - $time = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $input, $this->zone); + $time = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $input, $this->zone); if (false === $time) { throw new ClockException(sprintf('The input "%s" is invalid', $input)); } diff --git a/packages/clock/IntervalInterface.php b/packages/clock/IntervalInterface.php index 6e314129..cec36cdc 100644 --- a/packages/clock/IntervalInterface.php +++ b/packages/clock/IntervalInterface.php @@ -12,6 +12,4 @@ * * @author Joshua Estes */ -interface IntervalInterface -{ -} +interface IntervalInterface {} diff --git a/packages/clock/RepeatingIntervalInterface.php b/packages/clock/RepeatingIntervalInterface.php index 37520b90..a9e0b3b9 100644 --- a/packages/clock/RepeatingIntervalInterface.php +++ b/packages/clock/RepeatingIntervalInterface.php @@ -10,6 +10,4 @@ * * @author Joshua Estes */ -interface RepeatingIntervalInterface -{ -} +interface RepeatingIntervalInterface {} diff --git a/packages/clock/SystemClock.php b/packages/clock/SystemClock.php index b19cb435..8f39363a 100644 --- a/packages/clock/SystemClock.php +++ b/packages/clock/SystemClock.php @@ -4,10 +4,6 @@ namespace SonsOfPHP\Component\Clock; -use DateTimeImmutable; -use DateTimeInterface; -use DateTimeZone; - /** * System Clock. * @@ -15,27 +11,24 @@ */ class SystemClock implements ClockInterface { - private DateTimeZone $zone; + private \DateTimeZone $zone; - public function __construct(?DateTimeZone $zone = null) + public function __construct(\DateTimeZone $zone = null) { - $this->zone = $zone ?? new DateTimeZone('UTC'); + $this->zone = $zone ?? new \DateTimeZone('UTC'); } public function __toString(): string { - return 'SystemClock['.$this->zone->getName().']'; + return 'SystemClock[' . $this->zone->getName() . ']'; } - /** - * {@inheritDoc} - */ - public function now(): DateTimeInterface + public function now(): \DateTimeInterface { - return new DateTimeImmutable('now', $this->zone); + return new \DateTimeImmutable('now', $this->zone); } - public function getZone(): DateTimeZone + public function getZone(): \DateTimeZone { return $this->zone; } diff --git a/packages/clock/Tests/FixedClockTest.php b/packages/clock/Tests/FixedClockTest.php index 14f224ac..2b1c1f63 100644 --- a/packages/clock/Tests/FixedClockTest.php +++ b/packages/clock/Tests/FixedClockTest.php @@ -4,7 +4,6 @@ namespace SonsOfPHP\Component\Clock\Tests; -use DateTimeZone; use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Clock\ClockInterface; use SonsOfPHP\Component\Clock\Exception\ClockException; @@ -43,7 +42,7 @@ public function testTheDefaultTimezoneIsUTC(): void */ public function testSettingTheTimezoneInTheConstructorWorks(): void { - $clock = new FixedClock(new DateTimeZone('America/New_York')); + $clock = new FixedClock(new \DateTimeZone('America/New_York')); $this->assertSame('America/New_York', $clock->getZone()->getName()); } diff --git a/packages/clock/Tests/SystemClockTest.php b/packages/clock/Tests/SystemClockTest.php index d111b8bf..a2b47999 100644 --- a/packages/clock/Tests/SystemClockTest.php +++ b/packages/clock/Tests/SystemClockTest.php @@ -4,8 +4,6 @@ namespace SonsOfPHP\Component\Clock\Tests; -use DateTimeImmutable; -use DateTimeZone; use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Clock\ClockInterface; use SonsOfPHP\Component\Clock\SystemClock; @@ -37,8 +35,8 @@ public function testImmutable(): void usleep(1); $tickTwo = $clock->now(); - $this->assertInstanceOf(DateTimeImmutable::class, $tickOne); - $this->assertInstanceOf(DateTimeImmutable::class, $tickTwo); + $this->assertInstanceOf(\DateTimeImmutable::class, $tickOne); + $this->assertInstanceOf(\DateTimeImmutable::class, $tickTwo); $this->assertTrue($tickOne < $tickTwo); } @@ -58,7 +56,7 @@ public function testDefaultTimezone(): void */ public function testSetTimezoneWithObject(): void { - $clock = new SystemClock(new DateTimeZone('America/New_York')); + $clock = new SystemClock(new \DateTimeZone('America/New_York')); $this->assertSame('America/New_York', $clock->getZone()->getName()); } diff --git a/packages/clock/Time.php b/packages/clock/Time.php index 9022f0db..6b76afcb 100644 --- a/packages/clock/Time.php +++ b/packages/clock/Time.php @@ -27,9 +27,6 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return sprintf( @@ -41,33 +38,21 @@ public function toString(): string ); } - /** - * {@inheritDoc} - */ public function getHour(): int { return $this->hour; } - /** - * {@inheritDoc} - */ public function getMinute(): int { return $this->minute; } - /** - * {@inheritDoc} - */ public function getSecond(): int { return $this->second; } - /** - * {@inheritDoc} - */ public function getMillisecond(): int { return $this->millisecond; diff --git a/packages/clock/Year.php b/packages/clock/Year.php index fc0820a4..51297e58 100644 --- a/packages/clock/Year.php +++ b/packages/clock/Year.php @@ -24,17 +24,11 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return sprintf('%d', $this->year); } - /** - * {@inheritDoc} - */ public function toInt(): int { return $this->year; diff --git a/packages/clock/Zone.php b/packages/clock/Zone.php index 9ed7d26f..ed232fc3 100644 --- a/packages/clock/Zone.php +++ b/packages/clock/Zone.php @@ -23,25 +23,16 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return $this->name; } - /** - * {@inheritDoc} - */ public function getName(): string { return $this->name; } - /** - * {@inheritDoc} - */ public function getOffset(): ZoneOffsetInterface { return $this->offset; diff --git a/packages/clock/ZoneOffset.php b/packages/clock/ZoneOffset.php index 7d511ff4..52eb7688 100644 --- a/packages/clock/ZoneOffset.php +++ b/packages/clock/ZoneOffset.php @@ -21,9 +21,6 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { $lead = '+'; @@ -42,9 +39,6 @@ public function toString(): string ); } - /** - * {@inheritDoc} - */ public function getSeconds(): int { return $this->seconds; diff --git a/packages/cqrs-symfony/Command/AbstractOptionsResolverCommandMessage.php b/packages/cqrs-symfony/Command/AbstractOptionsResolverCommandMessage.php index 0c319616..80e0ce16 100644 --- a/packages/cqrs-symfony/Command/AbstractOptionsResolverCommandMessage.php +++ b/packages/cqrs-symfony/Command/AbstractOptionsResolverCommandMessage.php @@ -48,8 +48,6 @@ public function getOptions(): array /** * Returns a single option. If the option wasn't set, it returns null. - * - * @return mixed */ public function getOption(string $key) { @@ -66,8 +64,6 @@ public function hasOption(string $key): bool /** * @see ::getOption - * - * @return mixed */ public function __get(string $name) { @@ -76,8 +72,6 @@ public function __get(string $name) /** * @see ::hasOption - * - * @return mixed */ public function __isset(string $name) { diff --git a/packages/cqrs-symfony/QueryMessageBus.php b/packages/cqrs-symfony/QueryMessageBus.php index 365dd3e4..c0be22b9 100644 --- a/packages/cqrs-symfony/QueryMessageBus.php +++ b/packages/cqrs-symfony/QueryMessageBus.php @@ -35,8 +35,6 @@ public function __construct(MessageBusInterface $queryBus) /** * Handle the Query and return the results. - * - * @return mixed */ public function handle(object $query) { diff --git a/packages/cqrs/Command/CommandMessageHandlerInterface.php b/packages/cqrs/Command/CommandMessageHandlerInterface.php index eff9fa09..4fa7b7f5 100644 --- a/packages/cqrs/Command/CommandMessageHandlerInterface.php +++ b/packages/cqrs/Command/CommandMessageHandlerInterface.php @@ -9,6 +9,4 @@ /** * @author Joshua Estes */ -interface CommandMessageHandlerInterface extends MessageHandlerInterface -{ -} +interface CommandMessageHandlerInterface extends MessageHandlerInterface {} diff --git a/packages/cqrs/Command/CommandMessageInterface.php b/packages/cqrs/Command/CommandMessageInterface.php index 6db36c5e..4e5aa504 100644 --- a/packages/cqrs/Command/CommandMessageInterface.php +++ b/packages/cqrs/Command/CommandMessageInterface.php @@ -9,6 +9,4 @@ /** * @author Joshua Estes */ -interface CommandMessageInterface extends MessageInterface -{ -} +interface CommandMessageInterface extends MessageInterface {} diff --git a/packages/cqrs/MessageHandlerInterface.php b/packages/cqrs/MessageHandlerInterface.php index 6109e88d..8832cad5 100644 --- a/packages/cqrs/MessageHandlerInterface.php +++ b/packages/cqrs/MessageHandlerInterface.php @@ -7,6 +7,4 @@ /** * @author Joshua Estes */ -interface MessageHandlerInterface -{ -} +interface MessageHandlerInterface {} diff --git a/packages/cqrs/MessageInterface.php b/packages/cqrs/MessageInterface.php index c045e491..1a6cdc52 100644 --- a/packages/cqrs/MessageInterface.php +++ b/packages/cqrs/MessageInterface.php @@ -9,6 +9,4 @@ * * @author Joshua Estes */ -interface MessageInterface -{ -} +interface MessageInterface {} diff --git a/packages/cqrs/Query/QueryMessageHandlerInterface.php b/packages/cqrs/Query/QueryMessageHandlerInterface.php index 0f3a350e..1fdb7a7a 100644 --- a/packages/cqrs/Query/QueryMessageHandlerInterface.php +++ b/packages/cqrs/Query/QueryMessageHandlerInterface.php @@ -9,6 +9,4 @@ /** * @author Joshua Estes */ -interface QueryMessageHandlerInterface extends MessageHandlerInterface -{ -} +interface QueryMessageHandlerInterface extends MessageHandlerInterface {} diff --git a/packages/cqrs/Query/QueryMessageInterface.php b/packages/cqrs/Query/QueryMessageInterface.php index b62d2923..4381f434 100644 --- a/packages/cqrs/Query/QueryMessageInterface.php +++ b/packages/cqrs/Query/QueryMessageInterface.php @@ -9,6 +9,4 @@ /** * @author Joshua Estes */ -interface QueryMessageInterface extends MessageInterface -{ -} +interface QueryMessageInterface extends MessageInterface {} diff --git a/packages/event-dispatcher/EventDispatcher.php b/packages/event-dispatcher/EventDispatcher.php index 8d26a80c..963e89ac 100644 --- a/packages/event-dispatcher/EventDispatcher.php +++ b/packages/event-dispatcher/EventDispatcher.php @@ -9,35 +9,39 @@ use Psr\EventDispatcher\StoppableEventInterface; /** - * Event Dispatcher. - * * @author Joshua Estes */ class EventDispatcher implements EventDispatcherInterface { - private ListenerProviderInterface $provider; - - public function __construct(ListenerProviderInterface $provider) - { - $this->provider = $provider; - } + public function __construct( + private ListenerProviderInterface $provider = new ListenerProvider(), + ) {} /** - * {@inheritDoc} - * * @return object */ - public function dispatch(object $event) + public function dispatch(object $event, string $eventName = null): object { - $listeners = $this->provider->getListenersForEvent($event); - foreach ($listeners as $listener) { - $listener($event); + $eventName ??= $event::class; + foreach ($this->provider->getListenersForEventName($eventName) as $listener) { if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) { return $event; } + + $listener($event, $eventName, $this); } return $event; } + + public function addListener(string $eventName, callable|array $listener, int $priority = 0): void + { + $this->provider->add($eventName, $listener, $priority); + } + + public function addSubscriber(EventSubscriberInterface $subscriber): void + { + $this->provider->addSubscriber($subscriber); + } } diff --git a/packages/event-dispatcher/EventSubscriberInterface.php b/packages/event-dispatcher/EventSubscriberInterface.php new file mode 100644 index 00000000..f7142e06 --- /dev/null +++ b/packages/event-dispatcher/EventSubscriberInterface.php @@ -0,0 +1,15 @@ + + */ +interface EventSubscriberInterface +{ + /** + */ + public static function getSubscribedEvents(); +} diff --git a/packages/event-dispatcher/ListenerProvider.php b/packages/event-dispatcher/ListenerProvider.php index 2ba89a06..b177babd 100644 --- a/packages/event-dispatcher/ListenerProvider.php +++ b/packages/event-dispatcher/ListenerProvider.php @@ -7,27 +7,69 @@ use Psr\EventDispatcher\ListenerProviderInterface; /** + * Supports + * - Event Names like "event.name" + * - Listener Priorities + * - Event Subscribers + * * @author Joshua Estes */ class ListenerProvider implements ListenerProviderInterface { private array $listeners = []; + private array $sorted = []; - public function add(string $event, $listener): void + public function getListenersForEvent(object $event): iterable { - $this->listeners[$event][] = $listener; + return $this->getListenersForEventName($event::class); } - /** - * {@inheritDoc} - */ - public function getListenersForEvent(object $event): iterable + public function add(string $eventName, callable|array $listener, int $priority = 0): void + { + $this->listeners[$eventName][$priority][] = $listener; + unset($this->sorted[$eventName]); + } + + public function addSubscriber(EventSubscriberInterface $subscriber): void + { + foreach ($subscriber::getSubscribedEvents() as $eventName => $params) { + if (is_string($params)) { + // 'eventName' => 'methodName' + $this->add($eventName, [$subscriber, $params]); + } elseif (is_string($params[0])) { + // 'eventName' => ['methodName', $priority] + $this->add($eventName, [$subscriber, $params[0]], $params[1] ?? 0); + } else { + // 'eventName' => [['methodName1', $priority], ['methodName2']] + foreach ($params as $listener) { + $this->add($eventName, [$subscriber, $listener[0]], $listener[1] ?? 0); + } + } + } + } + + public function getListenersForEventName(string $eventName): iterable { - $class = $event::class; - if (isset($this->listeners[$class])) { - return $this->listeners[$class]; + if (!\array_key_exists($eventName, $this->listeners)) { + return []; + } + + if (!isset($this->sorted[$eventName])) { + $this->sortListeners($eventName); } - return []; + return $this->sorted[$eventName]; + } + + private function sortListeners(string $eventName): void + { + ksort($this->listeners[$eventName]); + $this->sorted[$eventName] = []; + + foreach ($this->listeners[$eventName] as $listeners) { + foreach ($listeners as $listener) { + $this->sorted[$eventName][] = $listener; + } + } } } diff --git a/packages/event-dispatcher/Tests/EventDispatcherTest.php b/packages/event-dispatcher/Tests/EventDispatcherTest.php index ed8f4521..0a56dd2d 100644 --- a/packages/event-dispatcher/Tests/EventDispatcherTest.php +++ b/packages/event-dispatcher/Tests/EventDispatcherTest.php @@ -8,6 +8,7 @@ use Psr\EventDispatcher\EventDispatcherInterface; use SonsOfPHP\Component\EventDispatcher\EventDispatcher; use SonsOfPHP\Component\EventDispatcher\ListenerProvider; +use SonsOfPHP\Component\EventDispatcher\EventSubscriberInterface; /** * @coversDefaultClass \SonsOfPHP\Component\EventDispatcher\EventDispatcher @@ -17,36 +18,51 @@ final class EventDispatcherTest extends TestCase { /** - * @coversNothing + * @covers ::__construct */ public function testItHasTheCorrectInterface(): void { - $dispatcher = new EventDispatcher(new ListenerProvider()); + $dispatcher = new EventDispatcher(); $this->assertInstanceOf(EventDispatcherInterface::class, $dispatcher); // @phpstan-ignore-line } /** - * @covers ::__construct * @covers ::dispatch */ - public function testDispatchReturnsEvent(): void + public function testItWillReturnTheSameEventWhenNoListeners(): void { - $dispatcher = new EventDispatcher(new ListenerProvider()); + $dispatcher = new EventDispatcher(); - $this->assertNotEmpty($dispatcher->dispatch(new \stdClass())); + $event = new \stdClass(); + $this->assertSame($event, $dispatcher->dispatch($event)); } /** - * @covers ::__construct - * @covers ::dispatch + * @covers ::addListener */ - public function testDispatchReturnsSameEventThatWasDispatched(): void + public function testItCanAddEventListener(): void { - $dispatcher = new EventDispatcher(new ListenerProvider()); + $provider = $this->createMock(ListenerProvider::class); + $provider->expects($this->once())->method('add'); + + $dispatcher = new EventDispatcher($provider); + + $dispatcher->addListener('stdClass', function (): void {}); + } + + /** + * @covers ::addSubscriber + */ + public function testItCanAddEventSubscriber(): void + { + $provider = $this->createMock(ListenerProvider::class); + $provider->expects($this->once())->method('addSubscriber'); + + $dispatcher = new EventDispatcher($provider); + + $subscriber = $this->createMock(EventSubscriberInterface::class); - $event = new \stdClass(); - $return = $dispatcher->dispatch($event); - $this->assertSame($event, $return); + $dispatcher->addSubscriber($subscriber); } } diff --git a/packages/event-dispatcher/Tests/ListenerProviderTest.php b/packages/event-dispatcher/Tests/ListenerProviderTest.php index c1e61255..14112eb6 100644 --- a/packages/event-dispatcher/Tests/ListenerProviderTest.php +++ b/packages/event-dispatcher/Tests/ListenerProviderTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use Psr\EventDispatcher\ListenerProviderInterface; use SonsOfPHP\Component\EventDispatcher\ListenerProvider; +use SonsOfPHP\Component\EventDispatcher\EventSubscriberInterface; /** * @coversDefaultClass \SonsOfPHP\Component\EventDispatcher\ListenerProvider @@ -26,6 +27,8 @@ public function testItHasTheCorrectInterface(): void /** * @covers ::getListenersForEvent + * @covers ::getListenersForEventName + * @covers ::sortListeners */ public function testGetListenersForUnknownEventReturnsEmptyArray(): void { @@ -38,14 +41,63 @@ public function testGetListenersForUnknownEventReturnsEmptyArray(): void /** * @covers ::add * @covers ::getListenersForEvent + * @covers ::getListenersForEventName + * @covers ::sortListeners */ public function testGetListenersForEvent(): void { $provider = new ListenerProvider(); - $provider->add('stdClass', 'example listener object'); + $provider->add('stdClass', function (): void {}); - $event = new \stdClass(); - $listeners = $provider->getListenersForEvent($event); + $listeners = $provider->getListenersForEvent(new \stdClass()); $this->assertCount(1, $listeners); } + + /** + * @covers ::add + * @covers ::sortListeners + */ + public function testItCanPrioritizeListeners(): void + { + $provider = new ListenerProvider(); + $provider->add('event.name', function (): void { echo '2'; }); + $provider->add('event.name', function (): void { echo '3'; }, 1); + $provider->add('event.name', function (): void { echo '1'; }, -1); + + ob_start(); + foreach ($provider->getListenersForEventName('event.name') as $listener) { + $listener(); + } + $this->assertSame('123', ob_get_clean()); + } + + /** + * @covers ::addSubscriber + */ + public function testItCanAddSubscriber(): void + { + $subscriber = new class () implements EventSubscriberInterface { + public static function getSubscribedEvents() + { + yield 'event.one' => 'handle'; + yield 'event.two' => ['handle', 0]; + yield 'event.three' => ['handle']; + yield 'event.four' => [['handle'], ['handle', 255]]; + } + + public function handle(): void {} + }; + + $provider = new ListenerProvider(); + + $this->assertCount(0, $provider->getListenersForEventName('event.one')); + $this->assertCount(0, $provider->getListenersForEventName('event.two')); + $this->assertCount(0, $provider->getListenersForEventName('event.three')); + $this->assertCount(0, $provider->getListenersForEventName('event.four')); + $provider->addSubscriber($subscriber); + $this->assertCount(1, $provider->getListenersForEventName('event.one')); + $this->assertCount(1, $provider->getListenersForEventName('event.two')); + $this->assertCount(1, $provider->getListenersForEventName('event.three')); + $this->assertCount(2, $provider->getListenersForEventName('event.four')); + } } diff --git a/packages/event-sourcing-doctrine/DoctrineDbalMessageRepository.php b/packages/event-sourcing-doctrine/DoctrineDbalMessageRepository.php index d1db8d06..b5684aae 100644 --- a/packages/event-sourcing-doctrine/DoctrineDbalMessageRepository.php +++ b/packages/event-sourcing-doctrine/DoctrineDbalMessageRepository.php @@ -33,9 +33,6 @@ public function __construct(Connection $connection, MessageSerializerInterface $ $this->tableSchema = $tableSchema; } - /** - * {@inheritDoc} - */ public function persist(MessageInterface $message): void { $id = $message->getAggregateId(); @@ -68,9 +65,6 @@ public function persist(MessageInterface $message): void ); } - /** - * {@inheritDoc} - */ public function find(string|AggregateIdInterface $id, int|AggregateVersionInterface $version = null): iterable { if (!$id instanceof AggregateIdInterface) { diff --git a/packages/event-sourcing-symfony/Aggregate/AggregateId.php b/packages/event-sourcing-symfony/Aggregate/AggregateId.php index ae5b98ff..d2668685 100644 --- a/packages/event-sourcing-symfony/Aggregate/AggregateId.php +++ b/packages/event-sourcing-symfony/Aggregate/AggregateId.php @@ -20,7 +20,7 @@ */ class AggregateId extends AbstractAggregateId { - public function __construct(?string $id = null) + public function __construct(string $id = null) { if (null === $id) { $id = (string) Uuid::v6(); diff --git a/packages/event-sourcing-symfony/Aggregate/AggregateIdNormalizer.php b/packages/event-sourcing-symfony/Aggregate/AggregateIdNormalizer.php index 7bf75d0e..166c629c 100644 --- a/packages/event-sourcing-symfony/Aggregate/AggregateIdNormalizer.php +++ b/packages/event-sourcing-symfony/Aggregate/AggregateIdNormalizer.php @@ -26,8 +26,6 @@ class AggregateIdNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * {@inheritDoc} - * * @return string */ public function normalize($object, string $format = null, array $context = []) @@ -35,17 +33,12 @@ public function normalize($object, string $format = null, array $context = []) return (string) $object; } - /** - * {@inheritDoc} - */ public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof AggregateIdInterface; } /** - * {@inheritDoc} - * * @return AggregateIdInterface */ public function denormalize($data, string $type, string $format = null, array $context = []) @@ -57,17 +50,11 @@ public function denormalize($data, string $type, string $format = null, array $c return $type::fromString($data); } - /** - * {@inheritDoc} - */ public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { return is_a($type, AggregateIdInterface::class, true); } - /** - * {@inheritDoc} - */ public function getSupportedTypes(?string $format): array { return [ diff --git a/packages/event-sourcing-symfony/Aggregate/AggregateVersionNormalizer.php b/packages/event-sourcing-symfony/Aggregate/AggregateVersionNormalizer.php index 352df373..649224c7 100644 --- a/packages/event-sourcing-symfony/Aggregate/AggregateVersionNormalizer.php +++ b/packages/event-sourcing-symfony/Aggregate/AggregateVersionNormalizer.php @@ -26,8 +26,6 @@ class AggregateVersionNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * {@inheritDoc} - * * @return int */ public function normalize($object, string $format = null, array $context = []) @@ -35,17 +33,12 @@ public function normalize($object, string $format = null, array $context = []) return $object->toInt(); } - /** - * {@inheritDoc} - */ public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof AggregateVersionInterface; } /** - * {@inheritDoc} - * * @return AggregateVersionInterface */ public function denormalize($data, string $type, string $format = null, array $context = []) @@ -57,17 +50,11 @@ public function denormalize($data, string $type, string $format = null, array $c return $type::fromInt($data); } - /** - * {@inheritDoc} - */ public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { return is_a($type, AggregateVersionInterface::class, true); } - /** - * {@inheritDoc} - */ public function getSupportedTypes(?string $format): array { return [ diff --git a/packages/event-sourcing-symfony/Message/Enricher/Handler/BlameableMessageEnricherHandler.php b/packages/event-sourcing-symfony/Message/Enricher/Handler/BlameableMessageEnricherHandler.php index 05f5d6b2..b53d4e51 100644 --- a/packages/event-sourcing-symfony/Message/Enricher/Handler/BlameableMessageEnricherHandler.php +++ b/packages/event-sourcing-symfony/Message/Enricher/Handler/BlameableMessageEnricherHandler.php @@ -29,12 +29,8 @@ class BlameableMessageEnricherHandler implements MessageEnricherHandlerInterface public function __construct( private Security $security - ) { - } + ) {} - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { $user = $this->security->getUser(); diff --git a/packages/event-sourcing-symfony/Message/Enricher/Handler/HttpRequestMessageEnricherHandler.php b/packages/event-sourcing-symfony/Message/Enricher/Handler/HttpRequestMessageEnricherHandler.php index d0bf1805..26126135 100644 --- a/packages/event-sourcing-symfony/Message/Enricher/Handler/HttpRequestMessageEnricherHandler.php +++ b/packages/event-sourcing-symfony/Message/Enricher/Handler/HttpRequestMessageEnricherHandler.php @@ -28,12 +28,8 @@ class HttpRequestMessageEnricherHandler implements MessageEnricherHandlerInterfa public function __construct( private RequestStack $requestStack - ) { - } + ) {} - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { $request = $this->requestStack->getMainRequest(); diff --git a/packages/event-sourcing-symfony/Message/Enricher/Handler/UlidEventIdMessageEnricherHandler.php b/packages/event-sourcing-symfony/Message/Enricher/Handler/UlidEventIdMessageEnricherHandler.php index 7f68f42a..1432a447 100644 --- a/packages/event-sourcing-symfony/Message/Enricher/Handler/UlidEventIdMessageEnricherHandler.php +++ b/packages/event-sourcing-symfony/Message/Enricher/Handler/UlidEventIdMessageEnricherHandler.php @@ -16,9 +16,6 @@ */ class UlidEventIdMessageEnricherHandler implements MessageEnricherHandlerInterface { - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { return $message->withMetadata([ diff --git a/packages/event-sourcing-symfony/Message/Enricher/Handler/UuidEventIdMessageEnricherHandler.php b/packages/event-sourcing-symfony/Message/Enricher/Handler/UuidEventIdMessageEnricherHandler.php index 08da2bea..82a8e76f 100644 --- a/packages/event-sourcing-symfony/Message/Enricher/Handler/UuidEventIdMessageEnricherHandler.php +++ b/packages/event-sourcing-symfony/Message/Enricher/Handler/UuidEventIdMessageEnricherHandler.php @@ -18,9 +18,6 @@ */ class UuidEventIdMessageEnricherHandler implements MessageEnricherHandlerInterface { - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { return $message->withMetadata([ diff --git a/packages/event-sourcing-symfony/Message/MessageNormalizer.php b/packages/event-sourcing-symfony/Message/MessageNormalizer.php index 83fd355d..a99a597a 100644 --- a/packages/event-sourcing-symfony/Message/MessageNormalizer.php +++ b/packages/event-sourcing-symfony/Message/MessageNormalizer.php @@ -23,8 +23,6 @@ class MessageNormalizer implements NormalizerInterface, DenormalizerInterface { /** - * {@inheritDoc} - * * @return array */ public function normalize($object, string $format = null, array $context = []) @@ -35,17 +33,12 @@ public function normalize($object, string $format = null, array $context = []) ]; } - /** - * {@inheritDoc} - */ public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof MessageInterface; } /** - * {@inheritDoc} - * * @return MessageInterface */ public function denormalize($data, string $type, string $format = null, array $context = []) @@ -53,9 +46,6 @@ public function denormalize($data, string $type, string $format = null, array $c return $type::new()->withPayload($data['payload'])->withMetadata($data['metadata']); } - /** - * {@inheritDoc} - */ public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { if (false === \is_array($data)) { @@ -69,9 +59,6 @@ public function supportsDenormalization($data, string $type, string $format = nu return is_subclass_of($type, MessageInterface::class, true); } - /** - * {@inheritDoc} - */ public function getSupportedTypes(?string $format): array { return [ diff --git a/packages/event-sourcing-symfony/Tests/Aggregate/AggregateIdNormalizerTest.php b/packages/event-sourcing-symfony/Tests/Aggregate/AggregateIdNormalizerTest.php index d565f77b..381c4477 100644 --- a/packages/event-sourcing-symfony/Tests/Aggregate/AggregateIdNormalizerTest.php +++ b/packages/event-sourcing-symfony/Tests/Aggregate/AggregateIdNormalizerTest.php @@ -59,7 +59,7 @@ public function testSupportsDenormalize( $this->assertSame($expected, $normalizer->supportsDenormalization($data, $type, $format)); } - public function providerForSupportsDenormalization(): iterable + public static function providerForSupportsDenormalization(): iterable { yield [true, 'aggregate-id', AggregateId::class]; yield [true, 'aggregate-id', AggregateIdInterface::class]; @@ -85,7 +85,7 @@ public function testDenormalize( $this->assertSame($data, $output->toString()); } - public function providerForDenormalize(): iterable + public static function providerForDenormalize(): iterable { yield ['aggregate-id', AggregateId::class]; yield ['aggregate-id', AggregateIdInterface::class]; diff --git a/packages/event-sourcing-symfony/Tests/Aggregate/AggregateVersionNormalizerTest.php b/packages/event-sourcing-symfony/Tests/Aggregate/AggregateVersionNormalizerTest.php index 4487e246..7fea6c23 100644 --- a/packages/event-sourcing-symfony/Tests/Aggregate/AggregateVersionNormalizerTest.php +++ b/packages/event-sourcing-symfony/Tests/Aggregate/AggregateVersionNormalizerTest.php @@ -59,7 +59,7 @@ public function testItSupportsDenormalize( $this->assertSame($expected, $normalizer->supportsDenormalization($data, $type, $format)); } - public function providerForSupportsDenormalization(): iterable + public static function providerForSupportsDenormalization(): iterable { yield [true, 2131, AggregateVersion::class]; yield [true, 2131, AggregateVersionInterface::class]; @@ -85,7 +85,7 @@ public function testItWillDenormalize( $this->assertSame($data, $output->toInt()); } - public function providerForDenormalize(): iterable + public static function providerForDenormalize(): iterable { yield [2131, AggregateVersion::class]; yield [2131, AggregateVersionInterface::class]; diff --git a/packages/event-sourcing-symfony/Tests/Message/MessageNormalizerTest.php b/packages/event-sourcing-symfony/Tests/Message/MessageNormalizerTest.php index 552655b4..853380df 100644 --- a/packages/event-sourcing-symfony/Tests/Message/MessageNormalizerTest.php +++ b/packages/event-sourcing-symfony/Tests/Message/MessageNormalizerTest.php @@ -10,9 +10,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -class Msg extends AbstractMessage -{ -} +class Msg extends AbstractMessage {} /** * @coversDefaultClass \SonsOfPHP\Bridge\Symfony\EventSourcing\Message\MessageNormalizer diff --git a/packages/event-sourcing/Aggregate/AbstractAggregate.php b/packages/event-sourcing/Aggregate/AbstractAggregate.php index 5b8bc4a5..8b729450 100644 --- a/packages/event-sourcing/Aggregate/AbstractAggregate.php +++ b/packages/event-sourcing/Aggregate/AbstractAggregate.php @@ -4,7 +4,6 @@ namespace SonsOfPHP\Component\EventSourcing\Aggregate; -use Generator; use SonsOfPHP\Component\EventSourcing\Message\MessageInterface; use SonsOfPHP\Component\EventSourcing\Metadata; @@ -40,17 +39,11 @@ final public static function new($id) return $static; } - /** - * {@inheritDoc} - */ final public function getAggregateId(): AggregateIdInterface { return $this->id; } - /** - * {@inheritDoc} - */ final public function getAggregateVersion(): AggregateVersionInterface { return $this->version; @@ -66,9 +59,6 @@ final public function hasPendingEvents(): bool return \count($this->pendingEvents) > 0; } - /** - * {@inheritDoc} - */ final public function getPendingEvents(): iterable { $events = $this->pendingEvents; @@ -77,10 +67,7 @@ final public function getPendingEvents(): iterable return $events; } - /** - * {@inheritDoc} - */ - final public static function buildFromEvents(AggregateIdInterface $id, Generator $events): AggregateInterface + final public static function buildFromEvents(AggregateIdInterface $id, \Generator $events): AggregateInterface { $aggregate = new static($id); foreach ($events as $event) { @@ -129,7 +116,7 @@ final protected function raiseEvent(MessageInterface $event): void final protected function applyEvent(MessageInterface $event): void { $parts = explode('\\', $event::class); - $method = 'apply'.end($parts); + $method = 'apply' . end($parts); if (method_exists($this, $method)) { $this->{$method}($event); // @phpstan-ignore-line diff --git a/packages/event-sourcing/Aggregate/AbstractAggregateId.php b/packages/event-sourcing/Aggregate/AbstractAggregateId.php index 9d3138a7..96af6b80 100644 --- a/packages/event-sourcing/Aggregate/AbstractAggregateId.php +++ b/packages/event-sourcing/Aggregate/AbstractAggregateId.php @@ -24,33 +24,21 @@ public function __construct( } } - /** - * {@inheritDoc} - */ final public function __toString(): string { return $this->toString(); } - /** - * {@inheritDoc} - */ final public function toString(): string { return $this->id; } - /** - * {@inheritDoc} - */ final public static function fromString(string $id): AggregateIdInterface { return new static($id); } - /** - * {@inheritDoc} - */ final public function equals(AggregateIdInterface $that): bool { return $this->toString() === $that->toString(); diff --git a/packages/event-sourcing/Aggregate/AbstractSnapshotableAggregate.php b/packages/event-sourcing/Aggregate/AbstractSnapshotableAggregate.php index 14cd1af8..8eb54cf5 100644 --- a/packages/event-sourcing/Aggregate/AbstractSnapshotableAggregate.php +++ b/packages/event-sourcing/Aggregate/AbstractSnapshotableAggregate.php @@ -4,7 +4,6 @@ namespace SonsOfPHP\Component\EventSourcing\Aggregate; -use Generator; use SonsOfPHP\Component\EventSourcing\Snapshot\Snapshot; use SonsOfPHP\Component\EventSourcing\Snapshot\SnapshotInterface; @@ -16,8 +15,6 @@ abstract class AbstractSnapshotableAggregate extends AbstractAggregate /** * Return the current state of the aggregate. This is * used as the snapshot state. - * - * @return mixed */ abstract protected function createSnapshotState(); @@ -37,7 +34,7 @@ public function createSnapshot(): SnapshotInterface /** * @see SnapshotableAggregateInterface::buildFromSnapshotAndEvents */ - public static function buildFromSnapshotAndEvents(SnapshotInterface $snapshot, Generator $messages): SnapshotableAggregateInterface + public static function buildFromSnapshotAndEvents(SnapshotInterface $snapshot, \Generator $messages): SnapshotableAggregateInterface { $aggregate = static::buildFromSnapshot($snapshot); foreach ($messages as $msg) { diff --git a/packages/event-sourcing/Aggregate/AggregateId.php b/packages/event-sourcing/Aggregate/AggregateId.php index 5e958244..e5e2060e 100644 --- a/packages/event-sourcing/Aggregate/AggregateId.php +++ b/packages/event-sourcing/Aggregate/AggregateId.php @@ -12,6 +12,4 @@ * * @author Joshua Estes */ -final class AggregateId extends AbstractAggregateId -{ -} +final class AggregateId extends AbstractAggregateId {} diff --git a/packages/event-sourcing/Aggregate/AggregateIdInterface.php b/packages/event-sourcing/Aggregate/AggregateIdInterface.php index 8b40216d..85a40f59 100644 --- a/packages/event-sourcing/Aggregate/AggregateIdInterface.php +++ b/packages/event-sourcing/Aggregate/AggregateIdInterface.php @@ -20,7 +20,7 @@ interface AggregateIdInterface extends \Stringable * * @throws EventSourcingException If the class does not support auto-generating IDs */ - public function __construct(?string $id = null); + public function __construct(string $id = null); /** * @see self::toString diff --git a/packages/event-sourcing/Aggregate/AggregateInterface.php b/packages/event-sourcing/Aggregate/AggregateInterface.php index be0d38a3..cf26ab0f 100644 --- a/packages/event-sourcing/Aggregate/AggregateInterface.php +++ b/packages/event-sourcing/Aggregate/AggregateInterface.php @@ -4,7 +4,6 @@ namespace SonsOfPHP\Component\EventSourcing\Aggregate; -use Generator; use SonsOfPHP\Component\EventSourcing\Exception\EventSourcingException; use SonsOfPHP\Component\EventSourcing\Message\MessageInterface; @@ -41,9 +40,9 @@ public function getPendingEvents(): iterable; /** * Build Aggregate from a collection of Domain Events. * - * @param Generator $events yields MessageInterface objects + * @param \Generator $events yields MessageInterface objects * * @throws EventSourcingException */ - public static function buildFromEvents(AggregateIdInterface $id, Generator $events): self; + public static function buildFromEvents(AggregateIdInterface $id, \Generator $events): self; } diff --git a/packages/event-sourcing/Aggregate/AggregateVersion.php b/packages/event-sourcing/Aggregate/AggregateVersion.php index 5c4dd485..f1923711 100644 --- a/packages/event-sourcing/Aggregate/AggregateVersion.php +++ b/packages/event-sourcing/Aggregate/AggregateVersion.php @@ -24,49 +24,31 @@ public function __construct(int $version = 0) } } - /** - * {@inheritDoc} - */ public static function fromInt(int $version): AggregateVersionInterface { return new static($version); } - /** - * {@inheritDoc} - */ public static function zero(): AggregateVersionInterface { return new static(0); } - /** - * {@inheritDoc} - */ public function next(): AggregateVersionInterface { return new static($this->version + 1); } - /** - * {@inheritDoc} - */ public function prev(): AggregateVersionInterface { return new static($this->version - 1); } - /** - * {@inheritDoc} - */ public function equals(AggregateVersionInterface $version): bool { return $this->version === $version->toInt(); } - /** - * {@inheritDoc} - */ public function toInt(): int { return $this->version; diff --git a/packages/event-sourcing/Aggregate/Repository/AggregateRepository.php b/packages/event-sourcing/Aggregate/Repository/AggregateRepository.php index bedb5670..ac487c28 100644 --- a/packages/event-sourcing/Aggregate/Repository/AggregateRepository.php +++ b/packages/event-sourcing/Aggregate/Repository/AggregateRepository.php @@ -28,9 +28,6 @@ public function __construct( $this->messageEnricher = $messageEnricher ?? new MessageEnricher(new NullMessageEnricherProvider()); } - /** - * {@inheritDoc} - */ public function find(AggregateIdInterface|string $id): ?AggregateInterface { if (!$id instanceof AggregateIdInterface) { @@ -48,9 +45,6 @@ public function find(AggregateIdInterface|string $id): ?AggregateInterface return null; } - /** - * {@inheritDoc} - */ public function persist(AggregateInterface $aggregate): void { $events = $aggregate->getPendingEvents(); diff --git a/packages/event-sourcing/Aggregate/SnapshotableAggregateInterface.php b/packages/event-sourcing/Aggregate/SnapshotableAggregateInterface.php index 18ce7076..dea67c7e 100644 --- a/packages/event-sourcing/Aggregate/SnapshotableAggregateInterface.php +++ b/packages/event-sourcing/Aggregate/SnapshotableAggregateInterface.php @@ -4,7 +4,6 @@ namespace SonsOfPHP\Component\EventSourcing\Aggregate; -use Generator; use SonsOfPHP\Component\EventSourcing\Snapshot\SnapshotInterface; /** @@ -21,5 +20,5 @@ public function createSnapshot(): SnapshotInterface; public static function buildFromSnapshot(SnapshotInterface $snapshot): self; - public static function buildFromSnapshotAndEvents(SnapshotInterface $snapshot, Generator $events): self; + public static function buildFromSnapshotAndEvents(SnapshotInterface $snapshot, \Generator $events): self; } diff --git a/packages/event-sourcing/Exception/AggregateNotFoundException.php b/packages/event-sourcing/Exception/AggregateNotFoundException.php index b2717569..37c87396 100644 --- a/packages/event-sourcing/Exception/AggregateNotFoundException.php +++ b/packages/event-sourcing/Exception/AggregateNotFoundException.php @@ -4,11 +4,7 @@ namespace SonsOfPHP\Component\EventSourcing\Exception; -use Exception; - /** * @author Joshua Estes */ -class AggregateNotFoundException extends Exception -{ -} +class AggregateNotFoundException extends \Exception {} diff --git a/packages/event-sourcing/Exception/EventSourcingException.php b/packages/event-sourcing/Exception/EventSourcingException.php index 5de88ff8..b2b6a347 100644 --- a/packages/event-sourcing/Exception/EventSourcingException.php +++ b/packages/event-sourcing/Exception/EventSourcingException.php @@ -14,6 +14,4 @@ * * @author Joshua Estes */ -class EventSourcingException extends Exception -{ -} +class EventSourcingException extends \Exception {} diff --git a/packages/event-sourcing/Message/AbstractGenericMessage.php b/packages/event-sourcing/Message/AbstractGenericMessage.php index e0022afd..c8bbf06f 100644 --- a/packages/event-sourcing/Message/AbstractGenericMessage.php +++ b/packages/event-sourcing/Message/AbstractGenericMessage.php @@ -7,6 +7,4 @@ /** * @deprecated Use AbstractSerializableMessage */ -abstract class AbstractGenericMessage extends AbstractSerializableMessage implements SerializableMessageInterface -{ -} +abstract class AbstractGenericMessage extends AbstractSerializableMessage implements SerializableMessageInterface {} diff --git a/packages/event-sourcing/Message/AbstractMessage.php b/packages/event-sourcing/Message/AbstractMessage.php index 95a1c068..89ff924b 100644 --- a/packages/event-sourcing/Message/AbstractMessage.php +++ b/packages/event-sourcing/Message/AbstractMessage.php @@ -25,68 +25,43 @@ abstract class AbstractMessage implements MessageInterface final public function __construct( private MessagePayload $payload = new MessagePayload(), private MessageMetadata $metadata = new MessageMetadata(), - ) { - } + ) {} - /** - * {@inheritDoc} - */ final public static function new(): MessageInterface { return new static(new MessagePayload(), new MessageMetadata()); } - /** - * {@inheritDoc} - */ final public function getEventId(): string { return $this->metadata->getEventId(); } - /** - * {@inheritDoc} - */ final public function getEventType(): string { return $this->metadata->getEventType(); } - /** - * {@inheritDoc} - */ final public function getTimestamp(): string { return $this->metadata->getTimestamp()->format($this->getTimestampFormat()); } - /** - * {@inheritDoc} - */ final public function getTimestampFormat(): string { return $this->metadata->getTimestampFormat(); } - /** - * {@inheritDoc} - */ final public function getAggregateId(): AggregateIdInterface { return $this->metadata->getAggregateId(); } - /** - * {@inheritDoc} - */ final public function getAggregateVersion(): AggregateVersionInterface { return $this->metadata->getAggregateVersion(); } - /** - * {@inheritDoc} - */ final public function withMetadata(array $metadata): MessageInterface { $that = clone $this; @@ -95,17 +70,11 @@ final public function withMetadata(array $metadata): MessageInterface return $that; } - /** - * {@inheritDoc} - */ final public function getMetadata(): array { return $this->metadata->all(); } - /** - * {@inheritDoc} - */ final public function withPayload(array $payload): MessageInterface { $that = clone $this; @@ -114,9 +83,6 @@ final public function withPayload(array $payload): MessageInterface return $that; } - /** - * {@inheritDoc} - */ final public function getPayload(): array { return $this->payload->all(); diff --git a/packages/event-sourcing/Message/AbstractSerializableMessage.php b/packages/event-sourcing/Message/AbstractSerializableMessage.php index 6480c03d..7494e40e 100644 --- a/packages/event-sourcing/Message/AbstractSerializableMessage.php +++ b/packages/event-sourcing/Message/AbstractSerializableMessage.php @@ -11,9 +11,6 @@ */ abstract class AbstractSerializableMessage extends AbstractMessage implements SerializableMessageInterface { - /** - * {@inheritDoc} - */ final public function serialize(): array { return [ @@ -22,9 +19,6 @@ final public function serialize(): array ]; } - /** - * {@inheritDoc} - */ final public static function deserialize(array $data): SerializableMessageInterface { if (!isset($data['payload']) || !isset($data['metadata'])) { diff --git a/packages/event-sourcing/Message/Enricher/Handler/EventTypeMessageEnricherHandler.php b/packages/event-sourcing/Message/Enricher/Handler/EventTypeMessageEnricherHandler.php index 020b111d..ceb9dc41 100644 --- a/packages/event-sourcing/Message/Enricher/Handler/EventTypeMessageEnricherHandler.php +++ b/packages/event-sourcing/Message/Enricher/Handler/EventTypeMessageEnricherHandler.php @@ -24,9 +24,6 @@ public function __construct(MessageProviderInterface $messageProvider) $this->messageProvider = $messageProvider; } - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { return $message->withMetadata([ diff --git a/packages/event-sourcing/Message/Enricher/Handler/NullMessageEnricherHandler.php b/packages/event-sourcing/Message/Enricher/Handler/NullMessageEnricherHandler.php index 51aa070f..1dc519fe 100644 --- a/packages/event-sourcing/Message/Enricher/Handler/NullMessageEnricherHandler.php +++ b/packages/event-sourcing/Message/Enricher/Handler/NullMessageEnricherHandler.php @@ -13,9 +13,6 @@ */ final class NullMessageEnricherHandler implements MessageEnricherHandlerInterface { - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { return $message; diff --git a/packages/event-sourcing/Message/Enricher/MessageEnricher.php b/packages/event-sourcing/Message/Enricher/MessageEnricher.php index 9750b2b0..1a3bbb08 100644 --- a/packages/event-sourcing/Message/Enricher/MessageEnricher.php +++ b/packages/event-sourcing/Message/Enricher/MessageEnricher.php @@ -19,9 +19,6 @@ public function __construct(MessageEnricherProviderInterface $provider) $this->provider = $provider; } - /** - * {@inheritDoc} - */ public function enrich(MessageInterface $message): MessageInterface { $enrichers = $this->provider->getEnrichersForMessage($message); diff --git a/packages/event-sourcing/Message/Enricher/Provider/AllMessageEnricherProvider.php b/packages/event-sourcing/Message/Enricher/Provider/AllMessageEnricherProvider.php index ed6f43a6..a8cb72da 100644 --- a/packages/event-sourcing/Message/Enricher/Provider/AllMessageEnricherProvider.php +++ b/packages/event-sourcing/Message/Enricher/Provider/AllMessageEnricherProvider.php @@ -32,9 +32,6 @@ public function register(MessageEnricherHandlerInterface $handler): void $this->enrichers[] = $handler; } - /** - * {@inheritDoc} - */ public function getEnrichersForMessage(MessageInterface $message): iterable { return $this->enrichers; diff --git a/packages/event-sourcing/Message/Enricher/Provider/ChainMessageEnricherProvider.php b/packages/event-sourcing/Message/Enricher/Provider/ChainMessageEnricherProvider.php index c7af0467..f4874625 100644 --- a/packages/event-sourcing/Message/Enricher/Provider/ChainMessageEnricherProvider.php +++ b/packages/event-sourcing/Message/Enricher/Provider/ChainMessageEnricherProvider.php @@ -32,9 +32,6 @@ public function registerProvider(MessageEnricherProviderInterface $provider): vo $this->providers[] = $provider; } - /** - * {@inheritDoc} - */ public function getEnrichersForMessage(MessageInterface $message): iterable { foreach ($this->providers as $provider) { diff --git a/packages/event-sourcing/Message/Enricher/Provider/NullMessageEnricherProvider.php b/packages/event-sourcing/Message/Enricher/Provider/NullMessageEnricherProvider.php index 4012f87f..7c47098d 100644 --- a/packages/event-sourcing/Message/Enricher/Provider/NullMessageEnricherProvider.php +++ b/packages/event-sourcing/Message/Enricher/Provider/NullMessageEnricherProvider.php @@ -15,9 +15,6 @@ */ final class NullMessageEnricherProvider implements MessageEnricherProviderInterface { - /** - * {@inheritDoc} - */ public function getEnrichersForMessage(MessageInterface $message): iterable { return []; diff --git a/packages/event-sourcing/Message/MessageHandlerInterface.php b/packages/event-sourcing/Message/MessageHandlerInterface.php index 7d15bf6b..87c0890c 100644 --- a/packages/event-sourcing/Message/MessageHandlerInterface.php +++ b/packages/event-sourcing/Message/MessageHandlerInterface.php @@ -11,6 +11,4 @@ * * @author Joshua Estes */ -interface MessageHandlerInterface -{ -} +interface MessageHandlerInterface {} diff --git a/packages/event-sourcing/Message/MessagePayload.php b/packages/event-sourcing/Message/MessagePayload.php index ff5eb382..ebd05ba9 100644 --- a/packages/event-sourcing/Message/MessagePayload.php +++ b/packages/event-sourcing/Message/MessagePayload.php @@ -13,8 +13,7 @@ final class MessagePayload implements \IteratorAggregate, \Countable { public function __construct( private array $payload = [], - ) { - } + ) {} public function getIterator(): \Traversable { diff --git a/packages/event-sourcing/Message/NamespaceMessageProvider.php b/packages/event-sourcing/Message/NamespaceMessageProvider.php index 7f115397..fd64ed53 100644 --- a/packages/event-sourcing/Message/NamespaceMessageProvider.php +++ b/packages/event-sourcing/Message/NamespaceMessageProvider.php @@ -20,9 +20,6 @@ public function __construct(string $namespace) $this->namespace = $namespace; } - /** - * {@inheritDoc} - */ public function getEventTypeForMessage($message): string { if (\is_object($message)) { @@ -42,12 +39,9 @@ public function getEventTypeForMessage($message): string return $eventType; } - /** - * {@inheritDoc} - */ public function getMessageClassForEventType(string $eventType): string { - $fqcn = $this->namespace.'\\'.$eventType; + $fqcn = $this->namespace . '\\' . $eventType; if (!class_exists($fqcn)) { throw new EventSourcingException(sprintf('Could not find "%s" for event "%s"', $fqcn, $eventType)); diff --git a/packages/event-sourcing/Message/Repository/InMemoryMessageRepository.php b/packages/event-sourcing/Message/Repository/InMemoryMessageRepository.php index d266d7a2..87980af8 100644 --- a/packages/event-sourcing/Message/Repository/InMemoryMessageRepository.php +++ b/packages/event-sourcing/Message/Repository/InMemoryMessageRepository.php @@ -18,9 +18,6 @@ final class InMemoryMessageRepository implements MessageRepositoryInterface { private array $storage = []; - /** - * {@inheritDoc} - */ public function persist(MessageInterface $message): void { $id = $message->getAggregateId(); @@ -29,9 +26,6 @@ public function persist(MessageInterface $message): void $this->storage[$id->toString()][$version->toInt()] = $message; } - /** - * {@inheritDoc} - */ public function find(string|AggregateIdInterface $id, int|AggregateVersionInterface $version = null): iterable { if (!$id instanceof AggregateIdInterface) { diff --git a/packages/event-sourcing/Message/Serializer/MessageSerializer.php b/packages/event-sourcing/Message/Serializer/MessageSerializer.php index ac68939a..51010295 100644 --- a/packages/event-sourcing/Message/Serializer/MessageSerializer.php +++ b/packages/event-sourcing/Message/Serializer/MessageSerializer.php @@ -25,10 +25,6 @@ class MessageSerializer implements MessageSerializerInterface private MessageEnricherInterface $messageEnricher; private MessageUpcasterInterface $messageUpcaster; - /** - * @param MessageEnricherInterface $messageEnricher - * @param MessageUpcasterInterface $messageUpcaster - */ public function __construct( MessageProviderInterface $messageProvider, MessageEnricherInterface $messageEnricher = null, @@ -39,9 +35,6 @@ public function __construct( $this->messageUpcaster = $messageUpcaster ?? new MessageUpcaster(new NullMessageUpcasterProvider()); } - /** - * {@inheritDoc} - */ public function serialize(SerializableMessageInterface $message): array { // @var SerializableMessageInterface $message @@ -52,9 +45,6 @@ public function serialize(SerializableMessageInterface $message): array return $message->serialize(); // @phpstan-ignore-line } - /** - * {@inheritDoc} - */ public function deserialize(array $data): SerializableMessageInterface { $data = $this->messageUpcaster->upcast($data); @@ -86,9 +76,9 @@ private function ensureRequiredMetadataExists(array $metadata): void if (\count($requiredMetadata) != \count(array_intersect_key(array_flip($requiredMetadata), $metadata))) { $values = []; foreach ($metadata as $k => $v) { - $values[] = $k.' => '.$v; + $values[] = $k . ' => ' . $v; } - throw new EventSourcingException('Message Metadata is missing one or more required values. Current metadata: '.implode(',', $values)); + throw new EventSourcingException('Message Metadata is missing one or more required values. Current metadata: ' . implode(',', $values)); } } } diff --git a/packages/event-sourcing/Message/Upcaster/Handler/NullUpcasterHandler.php b/packages/event-sourcing/Message/Upcaster/Handler/NullUpcasterHandler.php index 8f947628..12fe6a34 100644 --- a/packages/event-sourcing/Message/Upcaster/Handler/NullUpcasterHandler.php +++ b/packages/event-sourcing/Message/Upcaster/Handler/NullUpcasterHandler.php @@ -13,9 +13,6 @@ */ final class NullUpcasterHandler implements MessageUpcasterHandlerInterface { - /** - * {@inheritDoc} - */ public function upcast(array $eventData): array { return $eventData; diff --git a/packages/event-sourcing/Message/Upcaster/MessageUpcaster.php b/packages/event-sourcing/Message/Upcaster/MessageUpcaster.php index 60691a1d..53324754 100644 --- a/packages/event-sourcing/Message/Upcaster/MessageUpcaster.php +++ b/packages/event-sourcing/Message/Upcaster/MessageUpcaster.php @@ -18,9 +18,6 @@ public function __construct(MessageUpcasterProviderInterface $provider) $this->provider = $provider; } - /** - * {@inheritDoc} - */ public function upcast(array $data): array { $handlers = $this->provider->getUpcastersForEventData($data); diff --git a/packages/event-sourcing/Message/Upcaster/Provider/EventTypeMessageUpcasterProvider.php b/packages/event-sourcing/Message/Upcaster/Provider/EventTypeMessageUpcasterProvider.php index 262bf1f4..16a6aa39 100644 --- a/packages/event-sourcing/Message/Upcaster/Provider/EventTypeMessageUpcasterProvider.php +++ b/packages/event-sourcing/Message/Upcaster/Provider/EventTypeMessageUpcasterProvider.php @@ -26,13 +26,10 @@ public function register(string $eventType, MessageUpcasterHandlerInterface $upc $this->upcasters[$eventType][] = $upcaster; } - /** - * {@inheritDoc} - */ public function getUpcastersForEventData(array $eventData): iterable { if (empty($eventData['metadata'][Metadata::EVENT_TYPE])) { - throw new EventSourcingException('Event Data does not have metadata.'.Metadata::EVENT_TYPE.' set so this provider cannot be used'); + throw new EventSourcingException('Event Data does not have metadata.' . Metadata::EVENT_TYPE . ' set so this provider cannot be used'); } $eventType = $eventData['metadata'][Metadata::EVENT_TYPE]; diff --git a/packages/event-sourcing/Message/Upcaster/Provider/NullMessageUpcasterProvider.php b/packages/event-sourcing/Message/Upcaster/Provider/NullMessageUpcasterProvider.php index 9ad2f3d6..c2de6a52 100644 --- a/packages/event-sourcing/Message/Upcaster/Provider/NullMessageUpcasterProvider.php +++ b/packages/event-sourcing/Message/Upcaster/Provider/NullMessageUpcasterProvider.php @@ -9,9 +9,6 @@ */ final class NullMessageUpcasterProvider implements MessageUpcasterProviderInterface { - /** - * {@inheritDoc} - */ public function getUpcastersForEventData(array $eventData): iterable { return []; diff --git a/packages/event-sourcing/Snapshot/Repository/InMemorySnapshotRepository.php b/packages/event-sourcing/Snapshot/Repository/InMemorySnapshotRepository.php index 5522a341..5e95fcfc 100644 --- a/packages/event-sourcing/Snapshot/Repository/InMemorySnapshotRepository.php +++ b/packages/event-sourcing/Snapshot/Repository/InMemorySnapshotRepository.php @@ -14,17 +14,11 @@ final class InMemorySnapshotRepository implements SnapshotRepositoryInterface { private array $storage = []; - /** - * {@inheritDoc} - */ public function find(AggregateIdInterface $id): ?SnapshotInterface { return $this->storage[$id->toString()] ?? null; } - /** - * {@inheritDoc} - */ public function persist(SnapshotInterface $snapshot): void { $this->storage[$snapshot->getAggregateId()->toString()] = $snapshot; diff --git a/packages/event-sourcing/Snapshot/SnapshotInterface.php b/packages/event-sourcing/Snapshot/SnapshotInterface.php index 10b19d7c..1fb31838 100644 --- a/packages/event-sourcing/Snapshot/SnapshotInterface.php +++ b/packages/event-sourcing/Snapshot/SnapshotInterface.php @@ -20,8 +20,5 @@ public function getAggregateId(): AggregateIdInterface; public function getAggregateVersion(): AggregateVersionInterface; - /** - * @return mixed - */ public function getState(); } diff --git a/packages/event-sourcing/Tests/Aggregate/Repository/AggregateRepositoryTest.php b/packages/event-sourcing/Tests/Aggregate/Repository/AggregateRepositoryTest.php index 3405fdd0..e1792675 100644 --- a/packages/event-sourcing/Tests/Aggregate/Repository/AggregateRepositoryTest.php +++ b/packages/event-sourcing/Tests/Aggregate/Repository/AggregateRepositoryTest.php @@ -13,11 +13,8 @@ use SonsOfPHP\Component\EventSourcing\Message\Repository\InMemoryMessageRepository; use SonsOfPHP\Component\EventSourcing\Message\Repository\MessageRepositoryInterface; use SonsOfPHP\Component\EventSourcing\Tests\FakeAggregate; -use TypeError; -class Msg extends AbstractMessage -{ -} +class Msg extends AbstractMessage {} /** * @coversDefaultClass \SonsOfPHP\Component\EventSourcing\Aggregate\Repository\AggregateRepository @@ -127,7 +124,7 @@ public function testItThrowsExceptionWhenPassingInIncorrectArgumentType(): void $this->messageRepository ); - $this->expectException(TypeError::class); + $this->expectException(\TypeError::class); $result = $repository->find(123); } diff --git a/packages/event-sourcing/Tests/FakeSerializableMessage.php b/packages/event-sourcing/Tests/FakeSerializableMessage.php index a05836f2..381f36a3 100644 --- a/packages/event-sourcing/Tests/FakeSerializableMessage.php +++ b/packages/event-sourcing/Tests/FakeSerializableMessage.php @@ -7,6 +7,4 @@ use SonsOfPHP\Component\EventSourcing\Message\AbstractSerializableMessage; use SonsOfPHP\Component\EventSourcing\Message\SerializableMessageInterface; -class FakeSerializableMessage extends AbstractSerializableMessage implements SerializableMessageInterface -{ -} +class FakeSerializableMessage extends AbstractSerializableMessage implements SerializableMessageInterface {} diff --git a/packages/event-sourcing/Tests/Message/AbstractMessageTest.php b/packages/event-sourcing/Tests/Message/AbstractMessageTest.php index 8e48f977..02eb160b 100644 --- a/packages/event-sourcing/Tests/Message/AbstractMessageTest.php +++ b/packages/event-sourcing/Tests/Message/AbstractMessageTest.php @@ -12,9 +12,7 @@ use SonsOfPHP\Component\EventSourcing\Message\MessageInterface; use SonsOfPHP\Component\EventSourcing\Metadata; -class Msg extends AbstractMessage -{ -} +class Msg extends AbstractMessage {} /** * @coversDefaultClass \SonsOfPHP\Component\EventSourcing\Message\AbstractMessage diff --git a/packages/feature-toggle/Context.php b/packages/feature-toggle/Context.php index 08639c5c..321a4ffa 100644 --- a/packages/feature-toggle/Context.php +++ b/packages/feature-toggle/Context.php @@ -11,9 +11,6 @@ final class Context implements ContextInterface { private array $data = []; - /** - * {@inheritDoc} - */ public function get(string $key) { if ($this->has($key)) { @@ -23,9 +20,6 @@ public function get(string $key) return null; } - /** - * {@inheritDoc} - */ public function set(string $key, $value): ContextInterface { $this->data[$key] = $value; @@ -33,9 +27,6 @@ public function set(string $key, $value): ContextInterface return $this; } - /** - * {@inheritDoc} - */ public function has(string $key): bool { return \array_key_exists($key, $this->data); diff --git a/packages/feature-toggle/ContextInterface.php b/packages/feature-toggle/ContextInterface.php index 93a8cb8c..53ff0c9d 100644 --- a/packages/feature-toggle/ContextInterface.php +++ b/packages/feature-toggle/ContextInterface.php @@ -9,14 +9,8 @@ */ interface ContextInterface { - /** - * @return mixed - */ public function get(string $key); - /** - * @param mixed $value - */ public function set(string $key, $value): self; public function has(string $key): bool; diff --git a/packages/feature-toggle/Exception/FeatureToggleException.php b/packages/feature-toggle/Exception/FeatureToggleException.php index 80da7356..f4336826 100644 --- a/packages/feature-toggle/Exception/FeatureToggleException.php +++ b/packages/feature-toggle/Exception/FeatureToggleException.php @@ -4,11 +4,7 @@ namespace SonsOfPHP\Component\FeatureToggle\Exception; -use Exception; - /** * @author Joshua Estes */ -class FeatureToggleException extends Exception -{ -} +class FeatureToggleException extends \Exception {} diff --git a/packages/feature-toggle/Feature.php b/packages/feature-toggle/Feature.php index 76607727..d3646969 100644 --- a/packages/feature-toggle/Feature.php +++ b/packages/feature-toggle/Feature.php @@ -20,17 +20,11 @@ public function __construct(string $key, ToggleInterface $toggle) $this->toggle = $toggle; } - /** - * {@inheritDoc} - */ public function getKey(): string { return $this->key; } - /** - * {@inheritDoc} - */ public function isEnabled(ContextInterface $context): bool { return $this->toggle->isEnabled($context); diff --git a/packages/feature-toggle/Provider/InMemoryFeatureToggleProvider.php b/packages/feature-toggle/Provider/InMemoryFeatureToggleProvider.php index 804648de..fad0913a 100644 --- a/packages/feature-toggle/Provider/InMemoryFeatureToggleProvider.php +++ b/packages/feature-toggle/Provider/InMemoryFeatureToggleProvider.php @@ -25,9 +25,6 @@ public function addFeature(FeatureInterface $feature): void $this->features[] = $feature; } - /** - * {@inheritDoc} - */ public function getFeatures(): iterable { yield from $this->features; diff --git a/packages/feature-toggle/Toggle/AlwaysDisabledToggle.php b/packages/feature-toggle/Toggle/AlwaysDisabledToggle.php index b5315f73..bccb91fc 100644 --- a/packages/feature-toggle/Toggle/AlwaysDisabledToggle.php +++ b/packages/feature-toggle/Toggle/AlwaysDisabledToggle.php @@ -14,9 +14,6 @@ */ class AlwaysDisabledToggle implements ToggleInterface { - /** - * {@inheritDoc} - */ public function isEnabled(ContextInterface $context): bool { return false; diff --git a/packages/feature-toggle/Toggle/AlwaysEnabledToggle.php b/packages/feature-toggle/Toggle/AlwaysEnabledToggle.php index e69777e3..cebf5d12 100644 --- a/packages/feature-toggle/Toggle/AlwaysEnabledToggle.php +++ b/packages/feature-toggle/Toggle/AlwaysEnabledToggle.php @@ -14,9 +14,6 @@ */ class AlwaysEnabledToggle implements ToggleInterface { - /** - * {@inheritDoc} - */ public function isEnabled(ContextInterface $context): bool { return true; diff --git a/packages/json/Json.php b/packages/json/Json.php index 0b89b7f7..88d11ec6 100644 --- a/packages/json/Json.php +++ b/packages/json/Json.php @@ -37,7 +37,7 @@ class Json private JsonDecoder $decoder; private JsonEncoder $encoder; - public function __construct(?JsonEncoder $encoder = null, ?JsonDecoder $decoder = null) + public function __construct(JsonEncoder $encoder = null, JsonDecoder $decoder = null) { $this->encoder = $encoder ?? new JsonEncoder(); $this->decoder = $decoder ?? new JsonDecoder(); @@ -53,12 +53,12 @@ public function getDecoder(): JsonDecoder return $this->decoder; } - public static function encode($value, ?int $flags = null, ?int $depth = null): string + public static function encode($value, int $flags = null, int $depth = null): string { return (new JsonEncoder($flags, $depth))->encode($value); } - public static function decode(string $json, ?bool $associative = null, ?int $depth = null, ?int $flags = null) + public static function decode(string $json, bool $associative = null, int $depth = null, int $flags = null) { return (new JsonDecoder($associative, $depth, $flags))->decode($json); } diff --git a/packages/json/JsonDecoder.php b/packages/json/JsonDecoder.php index 5b9cb2d2..c668e2fe 100644 --- a/packages/json/JsonDecoder.php +++ b/packages/json/JsonDecoder.php @@ -11,7 +11,7 @@ */ class JsonDecoder extends AbstractEncoderDecoder { - public function __construct(?bool $associative = null, ?int $depth = null, ?int $flags = null) + public function __construct(bool $associative = null, int $depth = null, int $flags = null) { parent::__construct($flags, $depth); diff --git a/packages/json/JsonException.php b/packages/json/JsonException.php index 5ec2b7a8..cf1a49cc 100644 --- a/packages/json/JsonException.php +++ b/packages/json/JsonException.php @@ -4,11 +4,7 @@ namespace SonsOfPHP\Component\Json; -use Exception; - /** * @author Joshua Estes */ -class JsonException extends Exception -{ -} +class JsonException extends \Exception {} diff --git a/packages/json/JsonReader.php b/packages/json/JsonReader.php index bdb06143..e940d8ca 100644 --- a/packages/json/JsonReader.php +++ b/packages/json/JsonReader.php @@ -13,12 +13,12 @@ class JsonReader { private JsonDecoder $decoder; - public function __construct(?JsonDecoder $decoder = null) + public function __construct(JsonDecoder $decoder = null) { $this->decoder = $decoder ?? new JsonDecoder(); } - public function read(string $filename, ?bool $associative = null, ?int $depth = null, ?int $flags = null): array + public function read(string $filename, bool $associative = null, int $depth = null, int $flags = null): array { if (!is_readable($filename)) { throw new JsonException(sprintf('The file "%s" does not exist or cannot be read', $filename)); diff --git a/packages/json/JsonWriter.php b/packages/json/JsonWriter.php index c3c5f35d..d9e82ad3 100644 --- a/packages/json/JsonWriter.php +++ b/packages/json/JsonWriter.php @@ -11,12 +11,12 @@ class JsonWriter { private JsonEncoder $encoder; - public function __construct(?JsonEncoder $encoder = null) + public function __construct(JsonEncoder $encoder = null) { $this->encoder = $encoder ?? new JsonEncoder(); } - public function write(string $filename, $value, ?int $depth = null, ?int $flags = null) + public function write(string $filename, $value, int $depth = null, int $flags = null) { $encoder = $this->encoder; diff --git a/packages/json/Tests/JsonDecoderTest.php b/packages/json/Tests/JsonDecoderTest.php index 7723d942..71a056ed 100644 --- a/packages/json/Tests/JsonDecoderTest.php +++ b/packages/json/Tests/JsonDecoderTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\Json\Tests; use PHPUnit\Framework\TestCase; -use ReflectionObject; use SonsOfPHP\Component\Json\JsonDecoder; use SonsOfPHP\Component\Json\JsonException; @@ -23,7 +22,7 @@ final class JsonDecoderTest extends TestCase public function testConstructCanReturnArray(): void { $decoder = new JsonDecoder(true); - $ref = new ReflectionObject($decoder); + $ref = new \ReflectionObject($decoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -59,7 +58,7 @@ public function testWithoutFlagsReturnsNewObject(): void public function testWithoutFlagsDoesntRemoveMoreThanItShould(): void { $decoder = new JsonDecoder(); - $ref = new ReflectionObject($decoder); + $ref = new \ReflectionObject($decoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -80,7 +79,7 @@ public function testWithoutFlagsDoesntRemoveMoreThanItShould(): void public function testWithoutFlagsRemovesFlag(): void { $decoder = new JsonDecoder(); - $ref = new ReflectionObject($decoder); + $ref = new \ReflectionObject($decoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -97,7 +96,7 @@ public function testWithoutFlagsRemovesFlag(): void public function testAsArrayAddsCorrectFlag(): void { $decoder = new JsonDecoder(); - $ref = new ReflectionObject($decoder); + $ref = new \ReflectionObject($decoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -111,7 +110,7 @@ public function testAsArrayAddsCorrectFlag(): void public function testChangingDepthActuallyChangesDepth(): void { $decoder = new JsonDecoder(); - $ref = new ReflectionObject($decoder); + $ref = new \ReflectionObject($decoder); $prop = $ref->getProperty('depth'); $prop->setAccessible(true); diff --git a/packages/json/Tests/JsonEncoderTest.php b/packages/json/Tests/JsonEncoderTest.php index 2988388c..c0dece76 100644 --- a/packages/json/Tests/JsonEncoderTest.php +++ b/packages/json/Tests/JsonEncoderTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\Json\Tests; use PHPUnit\Framework\TestCase; -use ReflectionObject; use SonsOfPHP\Component\Json\JsonEncoder; use SonsOfPHP\Component\Json\JsonException; @@ -48,7 +47,7 @@ public function testWithoutFlagsReturnsNewObject(): void public function testWithoutFlagsDoesntRemoveMoreThanItShould(): void { $encoder = new JsonEncoder(); - $ref = new ReflectionObject($encoder); + $ref = new \ReflectionObject($encoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -70,7 +69,7 @@ public function testWithoutFlagsDoesntRemoveMoreThanItShould(): void public function testWithoutFlagsRemovesFlag(): void { $encoder = new JsonEncoder(); - $ref = new ReflectionObject($encoder); + $ref = new \ReflectionObject($encoder); $prop = $ref->getProperty('flags'); $prop->setAccessible(true); @@ -87,7 +86,7 @@ public function testWithoutFlagsRemovesFlag(): void public function testChangingDepthActuallyChangesDepth(): void { $encoder = new JsonEncoder(); - $ref = new ReflectionObject($encoder); + $ref = new \ReflectionObject($encoder); $prop = $ref->getProperty('depth'); $prop->setAccessible(true); diff --git a/packages/money/Amount.php b/packages/money/Amount.php index 3935f827..d0d65e26 100644 --- a/packages/money/Amount.php +++ b/packages/money/Amount.php @@ -26,9 +26,6 @@ final class Amount implements AmountInterface { private string $amount; - /** - * @param mixed $amount - */ public function __construct($amount) { $this->amount = (string) $amount; @@ -42,145 +39,91 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public function toString(): string { return $this->amount; } - /** - * {@inheritDoc} - */ public function toInt(): int { return (int) $this->amount; } - /** - * {@inheritDoc} - */ public function toFloat(): float { return (float) $this->amount; } - /** - * {@inheritDoc} - */ public function getAmount(): string { return $this->amount; } - /** - * {@inheritDoc} - */ public function with(AmountOperatorInterface $operator): AmountInterface { return $operator->apply($this); } - /** - * {@inheritDoc} - */ public function query(AmountQueryInterface $query) { return $query->queryFrom($this); } - /** - * {@inheritDoc} - */ public function add(AmountInterface $amount): AmountInterface { return $this->with(new AddAmountOperator($amount)); } - /** - * {@inheritDoc} - */ public function subtract(AmountInterface $amount): AmountInterface { return $this->with(new SubtractAmountOperator($amount)); } - /** - * {@inheritDoc} - */ public function multiply($multiplier): AmountInterface { return $this->with(new MultiplyAmountOperator($multiplier)); } - /** - * {@inheritDoc} - */ public function divide($divisor): AmountInterface { return $this->with(new DivideAmountOperator($divisor)); } - /** - * {@inheritDoc} - */ public function isEqualTo(AmountInterface $amount): bool { return $this->query(new IsEqualToAmountQuery($amount)); } - /** - * {@inheritDoc} - */ public function isGreaterThan(AmountInterface $amount): bool { return $this->query(new IsGreaterThanAmountQuery($amount)); } - /** - * {@inheritDoc} - */ public function isGreaterThanOrEqualTo(AmountInterface $amount): bool { return $this->query(new IsGreaterThanOrEqualToAmountQuery($amount)); } - /** - * {@inheritDoc} - */ public function isLessThan(AmountInterface $amount): bool { return $this->query(new IsLessThanAmountQuery($amount)); } - /** - * {@inheritDoc} - */ public function isLessThanOrEqualTo(AmountInterface $amount): bool { return $this->query(new IsLessThanOrEqualToAmountQuery($amount)); } - /** - * {@inheritDoc} - */ public function isNegative(): bool { return $this->query(new IsNegativeAmountQuery()); } - /** - * {@inheritDoc} - */ public function isPositive(): bool { return $this->query(new IsPositiveAmountQuery()); } - /** - * {@inheritDoc} - */ public function isZero(): bool { return $this->query(new IsZeroAmountQuery()); diff --git a/packages/money/AmountInterface.php b/packages/money/AmountInterface.php index 66555cf5..2d590862 100644 --- a/packages/money/AmountInterface.php +++ b/packages/money/AmountInterface.php @@ -30,8 +30,6 @@ public function with(AmountOperatorInterface $operator): self; /** * Allows you to ask different questions about the amount and get * different results returned to you. - * - * @return mixed */ public function query(AmountQueryInterface $query); @@ -73,15 +71,11 @@ public function subtract(self $amount): self; /** * Multiply amount by a specific amount. - * - * @param mixed $multiplier */ public function multiply($multiplier): self; /** * Divide the amount by a specific amount. - * - * @param mixed $divisor */ public function divide($divisor): self; diff --git a/packages/money/Currency.php b/packages/money/Currency.php index 9abbcf38..b384e1e1 100644 --- a/packages/money/Currency.php +++ b/packages/money/Currency.php @@ -16,11 +16,7 @@ final class Currency implements CurrencyInterface private ?int $numericCode; private ?int $minorUnit; - /** - * @param int $numericCode - * @param int $minorUnit - */ - public function __construct(string $currencyCode, ?int $numericCode = null, ?int $minorUnit = null) + public function __construct(string $currencyCode, int $numericCode = null, int $minorUnit = null) { $this->currencyCode = strtoupper($currencyCode); $this->numericCode = $numericCode; @@ -50,41 +46,26 @@ public static function __callStatic(string $currencyCode, array $args): Currency return new static($currencyCode, $numericCode, $minorUnit); } - /** - * {@inheritDoc} - */ public function query(CurrencyQueryInterface $query) { return $query->queryFrom($this); } - /** - * {@inheritDoc} - */ public function getCurrencyCode(): string { return $this->currencyCode; } - /** - * {@inheritDoc} - */ public function getNumericCode(): ?int { return $this->numericCode; } - /** - * {@inheritDoc} - */ public function getMinorUnit(): ?int { return $this->minorUnit; } - /** - * {@inheritDoc} - */ public function isEqualTo(CurrencyInterface $currency): bool { return $this->query(new IsEqualToCurrencyQuery($currency)); diff --git a/packages/money/CurrencyInterface.php b/packages/money/CurrencyInterface.php index 8a328c96..c89ddbb9 100644 --- a/packages/money/CurrencyInterface.php +++ b/packages/money/CurrencyInterface.php @@ -48,8 +48,5 @@ public function getMinorUnit(): ?int; */ public function isEqualTo(self $currency): bool; - /** - * @return mixed - */ public function query(CurrencyQueryInterface $query); } diff --git a/packages/money/CurrencyProvider/AbstractCurrencyProvider.php b/packages/money/CurrencyProvider/AbstractCurrencyProvider.php index ee695e6e..87dbae0a 100644 --- a/packages/money/CurrencyProvider/AbstractCurrencyProvider.php +++ b/packages/money/CurrencyProvider/AbstractCurrencyProvider.php @@ -14,25 +14,16 @@ */ abstract class AbstractCurrencyProvider implements CurrencyProviderInterface { - /** - * {@inheritDoc} - */ public function query(CurrencyProviderQueryInterface $query) { return $query->queryFrom($this); } - /** - * {@inheritDoc} - */ public function hasCurrency($currency): bool { return $this->query(new HasCurrencyQuery($currency)); } - /** - * {@inheritDoc} - */ public function getCurrency($currency): CurrencyInterface { return $this->query(new GetCurrencyQuery($currency)); diff --git a/packages/money/CurrencyProvider/ChainCurrencyProvider.php b/packages/money/CurrencyProvider/ChainCurrencyProvider.php index 6e87e086..27179923 100644 --- a/packages/money/CurrencyProvider/ChainCurrencyProvider.php +++ b/packages/money/CurrencyProvider/ChainCurrencyProvider.php @@ -25,9 +25,6 @@ public function addProvider(CurrencyProviderInterface $provider): void $this->providers[] = $provider; } - /** - * {@inheritDoc} - */ public function getCurrencies(): iterable { foreach ($this->providers as $provider) { diff --git a/packages/money/CurrencyProvider/CurrencyProvider.php b/packages/money/CurrencyProvider/CurrencyProvider.php index f4e9394b..9d1edd2f 100644 --- a/packages/money/CurrencyProvider/CurrencyProvider.php +++ b/packages/money/CurrencyProvider/CurrencyProvider.php @@ -13,9 +13,6 @@ */ final class CurrencyProvider extends AbstractCurrencyProvider { - /** - * {@inheritDoc} - */ public function getCurrencies(): iterable { // @todo Add all the currencies diff --git a/packages/money/CurrencyProvider/CurrencyProviderInterface.php b/packages/money/CurrencyProvider/CurrencyProviderInterface.php index c36c5986..cd09bc9c 100644 --- a/packages/money/CurrencyProvider/CurrencyProviderInterface.php +++ b/packages/money/CurrencyProvider/CurrencyProviderInterface.php @@ -53,8 +53,6 @@ public function getCurrency($currency): CurrencyInterface; * method will allow you to do this. * * @throw MoneyException - * - * @return mixed */ public function query(CurrencyProviderQueryInterface $query); } diff --git a/packages/money/CurrencyProvider/XCurrencyProvider.php b/packages/money/CurrencyProvider/XCurrencyProvider.php index c4f2c017..91c4216b 100644 --- a/packages/money/CurrencyProvider/XCurrencyProvider.php +++ b/packages/money/CurrencyProvider/XCurrencyProvider.php @@ -11,9 +11,6 @@ */ final class XCurrencyProvider extends AbstractCurrencyProvider { - /** - * {@inheritDoc} - */ public function getCurrencies(): iterable { yield Currency::XAF(950, 0); diff --git a/packages/money/Exception/ArithmeticException.php b/packages/money/Exception/ArithmeticException.php index b687fd9e..f929511b 100644 --- a/packages/money/Exception/ArithmeticException.php +++ b/packages/money/Exception/ArithmeticException.php @@ -13,6 +13,4 @@ * * @author Joshua Estes */ -class ArithmeticException extends Exception -{ -} +class ArithmeticException extends \Exception {} diff --git a/packages/money/Exception/MoneyException.php b/packages/money/Exception/MoneyException.php index f841f013..67ffac7d 100644 --- a/packages/money/Exception/MoneyException.php +++ b/packages/money/Exception/MoneyException.php @@ -11,6 +11,4 @@ * * @author Joshua Estes */ -class MoneyException extends Exception -{ -} +class MoneyException extends \Exception {} diff --git a/packages/money/Exception/UnknownCurrencyException.php b/packages/money/Exception/UnknownCurrencyException.php index f794125b..51501995 100644 --- a/packages/money/Exception/UnknownCurrencyException.php +++ b/packages/money/Exception/UnknownCurrencyException.php @@ -4,11 +4,7 @@ namespace SonsOfPHP\Component\Money\Exception; -use Exception; - /** * @author Joshua Estes */ -class UnknownCurrencyException extends Exception -{ -} +class UnknownCurrencyException extends \Exception {} diff --git a/packages/money/Money.php b/packages/money/Money.php index fce342d3..7fb8f243 100644 --- a/packages/money/Money.php +++ b/packages/money/Money.php @@ -27,9 +27,6 @@ final class Money implements MoneyInterface private AmountInterface $amount; private CurrencyInterface $currency; - /** - * @param mixed $amount - */ public function __construct($amount, CurrencyInterface $currency) { if (!$amount instanceof AmountInterface) { @@ -72,129 +69,81 @@ public function compare(MoneyInterface $money): int return 0; } - /** - * {@inheritDoc} - */ public function with(MoneyOperatorInterface $operator): MoneyInterface { return $operator->apply($this); } - /** - * {@inheritDoc} - */ public function query(MoneyQueryInterface $query) { return $query->queryFrom($this); } - /** - * {@inheritDoc} - */ public function getAmount(): AmountInterface { return $this->amount; } - /** - * {@inheritDoc} - */ public function getCurrency(): CurrencyInterface { return $this->currency; } - /** - * {@inheritDoc} - */ public function isEqualTo(MoneyInterface $money): bool { return $this->query(new IsEqualToMoneyQuery($money)); } - /** - * {@inheritDoc} - */ public function isGreaterThan(MoneyInterface $money): bool { return $this->query(new IsGreaterThanMoneyQuery($money)); } - /** - * {@inheritDoc} - */ public function isGreaterThanOrEqualTo(MoneyInterface $money): bool { return $this->query(new IsGreaterThanOrEqualToMoneyQuery($money)); } - /** - * {@inheritDoc} - */ public function isLessThan(MoneyInterface $money): bool { return $this->query(new IsLessThanMoneyQuery($money)); } - /** - * {@inheritDoc} - */ public function isLessThanOrEqualTo(MoneyInterface $money): bool { return $this->query(new IsLessThanOrEqualToMoneyQuery($money)); } - /** - * {@inheritDoc} - */ public function isNegative(): bool { return $this->query(new IsNegativeMoneyQuery()); } - /** - * {@inheritDoc} - */ public function isPositive(): bool { return $this->query(new IsPositiveMoneyQuery()); } - /** - * {@inheritDoc} - */ public function isZero(): bool { return $this->query(new IsZeroMoneyQuery()); } - /** - * {@inheritDoc} - */ public function add(MoneyInterface $money): MoneyInterface { return $this->with(new AddMoneyOperator($money)); } - /** - * {@inheritDoc} - */ public function subtract(MoneyInterface $money): MoneyInterface { return $this->with(new SubtractMoneyOperator($money)); } - /** - * {@inheritDoc} - */ public function multiply($multiplier): MoneyInterface { return $this->with(new MultiplyMoneyOperator($multiplier)); } - /** - * {@inheritDoc} - */ public function divide($divisor): MoneyInterface { return $this->with(new DivideMoneyOperator($divisor)); diff --git a/packages/money/MoneyInterface.php b/packages/money/MoneyInterface.php index 98ae2bda..a4881a01 100644 --- a/packages/money/MoneyInterface.php +++ b/packages/money/MoneyInterface.php @@ -22,9 +22,6 @@ public function getCurrency(): CurrencyInterface; public function with(MoneyOperatorInterface $operator): self; - /** - * @return mixed - */ public function query(MoneyQueryInterface $query); public function isEqualTo(self $money): bool; diff --git a/packages/money/Operator/Amount/AddAmountOperator.php b/packages/money/Operator/Amount/AddAmountOperator.php index 203ed3c1..153c4148 100644 --- a/packages/money/Operator/Amount/AddAmountOperator.php +++ b/packages/money/Operator/Amount/AddAmountOperator.php @@ -19,9 +19,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function apply(AmountInterface $amount): AmountInterface { return new Amount($amount->toFloat() + $this->amount->toFloat()); diff --git a/packages/money/Operator/Amount/DivideAmountOperator.php b/packages/money/Operator/Amount/DivideAmountOperator.php index 1ad21a74..c5b82ebd 100644 --- a/packages/money/Operator/Amount/DivideAmountOperator.php +++ b/packages/money/Operator/Amount/DivideAmountOperator.php @@ -19,9 +19,6 @@ public function __construct($divisor) $this->divisor = $divisor; } - /** - * {@inheritDoc} - */ public function apply(AmountInterface $amount): AmountInterface { return new Amount($amount->getAmount() / $this->divisor); diff --git a/packages/money/Operator/Amount/MultiplyAmountOperator.php b/packages/money/Operator/Amount/MultiplyAmountOperator.php index 1fa39500..217dafd6 100644 --- a/packages/money/Operator/Amount/MultiplyAmountOperator.php +++ b/packages/money/Operator/Amount/MultiplyAmountOperator.php @@ -19,9 +19,6 @@ public function __construct($multiplier) $this->multiplier = $multiplier; } - /** - * {@inheritDoc} - */ public function apply(AmountInterface $amount): AmountInterface { return new Amount($amount->getAmount() * $this->multiplier); diff --git a/packages/money/Operator/Amount/SubtractAmountOperator.php b/packages/money/Operator/Amount/SubtractAmountOperator.php index 91ef1630..86de4083 100644 --- a/packages/money/Operator/Amount/SubtractAmountOperator.php +++ b/packages/money/Operator/Amount/SubtractAmountOperator.php @@ -19,9 +19,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function apply(AmountInterface $amount): AmountInterface { return new Amount($amount->toFloat() - $this->amount->toFloat()); diff --git a/packages/money/Operator/Money/AddMoneyOperator.php b/packages/money/Operator/Money/AddMoneyOperator.php index d5bad6cb..7682418c 100644 --- a/packages/money/Operator/Money/AddMoneyOperator.php +++ b/packages/money/Operator/Money/AddMoneyOperator.php @@ -20,9 +20,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function apply(MoneyInterface $money): MoneyInterface { if (!$this->money->getCurrency()->isEqualTo($money->getCurrency())) { diff --git a/packages/money/Operator/Money/DivideMoneyOperator.php b/packages/money/Operator/Money/DivideMoneyOperator.php index 9bb05d61..fbb5c3af 100644 --- a/packages/money/Operator/Money/DivideMoneyOperator.php +++ b/packages/money/Operator/Money/DivideMoneyOperator.php @@ -19,9 +19,6 @@ public function __construct($divisor) $this->divisor = $divisor; } - /** - * {@inheritDoc} - */ public function apply(MoneyInterface $money): MoneyInterface { $amount = $money->getAmount()->divide($this->divisor); diff --git a/packages/money/Operator/Money/MultiplyMoneyOperator.php b/packages/money/Operator/Money/MultiplyMoneyOperator.php index c4b36f75..a0d57984 100644 --- a/packages/money/Operator/Money/MultiplyMoneyOperator.php +++ b/packages/money/Operator/Money/MultiplyMoneyOperator.php @@ -19,9 +19,6 @@ public function __construct($multiplier) $this->multiplier = $multiplier; } - /** - * {@inheritDoc} - */ public function apply(MoneyInterface $money): MoneyInterface { $amount = $money->getAmount()->multiply($this->multiplier); diff --git a/packages/money/Operator/Money/SubtractMoneyOperator.php b/packages/money/Operator/Money/SubtractMoneyOperator.php index 2a24ac76..e35ce0e1 100644 --- a/packages/money/Operator/Money/SubtractMoneyOperator.php +++ b/packages/money/Operator/Money/SubtractMoneyOperator.php @@ -20,9 +20,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function apply(MoneyInterface $money): MoneyInterface { if (!$this->money->getCurrency()->isEqualTo($money->getCurrency())) { diff --git a/packages/money/Query/Amount/AmountQueryInterface.php b/packages/money/Query/Amount/AmountQueryInterface.php index 55adc8a6..64d72009 100644 --- a/packages/money/Query/Amount/AmountQueryInterface.php +++ b/packages/money/Query/Amount/AmountQueryInterface.php @@ -15,8 +15,6 @@ interface AmountQueryInterface extends QueryInterface { /** * @throws MoneyException - * - * @return mixed */ public function queryFrom(AmountInterface $amount); } diff --git a/packages/money/Query/Amount/IsEqualToAmountQuery.php b/packages/money/Query/Amount/IsEqualToAmountQuery.php index 28e90d60..0ed67802 100644 --- a/packages/money/Query/Amount/IsEqualToAmountQuery.php +++ b/packages/money/Query/Amount/IsEqualToAmountQuery.php @@ -18,9 +18,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() === $this->amount->getAmount(); diff --git a/packages/money/Query/Amount/IsGreaterThanAmountQuery.php b/packages/money/Query/Amount/IsGreaterThanAmountQuery.php index d3c33fe7..83068f36 100644 --- a/packages/money/Query/Amount/IsGreaterThanAmountQuery.php +++ b/packages/money/Query/Amount/IsGreaterThanAmountQuery.php @@ -18,9 +18,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() > $this->amount->getAmount(); diff --git a/packages/money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php b/packages/money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php index 0a80c6d1..ce298398 100644 --- a/packages/money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php +++ b/packages/money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php @@ -18,9 +18,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() >= $this->amount->getAmount(); diff --git a/packages/money/Query/Amount/IsLessThanAmountQuery.php b/packages/money/Query/Amount/IsLessThanAmountQuery.php index f85c8ecd..d5e0740d 100644 --- a/packages/money/Query/Amount/IsLessThanAmountQuery.php +++ b/packages/money/Query/Amount/IsLessThanAmountQuery.php @@ -18,9 +18,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() < $this->amount->getAmount(); diff --git a/packages/money/Query/Amount/IsLessThanOrEqualToAmountQuery.php b/packages/money/Query/Amount/IsLessThanOrEqualToAmountQuery.php index caec9010..ed393a86 100644 --- a/packages/money/Query/Amount/IsLessThanOrEqualToAmountQuery.php +++ b/packages/money/Query/Amount/IsLessThanOrEqualToAmountQuery.php @@ -18,9 +18,6 @@ public function __construct(AmountInterface $amount) $this->amount = $amount; } - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() <= $this->amount->getAmount(); diff --git a/packages/money/Query/Amount/IsNegativeAmountQuery.php b/packages/money/Query/Amount/IsNegativeAmountQuery.php index a5db416f..8ef5f27f 100644 --- a/packages/money/Query/Amount/IsNegativeAmountQuery.php +++ b/packages/money/Query/Amount/IsNegativeAmountQuery.php @@ -11,9 +11,6 @@ */ class IsNegativeAmountQuery implements AmountQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() < 0; diff --git a/packages/money/Query/Amount/IsPositiveAmountQuery.php b/packages/money/Query/Amount/IsPositiveAmountQuery.php index 9a2cd0c7..577603a1 100644 --- a/packages/money/Query/Amount/IsPositiveAmountQuery.php +++ b/packages/money/Query/Amount/IsPositiveAmountQuery.php @@ -11,9 +11,6 @@ */ class IsPositiveAmountQuery implements AmountQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return $amount->getAmount() > 0; diff --git a/packages/money/Query/Amount/IsZeroAmountQuery.php b/packages/money/Query/Amount/IsZeroAmountQuery.php index f1f29d7e..9c17f271 100644 --- a/packages/money/Query/Amount/IsZeroAmountQuery.php +++ b/packages/money/Query/Amount/IsZeroAmountQuery.php @@ -11,9 +11,6 @@ */ class IsZeroAmountQuery implements AmountQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(AmountInterface $amount) { return 0 == $amount->getAmount(); diff --git a/packages/money/Query/Currency/CurrencyQueryInterface.php b/packages/money/Query/Currency/CurrencyQueryInterface.php index 39c0b27a..94f73036 100644 --- a/packages/money/Query/Currency/CurrencyQueryInterface.php +++ b/packages/money/Query/Currency/CurrencyQueryInterface.php @@ -15,8 +15,6 @@ interface CurrencyQueryInterface extends QueryInterface { /** * @throws MoneyException - * - * @return mixed */ public function queryFrom(CurrencyInterface $currency); } diff --git a/packages/money/Query/Currency/IsEqualToCurrencyQuery.php b/packages/money/Query/Currency/IsEqualToCurrencyQuery.php index 31762656..9cb1c1b2 100644 --- a/packages/money/Query/Currency/IsEqualToCurrencyQuery.php +++ b/packages/money/Query/Currency/IsEqualToCurrencyQuery.php @@ -18,9 +18,6 @@ public function __construct(CurrencyInterface $currency) $this->currency = $currency; } - /** - * {@inheritDoc} - */ public function queryFrom(CurrencyInterface $currency) { return $currency->getCurrencyCode() === $this->currency->getCurrencyCode(); diff --git a/packages/money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php b/packages/money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php index 969e3882..27f0e18e 100644 --- a/packages/money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php +++ b/packages/money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php @@ -15,8 +15,6 @@ interface CurrencyProviderQueryInterface extends QueryInterface { /** * @throws MoneyException - * - * @return mixed */ public function queryFrom(CurrencyProviderInterface $provider); } diff --git a/packages/money/Query/CurrencyProvider/GetCurrencyQuery.php b/packages/money/Query/CurrencyProvider/GetCurrencyQuery.php index da46b645..b4b39ac0 100644 --- a/packages/money/Query/CurrencyProvider/GetCurrencyQuery.php +++ b/packages/money/Query/CurrencyProvider/GetCurrencyQuery.php @@ -33,9 +33,6 @@ public function __construct($currency) throw new MoneyException('Value Error'); } - /** - * {@inheritDoc} - */ public function queryFrom(CurrencyProviderInterface $provider) { foreach ($provider->getCurrencies() as $currency) { diff --git a/packages/money/Query/CurrencyProvider/HasCurrencyQuery.php b/packages/money/Query/CurrencyProvider/HasCurrencyQuery.php index faea1bcf..cf289917 100644 --- a/packages/money/Query/CurrencyProvider/HasCurrencyQuery.php +++ b/packages/money/Query/CurrencyProvider/HasCurrencyQuery.php @@ -33,9 +33,6 @@ public function __construct($currency) throw new MoneyException('Value Error'); } - /** - * {@inheritDoc} - */ public function queryFrom(CurrencyProviderInterface $provider) { foreach ($provider->getCurrencies() as $currency) { diff --git a/packages/money/Query/Money/IsEqualToMoneyQuery.php b/packages/money/Query/Money/IsEqualToMoneyQuery.php index 467fb170..e5be0531 100644 --- a/packages/money/Query/Money/IsEqualToMoneyQuery.php +++ b/packages/money/Query/Money/IsEqualToMoneyQuery.php @@ -18,9 +18,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { return $this->money->getAmount()->isEqualTo($money->getAmount()) && $this->money->getCurrency()->isEqualTo($money->getCurrency()); diff --git a/packages/money/Query/Money/IsGreaterThanMoneyQuery.php b/packages/money/Query/Money/IsGreaterThanMoneyQuery.php index 51326a74..b8f312ba 100644 --- a/packages/money/Query/Money/IsGreaterThanMoneyQuery.php +++ b/packages/money/Query/Money/IsGreaterThanMoneyQuery.php @@ -19,9 +19,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { if (!$money->getCurrency()->isEqualTo($this->money->getCurrency())) { diff --git a/packages/money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php b/packages/money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php index ce67c8cb..d8f87449 100644 --- a/packages/money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php +++ b/packages/money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php @@ -19,9 +19,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { if (!$money->getCurrency()->isEqualTo($this->money->getCurrency())) { diff --git a/packages/money/Query/Money/IsLessThanMoneyQuery.php b/packages/money/Query/Money/IsLessThanMoneyQuery.php index aa1a507f..09bd36d6 100644 --- a/packages/money/Query/Money/IsLessThanMoneyQuery.php +++ b/packages/money/Query/Money/IsLessThanMoneyQuery.php @@ -19,9 +19,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { if (!$money->getCurrency()->isEqualTo($this->money->getCurrency())) { diff --git a/packages/money/Query/Money/IsLessThanOrEqualToMoneyQuery.php b/packages/money/Query/Money/IsLessThanOrEqualToMoneyQuery.php index fc29f616..95748d0c 100644 --- a/packages/money/Query/Money/IsLessThanOrEqualToMoneyQuery.php +++ b/packages/money/Query/Money/IsLessThanOrEqualToMoneyQuery.php @@ -19,9 +19,6 @@ public function __construct(MoneyInterface $money) $this->money = $money; } - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { if (!$money->getCurrency()->isEqualTo($this->money->getCurrency())) { diff --git a/packages/money/Query/Money/IsNegativeMoneyQuery.php b/packages/money/Query/Money/IsNegativeMoneyQuery.php index 1e120815..7096b1a4 100644 --- a/packages/money/Query/Money/IsNegativeMoneyQuery.php +++ b/packages/money/Query/Money/IsNegativeMoneyQuery.php @@ -11,9 +11,6 @@ */ class IsNegativeMoneyQuery implements MoneyQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { return $money->getAmount()->isNegative(); diff --git a/packages/money/Query/Money/IsPositiveMoneyQuery.php b/packages/money/Query/Money/IsPositiveMoneyQuery.php index 87cbcf97..43cc9e52 100644 --- a/packages/money/Query/Money/IsPositiveMoneyQuery.php +++ b/packages/money/Query/Money/IsPositiveMoneyQuery.php @@ -11,9 +11,6 @@ */ class IsPositiveMoneyQuery implements MoneyQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { return $money->getAmount()->isPositive(); diff --git a/packages/money/Query/Money/IsZeroMoneyQuery.php b/packages/money/Query/Money/IsZeroMoneyQuery.php index 053f1cac..2f235f33 100644 --- a/packages/money/Query/Money/IsZeroMoneyQuery.php +++ b/packages/money/Query/Money/IsZeroMoneyQuery.php @@ -11,9 +11,6 @@ */ class IsZeroMoneyQuery implements MoneyQueryInterface { - /** - * {@inheritDoc} - */ public function queryFrom(MoneyInterface $money) { return $money->getAmount()->isZero(); diff --git a/packages/money/Query/Money/MoneyQueryInterface.php b/packages/money/Query/Money/MoneyQueryInterface.php index 9d1bfa86..afd22840 100644 --- a/packages/money/Query/Money/MoneyQueryInterface.php +++ b/packages/money/Query/Money/MoneyQueryInterface.php @@ -15,8 +15,6 @@ interface MoneyQueryInterface extends QueryInterface { /** * @throws MoneyException - * - * @return mixed */ public function queryFrom(MoneyInterface $money); } diff --git a/packages/version/Exception/VersionException.php b/packages/version/Exception/VersionException.php index 7c549e2b..6e309c1b 100644 --- a/packages/version/Exception/VersionException.php +++ b/packages/version/Exception/VersionException.php @@ -11,6 +11,4 @@ * * @author Joshua Estes */ -class VersionException extends Exception -{ -} +class VersionException extends \Exception {} diff --git a/packages/version/Tests/VersionTest.php b/packages/version/Tests/VersionTest.php index 6bf94bd7..6a14808a 100644 --- a/packages/version/Tests/VersionTest.php +++ b/packages/version/Tests/VersionTest.php @@ -151,7 +151,7 @@ public function testIsEqualTo(): void $this->assertTrue($version->isEqualTo(new Version('1.2.3'))); } - public function validVersions(): iterable + public static function validVersions(): iterable { yield ['0.0.4', 0, 0, 4]; yield ['1.2.3', 1, 2, 3]; @@ -160,14 +160,14 @@ public function validVersions(): iterable yield ['1.1.2+meta', 1, 1, 2, '', 'meta']; } - public function invalidVersions(): iterable + public static function invalidVersions(): iterable { yield ['1.1']; yield ['v1']; yield ['v1.2-4']; } - public function compareVersions(): iterable + public static function compareVersions(): iterable { // Major yield [new Version('1.0.0'), new Version('0.0.0'), 1]; diff --git a/packages/version/Version.php b/packages/version/Version.php index 5bc9a88e..94d057ba 100644 --- a/packages/version/Version.php +++ b/packages/version/Version.php @@ -50,75 +50,51 @@ public function __toString(): string return $this->toString(); } - /** - * {@inheritDoc} - */ public static function from(string $version): VersionInterface { return new static($version); } - /** - * {@inheritDoc} - */ public function toString(): string { $version = sprintf('%d.%d.%d', $this->getMajor(), $this->getMinor(), $this->getPatch()); if ('' !== $this->getPreRelease()) { - $version = $version.'-'.$this->getPreRelease(); + $version = $version . '-' . $this->getPreRelease(); } if ('' !== $this->getBuild()) { - $version = $version.'+'.$this->getBuild(); + $version = $version . '+' . $this->getBuild(); } return $version; } - /** - * {@inheritDoc} - */ public function getMajor(): int { return $this->major; } - /** - * {@inheritDoc} - */ public function getMinor(): int { return $this->minor; } - /** - * {@inheritDoc} - */ public function getPatch(): int { return $this->patch; } - /** - * {@inheritDoc} - */ public function getPreRelease(): ?string { return $this->preRelease; } - /** - * {@inheritDoc} - */ public function getBuild(): ?string { return $this->build; } - /** - * {@inheritDoc} - */ public function compare(VersionInterface $version): int { if ($this->getMajor() > $version->getMajor()) { diff --git a/packages/version/VersionInterface.php b/packages/version/VersionInterface.php index 61a5ad0d..baab3318 100644 --- a/packages/version/VersionInterface.php +++ b/packages/version/VersionInterface.php @@ -44,15 +44,11 @@ public function getPatch(): int; /** * Returns the Pre-release (if any). - * - * @return string */ public function getPreRelease(): ?string; /** * Returns the Build Metadata (if any). - * - * @return string */ public function getBuild(): ?string;