Skip to content

Commit

Permalink
chore(deps): update dependency phpstan/phpstan to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and berndalter-txb committed Feb 7, 2025
1 parent 6e2ac7e commit 7241b59
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 65 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
- '%rootDir%/../../../tests/TurbineKreuzbergTest/Zed/DeployTasks/_output/*'
- '%rootDir%/../../../tests/TurbineKreuzbergTest/Zed/DeployTasks/_support/_generated/*'

checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false

reportUnmatchedIgnoredErrors: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,27 @@ public function execute(array $task): bool
}

/**
* @param array $task
* @param array<string, string|array<string>> $task
*
* @return bool
*/
private function isExecutionSkippedForCurrentStore(array $task): bool
{
$storeToExecuteFor = $task[DeployTasksConstants::YAML_KEY_EXECUTE_FOR_STORE];
/** @var string[] $storesToExecuteFor */
$storesToExecuteFor = $task[DeployTasksConstants::YAML_KEY_EXECUTE_FOR_STORE];
$currentStore = getenv('APPLICATION_STORE');

if (in_array($currentStore, $storeToExecuteFor, true)) {
if (in_array($currentStore, $storesToExecuteFor, true)) {
return false;
}

/** @var string $command */
$command = $task[DeployTasksConstants::YAML_KEY_COMMAND];

$this->tasksLogger->writeOutput(
sprintf(
"Command '%s' will be skipped for store '%s'",
$task[DeployTasksConstants::YAML_KEY_COMMAND],
$command,
$currentStore,
),
);
Expand All @@ -112,23 +116,27 @@ private function isExecutionSkippedForCurrentStore(array $task): bool
}

/**
* @param array $task
* @param array<string, string|array<string>> $task
*
* @return bool
*/
private function isExecutionSkippedInCurrentEnvironment(array $task): bool
{
/** @var string[] $environmentsToExecuteOn */
$environmentsToExecuteOn = $task[DeployTasksConstants::YAML_KEY_EXECUTE_ON];
$currentEnvironment = getenv('SHOP_ENV');

if (in_array($currentEnvironment, $environmentsToExecuteOn, true)) {
return false;
}

/** @var string $command */
$command = $task[DeployTasksConstants::YAML_KEY_COMMAND];

$this->tasksLogger->writeOutput(
sprintf(
"Command '%s' will be skipped in env '%s'",
$task[DeployTasksConstants::YAML_KEY_COMMAND],
$command,
$currentEnvironment,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getFilesToExecute(): array
/**
* @param string $filePath
*
* @return array<string, array<string, string|array<string>>>
* @return array<string, array<int, array<string, string|array<string>>>>
*/
public function readTasksFromFile(string $filePath): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct()
}

/**
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
* @SuppressWarnings("PHPMD.BooleanArgumentFlag")
*
* @param string $message
* @param bool $addDateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ public function execute(): void
$this->tasksLogger->printSeparatorLine();

$tasks = $this->tasksFileReader->readTasksFromFile($taskFile);
$validatedTasks = $this->tasksValidator->validate($tasks);
$validatedTasksArray = $this->tasksValidator->validate($tasks);

if ($this->executeTasks($validatedTasks[DeployTasksConstants::YAML_KEY_TASKS])) {
/** @var array<int, array<string, string|array<string>>> $validatedTasks */
$validatedTasks = $validatedTasksArray[DeployTasksConstants::YAML_KEY_TASKS];

if ($this->executeTasks($validatedTasks)) {
$this->tasksVersionJournal->saveExecutedVersion((int)$timestamp);
}
}
Expand All @@ -85,7 +88,7 @@ public function execute(): void
}

/**
* @param array $tasks
* @param array<int, array<string, string|array<string>>> $tasks
*
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
class DeployTasksValidator
{
/**
* @param array $tasks
* @param array<string, array<int, array<string, string|array<string>>>> $tasks
*
* @return array
* @return array<string, array<int, array<string, string|array<string>>>>
*/
public function validate(array $tasks): array
{
Expand All @@ -26,7 +26,7 @@ public function validate(array $tasks): array
}

/**
* @param array $tasks
* @param array<string, array<int, array<string, string|array<string>>>> $tasks
*
* @throws \TurbineKreuzberg\Zed\DeployTasks\Business\Exception\NoTasksKeyException
* @throws \TurbineKreuzberg\Zed\DeployTasks\Business\Exception\NoTasksArrayException
Expand All @@ -45,7 +45,7 @@ private function validateStructure(array $tasks): void
}

/**
* @param array $tasks
* @param array<int, array<string, string|array<string>>> $tasks
*
* @throws \TurbineKreuzberg\Zed\DeployTasks\Business\Exception\TaskCommandNotAStringException
* @throws \TurbineKreuzberg\Zed\DeployTasks\Business\Exception\TaskExecuteOnNotAnArrayException
Expand Down Expand Up @@ -91,7 +91,7 @@ private function validateTasks(array $tasks): void
}

/**
* @param array $task
* @param array<string, string|array<string>> $task
* @param int $taskNumber
*
* @throws \TurbineKreuzberg\Zed\DeployTasks\Business\Exception\TaskMandatoryKeyMissingException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(TxbDeployTasksQuery $tasksQuery)
}

/**
* @return array
* @return array<string>
*/
public function getExecutedVersions(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DeployTasksExecutorTest extends Unit
/**
* @dataProvider tasksToExecuteDataProvider
*
* @param array $task
* @param array<string, string|array<string>> $task
* @param bool $expectedResult
* @param string|null $expectedOutput
*
Expand Down Expand Up @@ -64,7 +64,7 @@ private function createDeployTasksExecutor(): DeployTasksExecutor
}

/**
* @return array
* @return array<string, array<string, mixed>>
*/
public function tasksToExecuteDataProvider(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testFileReaderReturnsCorrectArrayOfFilesToBeExecuted(): void
codecept_debug(compact('filesToExecute'));

$countAllFiles = 4;
self::assertIsArray($filesToExecute);
self::assertCount($countAllFiles, $filesToExecute);

$firstVersionExecuted = 123456789;
Expand Down Expand Up @@ -92,7 +91,6 @@ public function testFileReaderReturnsArrayWithCorrectOrderOfVersionKeys(): void
$previousVersion = null;

foreach ($versions as $version) {
self::assertIsInt($version);
self::assertGreaterThan(0, $version);

// @phpstan-ignore-next-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,46 +53,46 @@ public function testTasksFilesAreCorrectlyValidated(string $file, ?string $expec
}

/**
* @return array
* @return array<string, array<string, mixed>>
*/
public function invalidTasksDataProvider(): array
{
return [
'valid-tasks' => [
'file' => 'tasks.valid.yml',
],
'missing-tasks-key' => [
'file' => 'tasks.invalid.missing-tasks.yml',
'expectedException' => NoTasksKeyException::class,
],
'tasks-not-an-array' => [
'file' => 'tasks.invalid.tasks-not-an-array.yml',
'expectedException' => NoTasksArrayException::class,
],
'task-not-an-array' => [
'file' => 'tasks.invalid.task-not-an-array.yml',
'expectedException' => InvalidTaskFormatException::class,
],
'task-key-command-missing' => [
'file' => 'tasks.invalid.key-command-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-key-execute_on-missing' => [
'file' => 'tasks.invalid.key-execute_on-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-key-execute_for_store-missing' => [
'file' => 'tasks.invalid.key-execute_for_store-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-command-is-not-a-string' => [
'file' => 'tasks.invalid.task-command-not-string.yml',
'expectedException' => TaskCommandNotAStringException::class,
],
'task-execute_on-not-an-array' => [
'file' => 'tasks.invalid.execute_on-not-an-array.yml',
'expectedException' => TaskExecuteOnNotAnArrayException::class,
],
'valid-tasks' => [
'file' => 'tasks.valid.yml',
],
'missing-tasks-key' => [
'file' => 'tasks.invalid.missing-tasks.yml',
'expectedException' => NoTasksKeyException::class,
],
'tasks-not-an-array' => [
'file' => 'tasks.invalid.tasks-not-an-array.yml',
'expectedException' => NoTasksArrayException::class,
],
'task-not-an-array' => [
'file' => 'tasks.invalid.task-not-an-array.yml',
'expectedException' => InvalidTaskFormatException::class,
],
'task-key-command-missing' => [
'file' => 'tasks.invalid.key-command-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-key-execute_on-missing' => [
'file' => 'tasks.invalid.key-execute_on-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-key-execute_for_store-missing' => [
'file' => 'tasks.invalid.key-execute_for_store-missing.yml',
'expectedException' => TaskMandatoryKeyMissingException::class,
],
'task-command-is-not-a-string' => [
'file' => 'tasks.invalid.task-command-not-string.yml',
'expectedException' => TaskCommandNotAStringException::class,
],
'task-execute_on-not-an-array' => [
'file' => 'tasks.invalid.execute_on-not-an-array.yml',
'expectedException' => TaskExecuteOnNotAnArrayException::class,
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function runCommands(): void
}

/**
* @return array
* @return array<string>
*/
private function getCommands(): array
{
Expand Down

0 comments on commit 7241b59

Please sign in to comment.