Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
403 changes: 403 additions & 0 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
includes:
- phpstan-baseline.neon

parameters:
level: 8
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
paths:
- src
- tests
level: 8
parallel:
# to prevent full thread lagging pc
maximumNumberOfProcesses: 7
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
paths:
- src
- tests

inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
inferPrivatePropertyTypeFromConstructor: true
treatPhpDocTypesAsCertain: false
21 changes: 21 additions & 0 deletions src/Application/BaseApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ class BaseApplication extends Application
* Symlinks, which should be created for each release.
*
* @see \TYPO3\Surf\Task\Generic\CreateSymlinksTask
* @var string[]
*/
protected array $symlinks = [];

/**
* Directories which should be created on deployment. E.g. shared folders.
*
* @var string[]
*/
protected array $directories = [];

Expand Down Expand Up @@ -125,13 +128,19 @@ public function registerTasks(Workflow $workflow, Deployment $deployment): void
}
}

/**
* @param string[] $symlinks
*/
public function setSymlinks(array $symlinks): self
{
$this->symlinks = $symlinks;

return $this;
}

/**
* @return string[]
*/
public function getSymlinks(): array
{
return $this->symlinks;
Expand All @@ -144,6 +153,9 @@ public function addSymlink(string $linkPath, string $sourcePath): self
return $this;
}

