diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1327a1c8..5e749b51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: fail-fast: false matrix: php-version: [ - '8.1' + '8.3' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -35,7 +35,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Composer cache - uses: actions/cache@v3 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -78,10 +78,10 @@ jobs: fail-fast: false matrix: php-version: [ - '8.1' + '8.3' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -95,7 +95,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Composer cache - uses: actions/cache@v3 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/architector.php b/architector.php index fa3a43b0..4c0e0a69 100644 --- a/architector.php +++ b/architector.php @@ -5,18 +5,14 @@ * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ -use Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector; +use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; use Rector\Config\RectorConfig; -use Rector\Core\Configuration\Option; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; +use Rector\DeadCode\Rector\Property\RemoveDefaultValueFromAssignedPropertyRector; use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector; -use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; -use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector; -use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; -use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Set\ValueObject\SetList; defined('APPLICATION_ROOT_DIR') || define('APPLICATION_ROOT_DIR', __DIR__); @@ -26,16 +22,18 @@ $rectorConfig->import(SetList::EARLY_RETURN); $rectorConfig->import(SetList::PHP_74); - $rectorConfig->parameters()->set(Option::SKIP, [ - ChangeAndIfToEarlyReturnRector::class, - ChangeOrIfReturnToEarlyReturnRector::class, + $rectorConfig->skip([ ClosureToArrowFunctionRector::class, RemoveUselessParamTagRector::class, RemoveUnusedPromotedPropertyRector::class, RemoveUselessReturnTagRector::class, - ReturnBinaryAndToEarlyReturnRector::class, SimplifyUselessVariableRector::class, - TypedPropertyRector::class, - RemoveUselessVarTagRector::class + RemoveUselessVarTagRector::class, + // $isWindows is a static property only ever assigned inside the instance + // constructor; removing its default breaks any static-only access path + // that happens before the class is first instantiated. + RemoveDefaultValueFromAssignedPropertyRector::class => [ + __DIR__ . '/src/SprykerSdk/AsyncApi/Message/AbstractAsyncApiMessage.php', + ], ]); }; diff --git a/composer.json b/composer.json index 9f2800eb..66c26895 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,12 @@ "description": "SDK for AsyncAPI.", "license": "proprietary", "require": { - "php": ">=8.0", + "php": ">=8.3", "doctrine/inflector": "~1.4.2 || ~2.0.0", - "symfony/console": "^4.0.0 || ^5.3 || ^6.0", - "symfony/finder": "^4.0.0 || ^5.3 || ^6.0", - "symfony/process": "^4.0.0 || ^5.4 || ^6.0", - "symfony/property-access": "^4.0.0 || ^5.4 || ^6.0" + "symfony/console": "^4.0.0 || ^5.3 || ^6.0 || ^7.0", + "symfony/finder": "^4.0.0 || ^5.3 || ^6.0 || ^7.0", + "symfony/process": "^4.0.0 || ^5.4 || ^6.0 || ^7.0", + "symfony/property-access": "^4.0.0 || ^5.4 || ^6.0 || ^7.0" }, "require-dev": { "codeception/codeception": "^5.0.0", @@ -18,7 +18,7 @@ "sllh/composer-versions-check": "^2.0", "spryker-sdk/architector": "0.1.x-dev", "spryker/code-sniffer": "^0.17.20", - "symfony/var-dumper": "^6.0.0" + "symfony/var-dumper": "^6.0.0 || ^7.0.0" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index bc4abc82..523317b2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,5 @@ parameters: level: 8 - checkMissingIterableValueType: false bootstrapFiles: - phpstan-bootstrap.php @@ -8,5 +7,6 @@ parameters: ignoreErrors: - '#Parameter .+ of method .+Transfer::.+\(\).+ given.#' - '#Binary operation .+ results in an error.#' + - '#no value type specified in iterable type#' reportUnmatchedIgnoredErrors: false diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApi.php b/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApi.php index 8c2f9174..455bba99 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApi.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApi.php @@ -35,8 +35,6 @@ public function getChannels(): iterable /** * @param string $channelName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Channel\AsyncApiChannelInterface|null */ public function getChannel(string $channelName): ?AsyncApiChannelInterface { diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApiInterface.php b/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApiInterface.php index 2011cb23..e5405c13 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApiInterface.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/AsyncApiInterface.php @@ -18,8 +18,6 @@ public function getChannels(): iterable; /** * @param string $channelName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Channel\AsyncApiChannelInterface|null */ public function getChannel(string $channelName): ?AsyncApiChannelInterface; } diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannel.php b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannel.php index 41b68d99..5bc95878 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannel.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannel.php @@ -57,8 +57,6 @@ public function getPublishMessages(): iterable /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getPublishMessage(string $messageName): ?AsyncApiMessageInterface { @@ -75,8 +73,6 @@ public function getSubscribeMessages(): iterable /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getSubscribeMessage(string $messageName): ?AsyncApiMessageInterface { diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollection.php b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollection.php index 73f2e299..930c328b 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollection.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollection.php @@ -34,8 +34,6 @@ public function getChannels(): iterable /** * @param string $channelName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Channel\AsyncApiChannelInterface|null */ public function getChannel(string $channelName): ?AsyncApiChannelInterface { diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollectionInterface.php b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollectionInterface.php index 78593dc4..cce38ff9 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollectionInterface.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelCollectionInterface.php @@ -16,8 +16,6 @@ public function getChannels(): iterable; /** * @param string $channelName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Channel\AsyncApiChannelInterface|null */ public function getChannel(string $channelName): ?AsyncApiChannelInterface; } diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelInterface.php b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelInterface.php index cb4a1e22..d8da113f 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelInterface.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Channel/AsyncApiChannelInterface.php @@ -23,8 +23,6 @@ public function getPublishMessages(): iterable; /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getPublishMessage(string $messageName): ?AsyncApiMessageInterface; @@ -35,8 +33,6 @@ public function getSubscribeMessages(): iterable; /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getSubscribeMessage(string $messageName): ?AsyncApiMessageInterface; } diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Loader/AsyncApiLoader.php b/src/SprykerSdk/AsyncApi/AsyncApi/Loader/AsyncApiLoader.php index a9e74a6a..4927c911 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Loader/AsyncApiLoader.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Loader/AsyncApiLoader.php @@ -55,7 +55,9 @@ protected function validateRemotePath(string $asyncApiPath): void { // phpcs:disable if (@file_get_contents($asyncApiPath) === false) { - throw new InvalidFilePathException(sprintf('The remote file "%s" could not be loaded. Error: "%s"', $asyncApiPath, error_get_last() ? error_get_last()['message'] : 'Unknown error')); + $lastError = error_get_last(); + + throw new InvalidFilePathException(sprintf('The remote file "%s" could not be loaded. Error: "%s"', $asyncApiPath, $lastError ? $lastError['message'] : 'Unknown error')); } } diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollection.php b/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollection.php index 033560f3..121d1495 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollection.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollection.php @@ -34,8 +34,6 @@ public function getMessages(): iterable /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getMessage(string $messageName): ?AsyncApiMessageInterface { diff --git a/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollectionInterface.php b/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollectionInterface.php index 1c8d49a1..589f9195 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollectionInterface.php +++ b/src/SprykerSdk/AsyncApi/AsyncApi/Message/AsyncApiMessageCollectionInterface.php @@ -16,8 +16,6 @@ public function getMessages(): iterable; /** * @param string $messageName - * - * @return \SprykerSdk\AsyncApi\AsyncApi\Message\AsyncApiMessageInterface|null */ public function getMessage(string $messageName): ?AsyncApiMessageInterface; } diff --git a/src/SprykerSdk/AsyncApi/AsyncApiConfig.php b/src/SprykerSdk/AsyncApi/AsyncApiConfig.php index e51bb4e6..ab217bbb 100644 --- a/src/SprykerSdk/AsyncApi/AsyncApiConfig.php +++ b/src/SprykerSdk/AsyncApi/AsyncApiConfig.php @@ -46,8 +46,10 @@ public function getProjectRootPath(): string */ public function getSprykRunExecutablePath(): string { - if (getenv('INSTALLED_ROOT_DIRECTORY')) { - return getenv('INSTALLED_ROOT_DIRECTORY'); + $installedRootDirectory = getenv('INSTALLED_ROOT_DIRECTORY'); + + if ($installedRootDirectory) { + return $installedRootDirectory; } return (string)getcwd(); diff --git a/src/SprykerSdk/AsyncApi/Code/Builder/AsyncApiCodeBuilder.php b/src/SprykerSdk/AsyncApi/Code/Builder/AsyncApiCodeBuilder.php index 339a6bf2..4f9ed035 100644 --- a/src/SprykerSdk/AsyncApi/Code/Builder/AsyncApiCodeBuilder.php +++ b/src/SprykerSdk/AsyncApi/Code/Builder/AsyncApiCodeBuilder.php @@ -363,8 +363,6 @@ protected function normalizeTransferType(string $type): string /** * @param string $propertyName - * - * @return string|null */ protected function getSingularized(string $propertyName): ?string { diff --git a/src/SprykerSdk/AsyncApi/Console/AbstractConsole.php b/src/SprykerSdk/AsyncApi/Console/AbstractConsole.php index 6092e3d1..878e441e 100644 --- a/src/SprykerSdk/AsyncApi/Console/AbstractConsole.php +++ b/src/SprykerSdk/AsyncApi/Console/AbstractConsole.php @@ -29,7 +29,7 @@ class AbstractConsole extends Command /** * @var \SprykerSdk\AsyncApi\AsyncApiConfig|null */ - protected ?AsyncApiConfig $config = null; + protected ?AsyncApiConfig $config; /** * @var \SprykerSdk\AsyncApi\AsyncApiFacadeInterface|null