From 353583d8cfad30e82c35550881256b1bddb26b23 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 22 Jan 2022 18:05:19 +0700 Subject: [PATCH 1/3] [Rector] Update to rector 0.12.13, apply parallel, and RemoveUnusedPrivatePropertyRector --- composer.json | 8 ++++++-- rector.php | 8 +++++--- .../src/Internal/DoctrineAnnotationReader.php | 2 +- src/Reactor/src/Traits/NamedTrait.php | 3 --- .../src/Transform/Merge/Inject/InjectBlocks.php | 4 ---- .../src/Transform/Merge/Inject/InjectPHP.php | 4 ---- src/Storage/src/Bucket/ReadableTrait.php | 14 +++++++------- src/Storage/src/Bucket/WritableTrait.php | 12 ++++++------ 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 3a8e795e3..3dd173d81 100644 --- a/composer.json +++ b/composer.json @@ -134,7 +134,7 @@ "mockery/mockery": "^1.3", "phpunit/phpunit": "^8.5|^9.0", "ramsey/uuid": "^3.9", - "rector/rector": "0.12.3", + "rector/rector": "0.12.13", "spiral/broadcast": "^2.0", "spiral/broadcast-ws": "^1.0", "spiral/code-style": "^1.0", @@ -271,7 +271,11 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "composer/package-versions-deprecated": true, + "spiral/composer-publish-plugin": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/rector.php b/rector.php index dc5be0245..ad07c6f72 100644 --- a/rector.php +++ b/rector.php @@ -9,7 +9,6 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -use Spiral\Boot\Bootloader\ConfigurationBootloader; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { @@ -18,14 +17,17 @@ __DIR__ . '/src/*/src', ]); + $parameters->set(Option::PARALLEL, true); $parameters->set(Option::SKIP, [ CountOnNullRector::class, // for PHP 8 RemoveUnusedPromotedPropertyRector::class, - // buggy when remove private property, but filled by construct in the middle of parameter - RemoveUnusedPrivatePropertyRector::class, + RemoveUnusedPrivatePropertyRector::class => [ + // buggy when used in middle of parameter along with RemoveUnusedConstructorParamRector that may cause BC break + __DIR__ . '/src/Console/src/Sequence/CallableSequence.php', + ], RemoveUnusedPrivateMethodRector::class => [ __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', diff --git a/src/Attributes/src/Internal/DoctrineAnnotationReader.php b/src/Attributes/src/Internal/DoctrineAnnotationReader.php index b82aacdce..0f4e6fe10 100644 --- a/src/Attributes/src/Internal/DoctrineAnnotationReader.php +++ b/src/Attributes/src/Internal/DoctrineAnnotationReader.php @@ -120,7 +120,7 @@ private function wrapDoctrineExceptions(\Closure $then): iterable $class = AttributeException::class; } - throw new $class($e->getMessage(), (int)$e->getCode(), $e); + throw new $class($e->getMessage(), $e->getCode(), $e); } } diff --git a/src/Reactor/src/Traits/NamedTrait.php b/src/Reactor/src/Traits/NamedTrait.php index d8c2d1d6f..a82979328 100644 --- a/src/Reactor/src/Traits/NamedTrait.php +++ b/src/Reactor/src/Traits/NamedTrait.php @@ -23,9 +23,6 @@ trait NamedTrait /** * Attention, element name will be automatically classified. - * - * - * @return $this|self */ public function setName(string $name): self { diff --git a/src/Stempler/src/Transform/Merge/Inject/InjectBlocks.php b/src/Stempler/src/Transform/Merge/Inject/InjectBlocks.php index 3bbbc7fad..2cee1a2cb 100644 --- a/src/Stempler/src/Transform/Merge/Inject/InjectBlocks.php +++ b/src/Stempler/src/Transform/Merge/Inject/InjectBlocks.php @@ -27,13 +27,9 @@ final class InjectBlocks implements VisitorInterface /** @var BlockClaims */ private $blocks; - /** @var BlockFetcher */ - private $fetcher; - public function __construct(BlockClaims $blocks) { $this->blocks = $blocks; - $this->fetcher = new BlockFetcher(); } /** diff --git a/src/Stempler/src/Transform/Merge/Inject/InjectPHP.php b/src/Stempler/src/Transform/Merge/Inject/InjectPHP.php index 14047da42..2b5ea042f 100644 --- a/src/Stempler/src/Transform/Merge/Inject/InjectPHP.php +++ b/src/Stempler/src/Transform/Merge/Inject/InjectPHP.php @@ -36,13 +36,9 @@ final class InjectPHP implements VisitorInterface /** @var BlockClaims */ private $blocks; - /** @var BlockFetcher */ - private $fetcher; - public function __construct(BlockClaims $blocks) { $this->blocks = $blocks; - $this->fetcher = new BlockFetcher(); } /** diff --git a/src/Storage/src/Bucket/ReadableTrait.php b/src/Storage/src/Bucket/ReadableTrait.php index 619929c39..5aa3889dc 100644 --- a/src/Storage/src/Bucket/ReadableTrait.php +++ b/src/Storage/src/Bucket/ReadableTrait.php @@ -32,7 +32,7 @@ public function exists(string $pathname): bool try { return $fs->fileExists($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -46,7 +46,7 @@ public function getContents(string $pathname): string try { return $fs->read($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -60,7 +60,7 @@ public function getStream(string $pathname) try { return $fs->readStream($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -74,7 +74,7 @@ public function getLastModified(string $pathname): int try { return $fs->lastModified($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -88,7 +88,7 @@ public function getSize(string $pathname): int try { return $fs->fileSize($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -102,7 +102,7 @@ public function getMimeType(string $pathname): string try { return $fs->mimeType($pathname); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } @@ -119,7 +119,7 @@ public function getVisibility(string $pathname): string $fs->visibility($pathname) ); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } diff --git a/src/Storage/src/Bucket/WritableTrait.php b/src/Storage/src/Bucket/WritableTrait.php index ee29b7c6c..cb4190434 100644 --- a/src/Storage/src/Bucket/WritableTrait.php +++ b/src/Storage/src/Bucket/WritableTrait.php @@ -61,7 +61,7 @@ public function write(string $pathname, $content, array $config = []): FileInter throw new \InvalidArgumentException(\sprintf($message, \get_debug_type($content))); } } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } return $this->file($pathname); @@ -80,7 +80,7 @@ public function setVisibility( try { $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility)); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } return $this->file($pathname); @@ -101,7 +101,7 @@ public function copy( try { $fs->copy($source, $destination, $config); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } return $this->file($destination); @@ -125,7 +125,7 @@ public function move( try { $fs->move($source, $destination, $config); } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } return $this->file($destination); @@ -152,7 +152,7 @@ public function delete(string $pathname, bool $clean = false): void $this->deleteEmptyDirectories($this->getParentDirectory($pathname)); } } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } abstract protected function getOperator(): FilesystemOperator; @@ -220,7 +220,7 @@ private function deleteEmptyDirectories(string $directory): void $this->deleteEmptyDirectories($this->getParentDirectory($directory)); } } catch (FilesystemException $e) { - throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); + throw new FileOperationException($e->getMessage(), $e->getCode(), $e); } } From af3295abf880ba550f092dfc28f25c30f566c4f1 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 26 Jan 2022 09:22:27 +0700 Subject: [PATCH 2/3] updated to use rector 0.12.4 and re-run rector --- composer.json | 2 +- rector.php | 5 ----- src/Console/src/Sequence/CallableSequence.php | 4 ---- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 3dd173d81..53a9fc7f5 100644 --- a/composer.json +++ b/composer.json @@ -134,7 +134,7 @@ "mockery/mockery": "^1.3", "phpunit/phpunit": "^8.5|^9.0", "ramsey/uuid": "^3.9", - "rector/rector": "0.12.13", + "rector/rector": "0.12.14", "spiral/broadcast": "^2.0", "spiral/broadcast-ws": "^1.0", "spiral/code-style": "^1.0", diff --git a/rector.php b/rector.php index ad07c6f72..eb9375b68 100644 --- a/rector.php +++ b/rector.php @@ -24,11 +24,6 @@ // for PHP 8 RemoveUnusedPromotedPropertyRector::class, - RemoveUnusedPrivatePropertyRector::class => [ - // buggy when used in middle of parameter along with RemoveUnusedConstructorParamRector that may cause BC break - __DIR__ . '/src/Console/src/Sequence/CallableSequence.php', - ], - RemoveUnusedPrivateMethodRector::class => [ __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', ], diff --git a/src/Console/src/Sequence/CallableSequence.php b/src/Console/src/Sequence/CallableSequence.php index fb0d41348..2831edefd 100644 --- a/src/Console/src/Sequence/CallableSequence.php +++ b/src/Console/src/Sequence/CallableSequence.php @@ -23,9 +23,6 @@ final class CallableSequence extends AbstractSequence /** @var string */ private $function; - /** @var array */ - private $parameters = []; - /** * @param callable $function */ @@ -36,7 +33,6 @@ public function __construct( string $footer = '' ) { $this->function = $function; - $this->parameters = $parameters; parent::__construct($header, $footer); } From 57fd29871af265bc0dca9250b467a6cdea7873f4 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 26 Jan 2022 22:33:56 +0700 Subject: [PATCH 3/3] update to rector 0.12.15 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 53a9fc7f5..daba03684 100644 --- a/composer.json +++ b/composer.json @@ -134,7 +134,7 @@ "mockery/mockery": "^1.3", "phpunit/phpunit": "^8.5|^9.0", "ramsey/uuid": "^3.9", - "rector/rector": "0.12.14", + "rector/rector": "0.12.15", "spiral/broadcast": "^2.0", "spiral/broadcast-ws": "^1.0", "spiral/code-style": "^1.0",