/**
* @param string[] $symlinks
*/
public function addSymlinks(array $symlinks): self
{
foreach ($symlinks as $linkPath => $sourcePath) {
Expand All @@ -153,13 +165,19 @@ public function addSymlinks(array $symlinks): self
return $this;
}

/**
* @param string[] $directories
*/
public function setDirectories(array $directories): self
{
$this->directories = $directories;

return $this;
}

/**
* @return string[]
*/
public function getDirectories(): array
{
return $this->directories;
Expand All @@ -172,6 +190,9 @@ public function addDirectory(string $path): self
return $this;
}

/**
* @param string[] $directories
*/
public function addDirectories(array $directories): self
{
foreach ($directories as $path) {
Expand Down
4 changes: 3 additions & 1 deletion src/Application/Neos/Flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ public function getCommandPackageKey(string $command = ''): string
}

/**
* Returns a executable flow command including the context
* Returns an executable flow command including the context
*
* @param string[] $arguments
*/
public function buildCommand(
string $targetPath,
Expand Down
3 changes: 3 additions & 0 deletions src/Application/Neos/Neos.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

class Neos extends Flow
{
/**
* @var string[]
*/
private array $neosCommands = [
'domain:add',
'domain:list',
Expand Down
6 changes: 6 additions & 0 deletions src/Cli/Symfony/Logger/ConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ class ConsoleHandler extends AbstractProcessingHandler
{
private OutputInterface $output;

/**
* @var array<int, mixed>
*/
private array $verbosityLevelMap = [
OutputInterface::VERBOSITY_NORMAL => Logger::INFO,
OutputInterface::VERBOSITY_VERBOSE => Logger::DEBUG,
OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::DEBUG,
OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG,
];

/**
* @param array<int, array<int, mixed>> $verbosityLevelMap
*/
public function __construct(OutputInterface $output, bool $bubble = true, array $verbosityLevelMap = [])
{
parent::__construct(Logger::DEBUG, $bubble);
Expand Down
12 changes: 12 additions & 0 deletions src/Command/DescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\Surf\Domain\Model\Application;
use TYPO3\Surf\Domain\Model\FailedDeployment;
use TYPO3\Surf\Domain\Model\Node;
use TYPO3\Surf\Domain\Model\SimpleWorkflow;
use TYPO3\Surf\Domain\Model\Workflow;
use TYPO3\Surf\Integration\FactoryInterface;
Expand Down Expand Up @@ -91,6 +92,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}

/**
* @param Node[] $nodes
*/
protected function printNodes(array $nodes): void
{
$this->output->writeln('Nodes:' . PHP_EOL);
Expand All @@ -99,6 +103,9 @@ protected function printNodes(array $nodes): void
}
}

/**
* @param Application[] $applications
*/
protected function printApplications(array $applications, Workflow $workflow): void
{
$this->output->writeln(PHP_EOL . 'Applications:' . PHP_EOL);
Expand Down Expand Up @@ -127,6 +134,10 @@ protected function printApplications(array $applications, Workflow $workflow): v
}
}

/**
* @param array<string, mixed> $stages
* @param array<string, mixed> $tasks
*/
protected function printStages(Application $application, array $stages, array $tasks): void
{
foreach ($stages as $stage) {
Expand Down Expand Up @@ -155,6 +166,7 @@ protected function printStages(Application $application, array $stages, array $t
/**
* Print all tasks before or after a task
*
* @param array<string, mixed> $tasks
* @param string $output
*/
private function printBeforeAfterTasks(array $tasks, string $applicationName, string $task, string $step, &$output): void
Expand Down
3 changes: 3 additions & 0 deletions src/Domain/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public function createDirectory(string $directory): bool
return mkdir($directory, 0777, true);
}

/**
* @return string[]
*/
public function glob(string $pattern): array
{
$matches = glob($pattern);
Expand Down
3 changes: 3 additions & 0 deletions src/Domain/Filesystem/FilesystemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ public function fileExists(string $file): bool;

public function createDirectory(string $directory): bool;

/**
* @return string[]
*/
public function glob(string $pattern): array;
}
8 changes: 8 additions & 0 deletions src/Domain/Model/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Application
*/
protected string $releasesDirectory = 'releases';

/**
* @var array<string,mixed>
*/
protected array $options = [];

public function __construct(string $name)
Expand Down Expand Up @@ -219,6 +222,8 @@ public function getReleasesPath(): string
*
* The options will include the deploymentPath and sharedPath for
* unified option handling.
*
* @return array<string,mixed>
*/
public function getOptions(): array
{
Expand Down Expand Up @@ -267,6 +272,9 @@ public function provideStringOption(string $key): string
return (string)$this->getOption($key);
}

/**
* @param array<string, mixed> $options
*/
public function setOptions(array $options): self
{
$this->options = $options;
Expand Down
10 changes: 7 additions & 3 deletions src/Domain/Model/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ class Deployment implements LoggerAwareInterface

/**
* Callbacks that should be executed after initialization
*
* @var array<int,mixed>
*/
protected array $initCallbacks = [];

protected DeploymentStatus $status;

protected bool $initialized = false;

/**
* @var array<string,mixed>
*/
protected array $options = [];

/**
Expand Down Expand Up @@ -344,7 +349,7 @@ public function isInitialized(): bool
* The options will include the deploymentPath and sharedPath for
* unified option handling.
*
* @return array An array of options indexed by option key
* @return array<string, mixed> An array of options indexed by option key
*/
public function getOptions(): array
{
Expand All @@ -367,8 +372,7 @@ public function hasOption(string $key): bool
/**
* Sets all options for the deployment
*
* @param array $options The options to set indexed by option key
*
* @param array<string, mixed> $options The options to set indexed by option key
* @return Deployment The current instance for chaining
*/
public function setOptions(array $options): self
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/Model/HttpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ final class HttpResponse
{
private string $body;

/**
* @var string[][]
*/
private array $headers;

private int $statusCode;

/**
* @param string[][] $headers
*/
public function __construct(string $body, array $headers, int $statusCode)
{
$this->body = $body;
Expand All @@ -44,6 +50,9 @@ public function getBody(): string
return $this->body;
}

/**
* @return string[][]
*/
public function getHeaders(): array
{
return $this->headers;
Expand Down
10 changes: 9 additions & 1 deletion src/Domain/Model/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Node
*
* username: SSH username for connecting to this node (optional)
* port: SSH port for connecting to the node (optional)
*
* @var array{hostname?: string, username?: string, port?: int}
*/
protected array $options = [];

Expand Down Expand Up @@ -143,6 +145,9 @@ public function setHostname(string $hostname): Node
return $this->setOption('hostname', $hostname);
}

/**
* @return array<string, mixed>
*/
public function getOptions(): array
{
return array_merge($this->options, [
Expand All @@ -152,6 +157,9 @@ public function getOptions(): array
]);
}

/**
* @param array<string, mixed> $options
*/
public function setOptions(array $options): self
{
$this->options = $options;
Expand All @@ -171,7 +179,7 @@ public function getOption(string $key)
case 'sharedPath':
return $this->getSharedPath();
default:
return $this->options[$key];
return $this->options[$key] ?? null;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Domain/Model/RollbackWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

final class RollbackWorkflow extends Workflow
{
/**
* @var array<string, mixed>
*/
private array $stages;

public function __construct(TaskManager $taskManager)
Expand Down
6 changes: 6 additions & 0 deletions src/Domain/Model/SimpleWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SimpleWorkflow extends Workflow
*/
protected bool $enableRollback = true;

/**
* @var array<string,string>
*/
protected array $stages = [];

public function __construct(TaskManager $taskManager)
Expand Down Expand Up @@ -118,6 +121,9 @@ public function isEnableRollback(): bool
return $this->enableRollback;
}

/**
* @return string[]
*/
public function getStages(): array
{
return $this->stages;
Expand Down
11 changes: 11 additions & 0 deletions src/Domain/Model/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,31 @@ abstract class Task implements LoggerAwareInterface
use LoggerAwareTrait;

/**
* @param array<string,mixed> $options
* @return mixed|void
*/
abstract public function execute(Node $node, Application $application, Deployment $deployment, array $options = []);

/**
* @param array<string,mixed> $options
*/
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = []): void
{
$this->configureOptions($options);
}

/**
* @param array<string,mixed> $options
*/
public function simulate(Node $node, Application $application, Deployment $deployment, array $options = []): void
{
$this->configureOptions($options);
}

/**
* @param array<string,mixed> $options
* @return array<string,mixed>
*/
protected function configureOptions(array $options = []): array
{
try {
Expand Down
Loading