diff --git a/src/WordPress/AsyncHttp/Client.php b/src/WordPress/AsyncHttp/Client.php index fb53d58a..a5e68f60 100644 --- a/src/WordPress/AsyncHttp/Client.php +++ b/src/WordPress/AsyncHttp/Client.php @@ -89,7 +89,7 @@ */ class Client { protected $concurrency = 10; - protected Map $requests; + protected $requests; protected $onProgress; protected $queue_needs_processing = false; @@ -150,7 +150,7 @@ public function enqueue( $requests ) { * * @return resource */ - public function get_stream( Request $request ) { + public function get_stream( $request ) { if ( ! isset( $this->requests[ $request ] ) ) { $this->enqueue_request( $request ); } @@ -162,7 +162,10 @@ public function get_stream( Request $request ) { return $this->requests[ $request ]->stream; } - protected function enqueue_request( Request $request ) { + /** + * @param \WordPress\AsyncHttp\Request $request + */ + protected function enqueue_request( $request ) { $stream = StreamWrapper::create_resource( new StreamData( $request, $this ) ); @@ -232,7 +235,7 @@ protected function get_streamed_requests() { * @return false|string * @throws Exception */ - public function read_bytes( Request $request, $length ) { + public function read_bytes( $request, $length ) { if ( ! isset( $this->requests[ $request ] ) ) { return false; } diff --git a/src/WordPress/AsyncHttp/Request.php b/src/WordPress/AsyncHttp/Request.php index c083f356..a7999386 100644 --- a/src/WordPress/AsyncHttp/Request.php +++ b/src/WordPress/AsyncHttp/Request.php @@ -4,7 +4,7 @@ class Request { - public string $url; + public $url; /** * @param string $url diff --git a/src/WordPress/AsyncHttp/StreamData.php b/src/WordPress/AsyncHttp/StreamData.php index 267cd33d..7bd5546e 100644 --- a/src/WordPress/AsyncHttp/StreamData.php +++ b/src/WordPress/AsyncHttp/StreamData.php @@ -6,8 +6,8 @@ class StreamData extends VanillaStreamWrapperData { - public Request $request; - public Client $client; + public $request; + public $client; public function __construct( Request $request, Client $group ) { parent::__construct( null ); diff --git a/src/WordPress/AsyncHttp/StreamWrapper.php b/src/WordPress/AsyncHttp/StreamWrapper.php index 18492a9e..f661a4ba 100644 --- a/src/WordPress/AsyncHttp/StreamWrapper.php +++ b/src/WordPress/AsyncHttp/StreamWrapper.php @@ -30,7 +30,10 @@ public function stream_open( $path, $mode, $options, &$opened_path ) { return true; } - public function stream_cast( int $cast_as ) { + /** + * @param int $cast_as + */ + public function stream_cast( $cast_as ) { $this->initialize(); return parent::stream_cast( $cast_as ); diff --git a/src/WordPress/AsyncHttp/async_http_streams.php b/src/WordPress/AsyncHttp/async_http_streams.php index ac4fdc2b..0b9e9d84 100644 --- a/src/WordPress/AsyncHttp/async_http_streams.php +++ b/src/WordPress/AsyncHttp/async_http_streams.php @@ -96,10 +96,13 @@ function streams_http_requests_send( $streams ) { $remaining_streams = $streams; while ( count( $remaining_streams ) ) { $write = $remaining_streams; - $ready = @stream_select( $read, $write, $except, 0, 5000000 ); + sleep( 2 ); + $ready = @stream_select( $read, $write, $except, 5, 5000000 ); if ( $ready === false ) { throw new Exception( "Error: " . error_get_last()['message'] ); } elseif ( $ready <= 0 ) { + var_dump( $ready ); + die(); throw new Exception( "stream_select timed out" ); } @@ -172,7 +175,7 @@ function parse_http_headers( string $headers ) { ]; $headers = []; foreach ( $lines as $line ) { - if ( ! str_contains( $line, ': ' ) ) { + if ( strpos($line, ': ') === false ) { continue; } $line = explode( ': ', $line ); @@ -231,7 +234,7 @@ function streams_http_response_await_headers( $streams ) { } foreach ( $bytes as $k => $byte ) { $headers[ $k ] .= $byte; - if ( str_ends_with( $headers[ $k ], "\r\n\r\n" ) ) { + if ( substr_compare($headers[ $k ], "\r\n\r\n", -strlen("\r\n\r\n")) === 0 ) { unset( $remaining_streams[ $k ] ); } } diff --git a/src/WordPress/Blueprints/BlueprintMapper.php b/src/WordPress/Blueprints/BlueprintMapper.php index 029dc79b..32d62944 100644 --- a/src/WordPress/Blueprints/BlueprintMapper.php +++ b/src/WordPress/Blueprints/BlueprintMapper.php @@ -34,7 +34,7 @@ public function __construct() { * * @return Blueprint */ - public function map( stdClass $blueprint ): Blueprint { + public function map( $blueprint ): Blueprint { return $this->mapper->hydrate( $blueprint, Blueprint::class ); } diff --git a/src/WordPress/Blueprints/BlueprintParser.php b/src/WordPress/Blueprints/BlueprintParser.php index 58abfbea..728dcef6 100644 --- a/src/WordPress/Blueprints/BlueprintParser.php +++ b/src/WordPress/Blueprints/BlueprintParser.php @@ -55,7 +55,10 @@ public function parse( $raw_blueprint ) { ); } - public function fromObject( \stdClass $data ) { + /** + * @param \stdClass $data + */ + public function fromObject( $data ) { $result = $this->validator->validate( $data ); if ( ! $result->isValid() ) { print_r( ( new ErrorFormatter() )->format( $result->error() ) ); @@ -64,7 +67,10 @@ public function fromObject( \stdClass $data ) { return $this->mapper->map( $data ); } - public function fromBlueprint( Blueprint $blueprint ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + */ + public function fromBlueprint( $blueprint ) { $result = $this->validator->validate( $blueprint ); if ( ! $result->isValid() ) { print_r( ( new ErrorFormatter() )->format( $result->error() ) ); diff --git a/src/WordPress/Blueprints/Cache/FileCache.php b/src/WordPress/Blueprints/Cache/FileCache.php index 5064b766..534c6e58 100644 --- a/src/WordPress/Blueprints/Cache/FileCache.php +++ b/src/WordPress/Blueprints/Cache/FileCache.php @@ -9,7 +9,10 @@ class FileCache implements CacheInterface { private $filesystem; - public function __construct( private string|null $cacheDirectory = null ) { + private $cacheDirectory; + + public function __construct( $cacheDirectory = null ) { + $this->cacheDirectory = $cacheDirectory; // initialize the Filesystem component $this->filesystem = new Filesystem(); @@ -34,7 +37,10 @@ public function __construct( private string|null $cacheDirectory = null ) { } } - public function get( $key, $default = null ): mixed { + /** + * @return mixed + */ + public function get( $key, $default = null ) { $filepath = $this->getFilePathForKey( $key ); if ( ! file_exists( $filepath ) ) { return $default; @@ -47,7 +53,7 @@ public function get( $key, $default = null ): mixed { public function set( $key, $value, $ttl = null ): bool { $filepath = $this->getFilePathForKey( $key ); - $data = serialize( $value ); + $data = serialize( $value ); return file_put_contents( $filepath, $data ) !== false; } diff --git a/src/WordPress/Blueprints/Compile/BlueprintCompiler.php b/src/WordPress/Blueprints/Compile/BlueprintCompiler.php index 632268e5..7934ed49 100644 --- a/src/WordPress/Blueprints/Compile/BlueprintCompiler.php +++ b/src/WordPress/Blueprints/Compile/BlueprintCompiler.php @@ -17,7 +17,7 @@ class BlueprintCompiler { protected $stepRunnerFactory; - protected ResourceResolverInterface $resourceResolver; + protected $resourceResolver; public function __construct( $stepRunnerFactory, @@ -27,7 +27,10 @@ public function __construct( $this->stepRunnerFactory = $stepRunnerFactory; } - public function compile( Blueprint $blueprint ): CompiledBlueprint { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + */ + public function compile( $blueprint ): CompiledBlueprint { $blueprint->steps = array_merge( $this->expandShorthandsIntoSteps( $blueprint ), $blueprint->steps ); $progressTracker = new Tracker(); @@ -42,7 +45,10 @@ public function compile( Blueprint $blueprint ): CompiledBlueprint { ); } - protected function expandShorthandsIntoSteps( Blueprint $blueprint ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + */ + protected function expandShorthandsIntoSteps( $blueprint ) { // @TODO: This duplicates the logic in BlueprintComposer. // It cannot be easily reused because of the dichotomy between the // Step and Step model classes. Let's alter the code generation @@ -87,7 +93,11 @@ protected function expandShorthandsIntoSteps( Blueprint $blueprint ) { return $additional_steps; } - protected function compileSteps( Blueprint $blueprint, Tracker $progress ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + * @param \WordPress\Blueprints\Progress\Tracker $progress + */ + protected function compileSteps( $blueprint, $progress ) { $stepRunnerFactory = $this->stepRunnerFactory; // Compile, ensure all the runners may be created and configured $totalProgressWeight = 0; @@ -114,13 +124,17 @@ protected function compileSteps( Blueprint $blueprint, Tracker $progress ) { return $compiledSteps; } - protected function compileResources( Blueprint $blueprint, Tracker $progress ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + * @param \WordPress\Blueprints\Progress\Tracker $progress + */ + protected function compileResources( $blueprint, $progress ) { $resources = []; $this->findResources( $blueprint, $resources ); $totalProgressWeight = count( $resources ); $compiledResources = []; - foreach ( $resources as $path => [$declaration, $resource] ) { + foreach ( $resources as $path => list( $declaration, $resource ) ) { /** @var $resource ResourceDefinitionInterface */ $compiledResources[ $path ] = new CompiledResource( $declaration, @@ -151,13 +165,14 @@ protected function findResources( $blueprintFragment, &$resources, $path = '', $ // Check if the @var annotation mentions a ResourceDefinitionInterface foreach ( get_object_vars( $blueprintFragment ) as $key => $value ) { $reflection = new \ReflectionProperty( $blueprintFragment, $key ); + $reflection->setAccessible(true); $docComment = $reflection->getDocComment(); $parseNestedUrls = false; if ( preg_match( '/@var\s+([^\s]+)/', $docComment, $matches ) ) { $className = $matches[1]; if ( - str_contains( $className, 'string' ) && - str_contains( $className, 'ResourceDefinitionInterface' ) + false !== strpos( $className, 'string' ) && + false !== strpos( $className, 'ResourceDefinitionInterface' ) ) { $parseNestedUrls = true; } diff --git a/src/WordPress/Blueprints/Compile/CompiledBlueprint.php b/src/WordPress/Blueprints/Compile/CompiledBlueprint.php index 30d742ab..a33ea060 100644 --- a/src/WordPress/Blueprints/Compile/CompiledBlueprint.php +++ b/src/WordPress/Blueprints/Compile/CompiledBlueprint.php @@ -5,13 +5,23 @@ use WordPress\Blueprints\Progress\Tracker; class CompiledBlueprint { + public $compiledSteps; + public $compiledResources; + public $progressTracker; + public $stepsProgressStage; - public function __construct( - public array $compiledSteps, - public array $compiledResources, - public Tracker $progressTracker, - public Tracker $stepsProgressStage, - ) { + /** + * @param $compiledSteps + * @param $compiledResources + * @param $progressTracker + * @param $stepsProgressStage + */ + public function __construct( $compiledSteps, $compiledResources, $progressTracker, $stepsProgressStage ) { + $this->compiledSteps = $compiledSteps; + $this->compiledResources = $compiledResources; + $this->progressTracker = $progressTracker; + $this->stepsProgressStage = $stepsProgressStage; } + } diff --git a/src/WordPress/Blueprints/Compile/CompiledResource.php b/src/WordPress/Blueprints/Compile/CompiledResource.php index 42d729de..d911a444 100644 --- a/src/WordPress/Blueprints/Compile/CompiledResource.php +++ b/src/WordPress/Blueprints/Compile/CompiledResource.php @@ -7,11 +7,18 @@ class CompiledResource { + public $declaration; + public $resource; + public $progressTracker; + public function __construct( - public $declaration, - public ResourceDefinitionInterface $resource, - public Tracker $progressTracker, + $declaration, + ResourceDefinitionInterface $resource, + Tracker $progressTracker ) { + $this->declaration = $declaration; + $this->resource = $resource; + $this->progressTracker = $progressTracker; } } diff --git a/src/WordPress/Blueprints/Compile/CompiledStep.php b/src/WordPress/Blueprints/Compile/CompiledStep.php index bbfcce72..2256e910 100644 --- a/src/WordPress/Blueprints/Compile/CompiledStep.php +++ b/src/WordPress/Blueprints/Compile/CompiledStep.php @@ -8,11 +8,18 @@ class CompiledStep { + public $step; + public $runner; + public $progressTracker; + public function __construct( - public StepDefinitionInterface $step, - public StepRunnerInterface $runner, - public Tracker $progressTracker, + StepDefinitionInterface $step, + StepRunnerInterface $runner, + Tracker $progressTracker ) { + $this->step = $step; + $this->runner = $runner; + $this->progressTracker = $progressTracker; } } diff --git a/src/WordPress/Blueprints/Compile/StepFailure.php b/src/WordPress/Blueprints/Compile/StepFailure.php index 3b8b6136..affa5601 100644 --- a/src/WordPress/Blueprints/Compile/StepFailure.php +++ b/src/WordPress/Blueprints/Compile/StepFailure.php @@ -7,10 +7,15 @@ class StepFailure extends BlueprintException implements StepResultInterface { - public function __construct( - public StepDefinitionInterface $step, + /** + * @var \WordPress\Blueprints\Model\DataClass\StepDefinitionInterface + */ + public $step; + public function __construct( + StepDefinitionInterface $step, \Exception $cause ) { - parent::__construct( "Error when executing step $step->step", 0, $cause ); + $this->step = $step; + parent::__construct( "Error when executing step $step->step", 0, $cause ); } } diff --git a/src/WordPress/Blueprints/Compile/StepSuccess.php b/src/WordPress/Blueprints/Compile/StepSuccess.php index 7f051bed..2eddbf48 100644 --- a/src/WordPress/Blueprints/Compile/StepSuccess.php +++ b/src/WordPress/Blueprints/Compile/StepSuccess.php @@ -5,6 +5,11 @@ use WordPress\Blueprints\Model\DataClass\StepDefinitionInterface; class StepSuccess implements StepResultInterface { - public function __construct( public StepDefinitionInterface $step, public $result ) { + public $step; + public $result; + + public function __construct( StepDefinitionInterface $step, $result ) { + $this->step = $step; + $this->result = $result; } } diff --git a/src/WordPress/Blueprints/ContainerBuilder.php b/src/WordPress/Blueprints/ContainerBuilder.php index 09212605..e4d7d6d3 100644 --- a/src/WordPress/Blueprints/ContainerBuilder.php +++ b/src/WordPress/Blueprints/ContainerBuilder.php @@ -80,7 +80,11 @@ public function __construct() { } - public function build( string $environment, RuntimeInterface $runtime ) { + /** + * @param string $environment + * @param \WordPress\Blueprints\Runtime\RuntimeInterface $runtime + */ + public function build( $environment, $runtime ) { $container = $this->container; $container['runtime'] = function () use ( $runtime ) { return $runtime; @@ -230,7 +234,7 @@ function () use ( $c ) { $container['resource.supported_resolvers'] = function ( $c ) { $ResourceResolvers = array(); foreach ( $c->keys() as $key ) { - if ( str_starts_with( $key, 'resource.resolver.' ) ) { + if ( 0 === strpos( $key, 'resource.resolver.' ) ) { $ResourceResolvers[] = $c[ $key ]; } } diff --git a/src/WordPress/Blueprints/Engine.php b/src/WordPress/Blueprints/Engine.php index 97c99ad3..8168ae8c 100644 --- a/src/WordPress/Blueprints/Engine.php +++ b/src/WordPress/Blueprints/Engine.php @@ -39,7 +39,10 @@ public function parseAndCompile( $raw_blueprint ) { return $this->compiler->compile( $blueprint ); } - public function run( CompiledBlueprint $compiled_blueprint ) { + /** + * @param \WordPress\Blueprints\Compile\CompiledBlueprint $compiled_blueprint + */ + public function run( $compiled_blueprint ) { return $this->runner->run( $compiled_blueprint ); } } diff --git a/src/WordPress/Blueprints/Model/BlueprintBuilder.php b/src/WordPress/Blueprints/Model/BlueprintBuilder.php index a9d09436..52773260 100644 --- a/src/WordPress/Blueprints/Model/BlueprintBuilder.php +++ b/src/WordPress/Blueprints/Model/BlueprintBuilder.php @@ -47,13 +47,19 @@ public function withWordPressVersion( $v ) { return $this; } - public function withSiteOptions( array $options ) { + /** + * @param mixed[] $options + */ + public function withSiteOptions( $options ) { $this->blueprint->setSiteOptions( $options ); return $this; } - public function withWpConfigConstants( array $constants ) { + /** + * @param mixed[] $constants + */ + public function withWpConfigConstants( $constants ) { $this->blueprint->setConstants( $constants ); return $this; @@ -177,7 +183,10 @@ private function prependStep( StepDefinitionInterface $builder ) { return $this; } - public function addStep( StepDefinitionInterface $builder ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\StepDefinitionInterface $builder + */ + public function addStep( $builder ) { array_push( $this->blueprint->steps, $builder ); return $this; diff --git a/src/WordPress/Blueprints/Model/BlueprintSerializer.php b/src/WordPress/Blueprints/Model/BlueprintSerializer.php index 949ba675..93e02386 100644 --- a/src/WordPress/Blueprints/Model/BlueprintSerializer.php +++ b/src/WordPress/Blueprints/Model/BlueprintSerializer.php @@ -7,7 +7,10 @@ class BlueprintSerializer { - public function toJson( Blueprint $blueprint ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Blueprint $blueprint + */ + public function toJson( $blueprint ) { return json_encode( $blueprint ); } diff --git a/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php b/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php index 4538d564..030c9693 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php @@ -22,28 +22,40 @@ class ActivatePluginStep implements StepDefinitionInterface public $slug; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setSlug(string $slug) + /** + * @param string $slug + */ + public function setSlug($slug) { $this->slug = $slug; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php b/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php index 8d93b861..bb31bdf1 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php @@ -22,28 +22,40 @@ class ActivateThemeStep implements StepDefinitionInterface public $slug; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setSlug(string $slug) + /** + * @param string $slug + */ + public function setSlug($slug) { $this->slug = $slug; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/Blueprint.php b/src/WordPress/Blueprints/Model/DataClass/Blueprint.php index 6257788e..b43d0d00 100644 --- a/src/WordPress/Blueprints/Model/DataClass/Blueprint.php +++ b/src/WordPress/Blueprints/Model/DataClass/Blueprint.php @@ -2,8 +2,7 @@ namespace WordPress\Blueprints\Model\DataClass; -class Blueprint -{ +class Blueprint { /** * Optional description. It doesn't do anything but is exposed as a courtesy to developers who may want to document which blueprint file does what. * @var string @@ -50,58 +49,73 @@ class Blueprint public $steps = []; - public function setDescription(string $description) - { + /** + * @param string $description + */ + public function setDescription( $description ) { $this->description = $description; + return $this; } - public function setWordPressVersion(string $WordPressVersion) - { + /** + * @param string $WordPressVersion + */ + public function setWordPressVersion( $WordPressVersion ) { $this->WordPressVersion = $WordPressVersion; + return $this; } - public function setRuntime(iterable $runtime) - { + public function setRuntime( $runtime ) { $this->runtime = $runtime; + return $this; } - public function setOnBoot(BlueprintOnBoot $onBoot) - { + /** + * @param \WordPress\Blueprints\Model\DataClass\BlueprintOnBoot $onBoot + */ + public function setOnBoot( $onBoot ) { $this->onBoot = $onBoot; + return $this; } - public function setConstants(iterable $constants) - { + public function setConstants( $constants ) { $this->constants = $constants; + return $this; } - public function setPlugins(array $plugins) - { + /** + * @param mixed[] $plugins + */ + public function setPlugins( $plugins ) { $this->plugins = $plugins; + return $this; } - public function setSiteOptions(iterable $siteOptions) - { + public function setSiteOptions( $siteOptions ) { $this->siteOptions = $siteOptions; + return $this; } - public function setSteps(array $steps) - { + /** + * @param mixed[] $steps + */ + public function setSteps( $steps ) { $this->steps = $steps; + return $this; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php b/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php index a091a052..554b7184 100644 --- a/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php +++ b/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php @@ -14,14 +14,20 @@ class BlueprintOnBoot public $login; - public function setOpenUrl(string $openUrl) + /** + * @param string $openUrl + */ + public function setOpenUrl($openUrl) { $this->openUrl = $openUrl; return $this; } - public function setLogin(bool $login) + /** + * @param bool $login + */ + public function setLogin($login) { $this->login = $login; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php b/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php index 086d45c1..472bcef1 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php @@ -19,14 +19,20 @@ class CorePluginResource implements ResourceDefinitionInterface public $slug; - public function setResource(string $resource) + /** + * @param string $resource + */ + public function setResource($resource) { $this->resource = $resource; return $this; } - public function setSlug(string $slug) + /** + * @param string $slug + */ + public function setSlug($slug) { $this->slug = $slug; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php b/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php index e7015a0a..2296d87d 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php @@ -19,14 +19,20 @@ class CoreThemeResource implements ResourceDefinitionInterface public $slug; - public function setResource(string $resource) + /** + * @param string $resource + */ + public function setResource($resource) { $this->resource = $resource; return $this; } - public function setSlug(string $slug) + /** + * @param string $slug + */ + public function setSlug($slug) { $this->slug = $slug; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/CpStep.php b/src/WordPress/Blueprints/Model/DataClass/CpStep.php index 08d81a7d..c5d22c1e 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CpStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/CpStep.php @@ -28,35 +28,50 @@ class CpStep implements StepDefinitionInterface public $toPath; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setFromPath(string $fromPath) + /** + * @param string $fromPath + */ + public function setFromPath($fromPath) { $this->fromPath = $fromPath; return $this; } - public function setToPath(string $toPath) + /** + * @param string $toPath + */ + public function setToPath($toPath) { $this->toPath = $toPath; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php b/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php index 5ade7609..b21cf0e8 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php @@ -22,28 +22,40 @@ class DefineSiteUrlStep implements StepDefinitionInterface public $siteUrl; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setSiteUrl(string $siteUrl) + /** + * @param string $siteUrl + */ + public function setSiteUrl($siteUrl) { $this->siteUrl = $siteUrl; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php b/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php index d75f533b..19a0bbc6 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php @@ -22,28 +22,40 @@ class DefineWpConfigConstsStep implements StepDefinitionInterface public $consts; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setConsts(iterable $consts) + /** + * @param iterable $consts + */ + public function setConsts($consts) { $this->consts = $consts; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php b/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php index 432fb9c3..1db432bf 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php @@ -19,21 +19,30 @@ class DownloadWordPressStep implements StepDefinitionInterface public $wordPressZip; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php b/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php index e47d2be2..8dda6c98 100644 --- a/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php @@ -16,21 +16,30 @@ class EnableMultisiteStep implements StepDefinitionInterface public $step = 'enableMultisite'; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php b/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php index 0bf34c2d..b2d480b5 100644 --- a/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php @@ -25,21 +25,30 @@ class EvalPHPCallbackStep implements StepDefinitionInterface public $callback; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfo.php b/src/WordPress/Blueprints/Model/DataClass/FileInfo.php index 0ed00e2a..534f76a9 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfo.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfo.php @@ -17,28 +17,40 @@ class FileInfo public $data; - public function setKey(string $key) + /** + * @param string $key + */ + public function setKey($key) { $this->key = $key; return $this; } - public function setName(string $name) + /** + * @param string $name + */ + public function setName($name) { $this->name = $name; return $this; } - public function setType(string $type) + /** + * @param string $type + */ + public function setType($type) { $this->type = $type; return $this; } - public function setData(FileInfoData $data) + /** + * @param \WordPress\Blueprints\Model\DataClass\FileInfoData $data + */ + public function setData($data) { $this->data = $data; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php b/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php index 9638f0e9..39ff5129 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php @@ -20,35 +20,50 @@ class FileInfoData public $length; - public function setBYTES_PER_ELEMENT(float $BYTES_PER_ELEMENT) + /** + * @param float $BYTES_PER_ELEMENT + */ + public function setBYTES_PER_ELEMENT($BYTES_PER_ELEMENT) { $this->BYTES_PER_ELEMENT = $BYTES_PER_ELEMENT; return $this; } - public function setBuffer(FileInfoDataBuffer $buffer) + /** + * @param \WordPress\Blueprints\Model\DataClass\FileInfoDataBuffer $buffer + */ + public function setBuffer($buffer) { $this->buffer = $buffer; return $this; } - public function setByteLength(float $byteLength) + /** + * @param float $byteLength + */ + public function setByteLength($byteLength) { $this->byteLength = $byteLength; return $this; } - public function setByteOffset(float $byteOffset) + /** + * @param float $byteOffset + */ + public function setByteOffset($byteOffset) { $this->byteOffset = $byteOffset; return $this; } - public function setLength(float $length) + /** + * @param float $length + */ + public function setLength($length) { $this->length = $length; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php b/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php index 9bb4dfc8..535ef8b4 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php @@ -8,7 +8,10 @@ class FileInfoDataBuffer public $byteLength; - public function setByteLength(float $byteLength) + /** + * @param float $byteLength + */ + public function setByteLength($byteLength) { $this->byteLength = $byteLength; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php b/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php index 2c72c182..caffb091 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php @@ -19,14 +19,20 @@ class FilesystemResource implements ResourceDefinitionInterface public $path; - public function setResource(string $resource) + /** + * @param string $resource + */ + public function setResource($resource) { $this->resource = $resource; return $this; } - public function setPath(string $path) + /** + * @param string $path + */ + public function setPath($path) { $this->path = $path; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php b/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php index c4dd3310..568a04ad 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php @@ -19,21 +19,30 @@ class ImportFileStep implements StepDefinitionInterface public $file; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/InlineResource.php b/src/WordPress/Blueprints/Model/DataClass/InlineResource.php index fa3bde2f..4e30c0ad 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InlineResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/InlineResource.php @@ -19,14 +19,20 @@ class InlineResource implements ResourceDefinitionInterface public $contents; - public function setResource(string $resource) + /** + * @param string $resource + */ + public function setResource($resource) { $this->resource = $resource; return $this; } - public function setContents(string $contents) + /** + * @param string $contents + */ + public function setContents($contents) { $this->contents = $contents; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php index 7c9a1ecc..54375712 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php @@ -27,21 +27,30 @@ class InstallPluginStep implements StepDefinitionInterface { public $activate = true; - public function setProgress( Progress $progress ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress( $progress ) { $this->progress = $progress; return $this; } - public function setContinueOnError( bool $continueOnError ) { + /** + * @param bool $continueOnError + */ + public function setContinueOnError( $continueOnError ) { $this->continueOnError = $continueOnError; return $this; } - public function setStep( string $step ) { + /** + * @param string $step + */ + public function setStep( $step ) { $this->step = $step; return $this; @@ -55,7 +64,10 @@ public function setPluginZipFile( $pluginZipFile ) { } - public function setActivate( bool $activate ) { + /** + * @param bool $activate + */ + public function setActivate( $activate ) { $this->activate = $activate; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php index a96aef15..63e868e4 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php @@ -19,21 +19,30 @@ class InstallSqliteIntegrationStep implements StepDefinitionInterface public $sqlitePluginZip; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php index a862fad6..5bd52b88 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php @@ -28,21 +28,30 @@ class InstallThemeStep implements StepDefinitionInterface public $activate = true; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; @@ -56,7 +65,10 @@ public function setThemeZipFile($themeZipFile) } - public function setActivate(bool $activate) + /** + * @param bool $activate + */ + public function setActivate($activate) { $this->activate = $activate; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php b/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php index 911ee9da..291151c9 100644 --- a/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php @@ -22,28 +22,40 @@ class MkdirStep implements StepDefinitionInterface public $path; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setPath(string $path) + /** + * @param string $path + */ + public function setPath($path) { $this->path = $path; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/MvStep.php b/src/WordPress/Blueprints/Model/DataClass/MvStep.php index 736d18aa..10c35d5b 100644 --- a/src/WordPress/Blueprints/Model/DataClass/MvStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/MvStep.php @@ -28,35 +28,50 @@ class MvStep implements StepDefinitionInterface public $toPath; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setFromPath(string $fromPath) + /** + * @param string $fromPath + */ + public function setFromPath($fromPath) { $this->fromPath = $fromPath; return $this; } - public function setToPath(string $toPath) + /** + * @param string $toPath + */ + public function setToPath($toPath) { $this->toPath = $toPath; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/Progress.php b/src/WordPress/Blueprints/Model/DataClass/Progress.php index 4ae54958..973bc481 100644 --- a/src/WordPress/Blueprints/Model/DataClass/Progress.php +++ b/src/WordPress/Blueprints/Model/DataClass/Progress.php @@ -11,14 +11,20 @@ class Progress public $caption; - public function setWeight(float $weight) + /** + * @param float $weight + */ + public function setWeight($weight) { $this->weight = $weight; return $this; } - public function setCaption(string $caption) + /** + * @param string $caption + */ + public function setCaption($caption) { $this->caption = $caption; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/RmStep.php b/src/WordPress/Blueprints/Model/DataClass/RmStep.php index c4a791ed..af6d3853 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RmStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RmStep.php @@ -22,28 +22,40 @@ class RmStep implements StepDefinitionInterface public $path; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setPath(string $path) + /** + * @param string $path + */ + public function setPath($path) { $this->path = $path; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php b/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php index ff2fb327..3c763d38 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php @@ -25,28 +25,40 @@ class RunPHPStep implements StepDefinitionInterface public $code; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setCode(string $code) + /** + * @param string $code + */ + public function setCode($code) { $this->code = $code; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php b/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php index a63ad67e..ebaf9c68 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php @@ -22,21 +22,30 @@ class RunSQLStep implements StepDefinitionInterface public $sql; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php b/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php index de109909..b4a38a06 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php @@ -19,28 +19,40 @@ class RunWordPressInstallerStep implements StepDefinitionInterface public $options; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setOptions(WordPressInstallationOptions $options) + /** + * @param \WordPress\Blueprints\Model\DataClass\WordPressInstallationOptions $options + */ + public function setOptions($options) { $this->options = $options; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php b/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php index d9f1dd36..3b9e7327 100644 --- a/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php @@ -2,8 +2,7 @@ namespace WordPress\Blueprints\Model\DataClass; -class SetSiteOptionsStep implements StepDefinitionInterface -{ +class SetSiteOptionsStep implements StepDefinitionInterface { const DISCRIMINATOR = 'setSiteOptions'; /** @var Progress */ @@ -25,30 +24,39 @@ class SetSiteOptionsStep implements StepDefinitionInterface public $options; - public function setProgress(Progress $progress) - { + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress( $progress ) { $this->progress = $progress; + return $this; } - public function setContinueOnError(bool $continueOnError) - { + /** + * @param bool $continueOnError + */ + public function setContinueOnError( $continueOnError ) { $this->continueOnError = $continueOnError; + return $this; } - public function setStep(string $step) - { + /** + * @param string $step + */ + public function setStep( $step ) { $this->step = $step; + return $this; } - public function setOptions(iterable $options) - { + public function setOptions( $options ) { $this->options = $options; + return $this; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php b/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php index f107951d..5333e315 100644 --- a/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php @@ -25,21 +25,30 @@ class UnzipStep implements StepDefinitionInterface public $extractToPath; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; @@ -53,7 +62,10 @@ public function setZipFile($zipFile) } - public function setExtractToPath(string $extractToPath) + /** + * @param string $extractToPath + */ + public function setExtractToPath($extractToPath) { $this->extractToPath = $extractToPath; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/UrlResource.php b/src/WordPress/Blueprints/Model/DataClass/UrlResource.php index cd03093a..8d25d706 100644 --- a/src/WordPress/Blueprints/Model/DataClass/UrlResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/UrlResource.php @@ -25,21 +25,30 @@ class UrlResource implements ResourceDefinitionInterface public $caption; - public function setResource(string $resource) + /** + * @param string $resource + */ + public function setResource($resource) { $this->resource = $resource; return $this; } - public function setUrl(string $url) + /** + * @param string $url + */ + public function setUrl($url) { $this->url = $url; return $this; } - public function setCaption(string $caption) + /** + * @param string $caption + */ + public function setCaption($caption) { $this->caption = $caption; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php b/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php index 3949a622..ea7b3060 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php @@ -25,28 +25,40 @@ class WPCLIStep implements StepDefinitionInterface public $command; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setCommand(array $command) + /** + * @param mixed[] $command + */ + public function setCommand($command) { $this->command = $command; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php b/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php index 7793e3db..3446a085 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php +++ b/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php @@ -11,14 +11,20 @@ class WordPressInstallationOptions public $adminPassword = 'admin'; - public function setAdminUsername(string $adminUsername) + /** + * @param string $adminUsername + */ + public function setAdminUsername($adminUsername) { $this->adminUsername = $adminUsername; return $this; } - public function setAdminPassword(string $adminPassword) + /** + * @param string $adminPassword + */ + public function setAdminPassword($adminPassword) { $this->adminPassword = $adminPassword; return $this; diff --git a/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php b/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php index dc1a05f8..784e1845 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php @@ -28,28 +28,40 @@ class WriteFileStep implements StepDefinitionInterface public $data; - public function setProgress(Progress $progress) + /** + * @param \WordPress\Blueprints\Model\DataClass\Progress $progress + */ + public function setProgress($progress) { $this->progress = $progress; return $this; } - public function setContinueOnError(bool $continueOnError) + /** + * @param bool $continueOnError + */ + public function setContinueOnError($continueOnError) { $this->continueOnError = $continueOnError; return $this; } - public function setStep(string $step) + /** + * @param string $step + */ + public function setStep($step) { $this->step = $step; return $this; } - public function setPath(string $path) + /** + * @param string $path + */ + public function setPath($path) { $this->path = $path; return $this; diff --git a/src/WordPress/Blueprints/Progress/ProgressCaptionEvent.php b/src/WordPress/Blueprints/Progress/ProgressCaptionEvent.php index cc7d43e5..5fbe1836 100644 --- a/src/WordPress/Blueprints/Progress/ProgressCaptionEvent.php +++ b/src/WordPress/Blueprints/Progress/ProgressCaptionEvent.php @@ -3,8 +3,12 @@ namespace WordPress\Blueprints\Progress; class ProgressCaptionEvent extends \Symfony\Contracts\EventDispatcher\Event { - public function __construct( - public string $caption - ) { - } + /** + * @var string + */ + public $caption; + public function __construct(string $caption) + { + $this->caption = $caption; + } } diff --git a/src/WordPress/Blueprints/Progress/ProgressEvent.php b/src/WordPress/Blueprints/Progress/ProgressEvent.php index 11355033..80b4fb85 100644 --- a/src/WordPress/Blueprints/Progress/ProgressEvent.php +++ b/src/WordPress/Blueprints/Progress/ProgressEvent.php @@ -13,20 +13,20 @@ class ProgressEvent extends Event { * * @var float $progress */ - public float $progress; + public $progress; /** * The caption to display during progress, a string. * * @var ?string $caption */ - public ?string $caption; + public $caption; public function __construct( float $progress, - ?string $caption + string $caption ) { - $this->caption = $caption; + $this->caption = $caption; $this->progress = $progress; } } diff --git a/src/WordPress/Blueprints/Progress/Tracker.php b/src/WordPress/Blueprints/Progress/Tracker.php index ed23b027..123b57b8 100644 --- a/src/WordPress/Blueprints/Progress/Tracker.php +++ b/src/WordPress/Blueprints/Progress/Tracker.php @@ -46,7 +46,7 @@ class Tracker { private $weight; private $subTrackers = []; - public EventDispatcher $events; + public $events; public function __construct( $options = [] ) { $this->weight = $options['weight'] ?? 1; @@ -117,7 +117,11 @@ public function stage( $weight = null, $caption = '' ) { return $subTracker; } - public function set( float $value, ?string $caption = null ): void { + /** + * @param float $value + * @param string|null $caption + */ + public function set( $value, $caption = null ) { if ( $value < $this->selfProgress ) { throw new \InvalidArgumentException( "Progress cannot go backwards (tried updating to $value when it already was $this->selfProgress)" ); } @@ -181,7 +185,7 @@ private function notifyProgress() { $this->events->dispatch( new ProgressEvent( $this->getProgress(), - $this->getCaption(), + $this->getCaption() ) ); } diff --git a/src/WordPress/Blueprints/Resources/Resolver/FilesystemResourceResolver.php b/src/WordPress/Blueprints/Resources/Resolver/FilesystemResourceResolver.php index ce917d2a..0611758d 100644 --- a/src/WordPress/Blueprints/Resources/Resolver/FilesystemResourceResolver.php +++ b/src/WordPress/Blueprints/Resources/Resolver/FilesystemResourceResolver.php @@ -8,8 +8,11 @@ class FilesystemResourceResolver implements ResourceResolverInterface { - public function parseUrl( string $url ): ?ResourceDefinitionInterface { - if ( ! str_starts_with( $url, 'file://' ) ) { + /** + * @param string $url + */ + public function parseUrl( $url ) { + if ( strncmp($url, 'file://', strlen('file://')) !== 0 ) { return null; } @@ -20,11 +23,18 @@ static public function getResourceClass(): string { return FilesystemResource::class; } - public function supports( ResourceDefinitionInterface $resource ): bool { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + */ + public function supports( $resource ): bool { return $resource instanceof FilesystemResource; } - public function stream( ResourceDefinitionInterface $resource, Tracker $progress_tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + * @param \WordPress\Blueprints\Progress\Tracker $progress_tracker + */ + public function stream( $resource, $progress_tracker ) { if ( ! $this->supports( $resource ) ) { throw new \InvalidArgumentException( 'Resource ' . get_class( $resource ) . ' unsupported' ); } diff --git a/src/WordPress/Blueprints/Resources/Resolver/InlineResourceResolver.php b/src/WordPress/Blueprints/Resources/Resolver/InlineResourceResolver.php index 034c887d..4d961240 100644 --- a/src/WordPress/Blueprints/Resources/Resolver/InlineResourceResolver.php +++ b/src/WordPress/Blueprints/Resources/Resolver/InlineResourceResolver.php @@ -9,7 +9,10 @@ class InlineResourceResolver implements ResourceResolverInterface { - public function parseUrl( string $url ): ?ResourceDefinitionInterface { + /** + * @param string $url + */ + public function parseUrl( $url ) { // If url starts with "protocol://" then we assume it's not inline raw data if ( 0 !== preg_match( '#^[a-z_+]+://#', $url ) ) { return null; @@ -22,11 +25,18 @@ static public function getResourceClass(): string { return InlineResource::class; } - public function supports( ResourceDefinitionInterface $resource ): bool { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + */ + public function supports( $resource ): bool { return $resource instanceof InlineResource; } - public function stream( ResourceDefinitionInterface $resource, Tracker $progress_tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + * @param \WordPress\Blueprints\Progress\Tracker $progress_tracker + */ + public function stream( $resource, $progress_tracker ) { if ( ! $this->supports( $resource ) ) { throw new \InvalidArgumentException( 'Resource ' . get_class( $resource ) . ' unsupported' ); } diff --git a/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverCollection.php b/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverCollection.php index c45e4d10..67584450 100644 --- a/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverCollection.php +++ b/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverCollection.php @@ -10,7 +10,7 @@ class ResourceResolverCollection implements ResourceResolverInterface { /** @var ResourceResolverInterface[] */ - protected array $resource_resolvers; + protected $resource_resolvers; public function __construct( array $resource_resolvers @@ -22,7 +22,10 @@ public static function getResourceClass(): string { throw new RuntimeException( 'Not implemented' ); } - public function parseUrl( string $url ): ?ResourceDefinitionInterface { + /** + * @param string $url + */ + public function parseUrl( $url ) { foreach ( $this->resource_resolvers as $resolver ) { /** @var ResourceResolverInterface $resolver */ $resource = $resolver->parseUrl( $url ); @@ -34,7 +37,10 @@ public function parseUrl( string $url ): ?ResourceDefinitionInterface { return null; } - public function supports( ResourceDefinitionInterface $resource ): bool { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + */ + public function supports( $resource ): bool { foreach ( $this->resource_resolvers as $resolver ) { /** @var ResourceResolverInterface $resolver */ if ( $resolver->supports( $resource ) ) { @@ -45,7 +51,11 @@ public function supports( ResourceDefinitionInterface $resource ): bool { return false; } - public function stream( ResourceDefinitionInterface $resource, Tracker $progressTracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + * @param \WordPress\Blueprints\Progress\Tracker $progressTracker + */ + public function stream( $resource, $progressTracker ) { foreach ( $this->resource_resolvers as $resolver ) { /** @var ResourceResolverInterface $resolver */ if ( $resolver->supports( $resource ) ) { diff --git a/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverInterface.php b/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverInterface.php index 6fc823fd..7f7b8beb 100644 --- a/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverInterface.php +++ b/src/WordPress/Blueprints/Resources/Resolver/ResourceResolverInterface.php @@ -6,11 +6,21 @@ use WordPress\Blueprints\Progress\Tracker; interface ResourceResolverInterface { - public function parseUrl( string $url ): ?ResourceDefinitionInterface; + /** + * @param string $url + */ + public function parseUrl( $url ); - public function supports( ResourceDefinitionInterface $resource ): bool; + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + */ + public function supports( $resource ): bool; static public function getResourceClass(): string; - public function stream( ResourceDefinitionInterface $resource, Tracker $progress_tracker ); + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + * @param \WordPress\Blueprints\Progress\Tracker $progress_tracker + */ + public function stream( $resource, $progress_tracker ); } diff --git a/src/WordPress/Blueprints/Resources/Resolver/UrlResourceResolver.php b/src/WordPress/Blueprints/Resources/Resolver/UrlResourceResolver.php index d7c6cf71..22edb3e7 100644 --- a/src/WordPress/Blueprints/Resources/Resolver/UrlResourceResolver.php +++ b/src/WordPress/Blueprints/Resources/Resolver/UrlResourceResolver.php @@ -11,14 +11,17 @@ class UrlResourceResolver implements ResourceResolverInterface { - protected DataSourceInterface $data_source; + protected $data_source; public function __construct( DataSourceInterface $data_source ) { $this->data_source = $data_source; } - public function parseUrl( string $url ): ?ResourceDefinitionInterface { - if ( ! str_starts_with( $url, 'http://' ) && ! str_starts_with( $url, 'https://' ) ) { + /** + * @param string $url + */ + public function parseUrl( $url ) { + if ( strncmp($url, 'http://', strlen('http://')) !== 0 && strncmp($url, 'https://', strlen('https://')) !== 0 ) { return null; } @@ -30,11 +33,18 @@ public static function getResourceClass(): string { return UrlResource::class; } - public function supports( ResourceDefinitionInterface $resource ): bool { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + */ + public function supports( $resource ): bool { return $resource instanceof UrlResource; } - public function stream( ResourceDefinitionInterface $resource, Tracker $progress_tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\ResourceDefinitionInterface $resource + * @param \WordPress\Blueprints\Progress\Tracker $progress_tracker + */ + public function stream( $resource, $progress_tracker ) { if ( ! $this->supports( $resource ) ) { throw new InvalidArgumentException( 'Resource ' . get_class( $resource ) . ' unsupported' ); } diff --git a/src/WordPress/Blueprints/Resources/ResourceManager.php b/src/WordPress/Blueprints/Resources/ResourceManager.php index 75df95af..2ceba893 100644 --- a/src/WordPress/Blueprints/Resources/ResourceManager.php +++ b/src/WordPress/Blueprints/Resources/ResourceManager.php @@ -9,9 +9,9 @@ class ResourceManager { - protected Filesystem $fs; - protected Map $map; - protected ResourceResolverCollection $resource_resolvers; + protected $fs; + protected $map; + protected $resource_resolvers; public function __construct( ResourceResolverCollection $resource_resolvers @@ -21,7 +21,10 @@ public function __construct( $this->map = new Map(); } - public function enqueue( array $compiledResources ) { + /** + * @param mixed[] $compiledResources + */ + public function enqueue( $compiledResources ) { foreach ( $compiledResources as $compiled ) { /** @var CompiledResource $compiled */ diff --git a/src/WordPress/Blueprints/Runner/Blueprint/BlueprintRunner.php b/src/WordPress/Blueprints/Runner/Blueprint/BlueprintRunner.php index bdd2532d..8b83878e 100644 --- a/src/WordPress/Blueprints/Runner/Blueprint/BlueprintRunner.php +++ b/src/WordPress/Blueprints/Runner/Blueprint/BlueprintRunner.php @@ -11,8 +11,8 @@ class BlueprintRunner { - public EventDispatcher $events; - protected RuntimeInterface $runtime; + public $events; + protected $runtime; protected $resourceManagerFactory; public function __construct( @@ -24,7 +24,10 @@ public function __construct( $this->events = new EventDispatcher(); } - public function run( CompiledBlueprint $blueprint ) { + /** + * @param \WordPress\Blueprints\Compile\CompiledBlueprint $blueprint + */ + public function run( $blueprint ) { $resourceManagerFactory = $this->resourceManagerFactory; $resourceManager = $resourceManagerFactory(); $resourceManager->enqueue( diff --git a/src/WordPress/Blueprints/Runner/Step/ActivatePluginStepRunner.php b/src/WordPress/Blueprints/Runner/Step/ActivatePluginStepRunner.php index 71c87548..7889b7eb 100644 --- a/src/WordPress/Blueprints/Runner/Step/ActivatePluginStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/ActivatePluginStepRunner.php @@ -8,8 +8,12 @@ class ActivatePluginStepRunner extends BaseStepRunner { - function run( ActivatePluginStep $input, Tracker $tracker ) { - $tracker?->setCaption( $input->progress->caption ?? "Activating plugin " . $input->slug ); + /** + * @param \WordPress\Blueprints\Model\DataClass\ActivatePluginStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { + ($nullsafeVariable1 = $tracker) ? $nullsafeVariable1->setCaption($input->progress->caption ?? "Activating plugin " . $input->slug) : null; // @TODO: Compare performance to the wp_activate_plugin.php script. // On the first sight it seems to be significantly faster. @@ -31,7 +35,7 @@ function run( ActivatePluginStep $input, Tracker $tracker ) { // ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Activating plugin"; } } diff --git a/src/WordPress/Blueprints/Runner/Step/ActivateThemeStepRunner.php b/src/WordPress/Blueprints/Runner/Step/ActivateThemeStepRunner.php index 3e564be2..03f67944 100644 --- a/src/WordPress/Blueprints/Runner/Step/ActivateThemeStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/ActivateThemeStepRunner.php @@ -16,13 +16,18 @@ static public function getStepClass(): string { } /** - * @param ActivateThemeStep $input - */ - public function getDefaultCaption( $input ): string|null { + * @param ActivateThemeStep $input + * @return string|null + */ + public function getDefaultCaption( $input ) { return "Activating theme " . $input->slug; } - public function run( ActivateThemeStep $input, Tracker $tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\ActivateThemeStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + public function run( $input, $tracker ) { // @TODO: Compare performance to the wp_activate_theme.php script. // On the first sight it seems to be significantly faster. return $this->getRuntime()->runShellCommand( diff --git a/src/WordPress/Blueprints/Runner/Step/BaseStepRunner.php b/src/WordPress/Blueprints/Runner/Step/BaseStepRunner.php index 908ddf84..8a81093c 100644 --- a/src/WordPress/Blueprints/Runner/Step/BaseStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/BaseStepRunner.php @@ -5,34 +5,34 @@ use WordPress\Blueprints\Resources\ResourceManager; use WordPress\Blueprints\Runtime\RuntimeInterface; -abstract class BaseStepRunner implements StepRunnerInterface -{ - protected ResourceManager $resourceManager; - - protected RuntimeInterface $runtime; - - public function setResourceManager(ResourceManager $map) - { - $this->resourceManager = $map; - } - - protected function getResource($declaration) - { - return $this->resourceManager->getStream($declaration); - } - - public function setRuntime(RuntimeInterface $runtime): void - { - $this->runtime = $runtime; - } - - protected function getRuntime(): RuntimeInterface - { - return $this->runtime; - } - - public function getDefaultCaption($input): ?string - { - return null; - } +abstract class BaseStepRunner implements StepRunnerInterface { + protected $resourceManager; + + protected $runtime; + + /** + * @param \WordPress\Blueprints\Resources\ResourceManager $map + */ + public function setResourceManager( $map ) { + $this->resourceManager = $map; + } + + protected function getResource( $declaration ) { + return $this->resourceManager->getStream( $declaration ); + } + + /** + * @param \WordPress\Blueprints\Runtime\RuntimeInterface $runtime + */ + public function setRuntime( $runtime ) { + $this->runtime = $runtime; + } + + protected function getRuntime(): RuntimeInterface { + return $this->runtime; + } + + public function getDefaultCaption( $input ) { + return null; + } } diff --git a/src/WordPress/Blueprints/Runner/Step/CpStepRunner.php b/src/WordPress/Blueprints/Runner/Step/CpStepRunner.php index d971fb5b..258e80dc 100644 --- a/src/WordPress/Blueprints/Runner/Step/CpStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/CpStepRunner.php @@ -9,7 +9,7 @@ class CpStepRunner extends BaseStepRunner { /** * @param CpStep $input */ - function run( CpStep $input ) { + function run( $input ) { // @TODO: Treat the input paths as relative path to the document root (unless it's absolute) $success = copy( $input->fromPath, $input->toPath ); if ( ! $success ) { diff --git a/src/WordPress/Blueprints/Runner/Step/DefineSiteUrlStepRunner.php b/src/WordPress/Blueprints/Runner/Step/DefineSiteUrlStepRunner.php index df7031d2..803c3573 100644 --- a/src/WordPress/Blueprints/Runner/Step/DefineSiteUrlStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/DefineSiteUrlStepRunner.php @@ -7,7 +7,10 @@ class DefineSiteUrlStepRunner extends BaseStepRunner { - function run( DefineSiteUrlStep $input ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\DefineSiteUrlStep $input + */ + function run( $input ) { // @TODO: Don't manually construct the step object like this. // There may be more required fields in the future. // Instead, either remove this step, move the const-setting @@ -21,7 +24,7 @@ function run( DefineSiteUrlStep $input ) { ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Defining site URL"; } } diff --git a/src/WordPress/Blueprints/Runner/Step/DefineWpConfigConstsStepRunner.php b/src/WordPress/Blueprints/Runner/Step/DefineWpConfigConstsStepRunner.php index 50a0de43..0c84cd5c 100644 --- a/src/WordPress/Blueprints/Runner/Step/DefineWpConfigConstsStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/DefineWpConfigConstsStepRunner.php @@ -6,25 +6,28 @@ class DefineWpConfigConstsStepRunner extends BaseStepRunner { - function run( DefineWpConfigConstsStep $input ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\DefineWpConfigConstsStep $input + */ + function run( $input ) { $functions = file_get_contents( __DIR__ . '/DefineWpConfigConsts/functions.php' ); return $this->getRuntime()->evalPhpInSubProcess( - "$functions ?>" . <<<'PHP' -" . ' json_encode( $input->consts ), ] ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Defining wp-config constants"; } + } diff --git a/src/WordPress/Blueprints/Runner/Step/DownloadWordPressStepRunner.php b/src/WordPress/Blueprints/Runner/Step/DownloadWordPressStepRunner.php index b8488149..e39d443e 100644 --- a/src/WordPress/Blueprints/Runner/Step/DownloadWordPressStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/DownloadWordPressStepRunner.php @@ -7,9 +7,13 @@ class DownloadWordPressStepRunner extends InstallAssetStepRunner { - public function run( - DownloadWordPressStep $input, - Tracker $progress + /** + * @param \WordPress\Blueprints\Model\DataClass\DownloadWordPressStep $input + * @param \WordPress\Blueprints\Progress\Tracker $progress + */ + public function run( + $input, + $progress ) { $this->unzipAssetTo( $input->wordPressZip, $this->getRuntime()->getDocumentRoot() ); @@ -20,7 +24,7 @@ public function run( } } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Extracting WordPress"; } diff --git a/src/WordPress/Blueprints/Runner/Step/EnableMultisiteStepRunner.php b/src/WordPress/Blueprints/Runner/Step/EnableMultisiteStepRunner.php index 60178ac5..f8aad316 100644 --- a/src/WordPress/Blueprints/Runner/Step/EnableMultisiteStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/EnableMultisiteStepRunner.php @@ -8,7 +8,7 @@ class EnableMultisiteStepRunner extends BaseStepRunner { /** * @param EnableMultisiteStep $input */ - function run( EnableMultisiteStep $input ) { + function run( $input ) { throw new \LogicException( 'Not implemented yet' ); // @TODO: diff --git a/src/WordPress/Blueprints/Runner/Step/EvalPHPCallbackStepRunner.php b/src/WordPress/Blueprints/Runner/Step/EvalPHPCallbackStepRunner.php index 3cbd8661..000fc0dc 100644 --- a/src/WordPress/Blueprints/Runner/Step/EvalPHPCallbackStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/EvalPHPCallbackStepRunner.php @@ -10,7 +10,7 @@ class EvalPHPCallbackStepRunner extends BaseStepRunner { * @param EvalPHPCallbackStep $input * @param Tracker $tracker */ - function run( EvalPHPCallbackStep $input, Tracker $tracker ) { + function run( $input, $tracker ) { if ( ! is_callable( $input->callback ) ) { throw new \InvalidArgumentException( "The 'callback' input property is not callable" ); } diff --git a/src/WordPress/Blueprints/Runner/Step/ImportFileStepRunner.php b/src/WordPress/Blueprints/Runner/Step/ImportFileStepRunner.php index 29a2e90d..1aa6f15c 100644 --- a/src/WordPress/Blueprints/Runner/Step/ImportFileStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/ImportFileStepRunner.php @@ -9,8 +9,12 @@ class ImportFileStepRunner extends BaseStepRunner { - function run( ImportFileStep $input, Tracker $tracker ) { - $tracker?->setCaption( $input->progress->caption ?? "Importing starter content" ); + /** + * @param \WordPress\Blueprints\Model\DataClass\ImportFileStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { + ($nullsafeVariable1 = $tracker) ? $nullsafeVariable1->setCaption($input->progress->caption ?? "Importing starter content") : null; // @TODO: Install the wordpress-importer plugin if it's not already installed // wp plugin install wordpress-importer --activate diff --git a/src/WordPress/Blueprints/Runner/Step/InstallPluginStepRunner.php b/src/WordPress/Blueprints/Runner/Step/InstallPluginStepRunner.php index f9aca493..b5322189 100644 --- a/src/WordPress/Blueprints/Runner/Step/InstallPluginStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/InstallPluginStepRunner.php @@ -8,7 +8,11 @@ class InstallPluginStepRunner extends InstallAssetStepRunner { - function run( InstallPluginStep $input, Tracker $tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\InstallPluginStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { // @TODO: inject this information into this step $pluginDir = 'plugin' . rand( 0, 1000 ); $targetPath = $this->getRuntime()->resolvePath( 'wp-content/plugins/' . $pluginDir ); @@ -26,7 +30,7 @@ function run( InstallPluginStep $input, Tracker $tracker ) { } } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Installing plugin " . $input->pluginZipFile; } } diff --git a/src/WordPress/Blueprints/Runner/Step/InstallSqliteIntegrationStepRunner.php b/src/WordPress/Blueprints/Runner/Step/InstallSqliteIntegrationStepRunner.php index e26e0184..6be1d28b 100644 --- a/src/WordPress/Blueprints/Runner/Step/InstallSqliteIntegrationStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/InstallSqliteIntegrationStepRunner.php @@ -11,7 +11,7 @@ class InstallSqliteIntegrationStepRunner extends InstallAssetStepRunner { * @param InstallSqliteIntegrationStep $input * @param Tracker $tracker */ - function run( InstallSqliteIntegrationStep $input, Tracker $tracker ) { + function run( $input, $tracker ) { $pluginDir = 'sqlite-database-integration'; $targetPath = $this->getRuntime()->resolvePath( 'wp-content/mu-plugins/' . $pluginDir ); $this->unzipAssetTo( $input->sqlitePluginZip, $targetPath ); @@ -33,7 +33,7 @@ function run( InstallSqliteIntegrationStep $input, Tracker $tracker ) { 'getRuntime()->resolvePath( 'wp-content/themes/' . $themeDir ); @@ -31,7 +32,7 @@ function run( InstallThemeStep $input, Tracker $tracker ) { } } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Installing theme " . $input->themeZipFile; } diff --git a/src/WordPress/Blueprints/Runner/Step/MkdirStepRunner.php b/src/WordPress/Blueprints/Runner/Step/MkdirStepRunner.php index 7143ddb8..e7af07c5 100644 --- a/src/WordPress/Blueprints/Runner/Step/MkdirStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/MkdirStepRunner.php @@ -7,7 +7,10 @@ class MkdirStepRunner extends BaseStepRunner { - function run( MkdirStep $input ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\MkdirStep $input + */ + function run( $input ) { // @TODO: Treat $input->path as relative path to the document root (unless it's absolute) $success = mkdir( $input->path ); if ( ! $success ) { diff --git a/src/WordPress/Blueprints/Runner/Step/MvStepRunner.php b/src/WordPress/Blueprints/Runner/Step/MvStepRunner.php index b97dccb2..81cd4225 100644 --- a/src/WordPress/Blueprints/Runner/Step/MvStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/MvStepRunner.php @@ -12,7 +12,7 @@ class MvStepRunner extends BaseStepRunner { /** * @param MvStep $input */ - function run( MvStep $input ) { + function run( $input ) { // @TODO: Treat these paths as relative path to the document root (unless it's absolute) $success = rename( $input->fromPath, $input->toPath ); if ( ! $success ) { diff --git a/src/WordPress/Blueprints/Runner/Step/RmStepRunner.php b/src/WordPress/Blueprints/Runner/Step/RmStepRunner.php index b16c75e2..23df8388 100644 --- a/src/WordPress/Blueprints/Runner/Step/RmStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/RmStepRunner.php @@ -12,7 +12,7 @@ class RmStepRunner extends BaseStepRunner /** * @param RmStep $input */ - public function run(RmStep $input) + public function run($input) { $resolvedPath = $this->getRuntime()->resolvePath($input->path); $fileSystem = new Filesystem(); diff --git a/src/WordPress/Blueprints/Runner/Step/RunPHPStepRunner.php b/src/WordPress/Blueprints/Runner/Step/RunPHPStepRunner.php index 7eb724d7..f1ae4a40 100644 --- a/src/WordPress/Blueprints/Runner/Step/RunPHPStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/RunPHPStepRunner.php @@ -6,8 +6,12 @@ use WordPress\Blueprints\Progress\Tracker; class RunPHPStepRunner extends BaseStepRunner { - function run( RunPHPStep $input, Tracker $tracker ) { - $tracker?->setCaption( "Running custom PHP code" ); + /** + * @param \WordPress\Blueprints\Model\DataClass\RunPHPStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { + ($nullsafeVariable1 = $tracker) ? $nullsafeVariable1->setCaption("Running custom PHP code") : null; return $this->getRuntime()->evalPhpInSubProcess( $input->code ); } diff --git a/src/WordPress/Blueprints/Runner/Step/RunSQLStepRunner.php b/src/WordPress/Blueprints/Runner/Step/RunSQLStepRunner.php index f70c8419..8032d545 100644 --- a/src/WordPress/Blueprints/Runner/Step/RunSQLStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/RunSQLStepRunner.php @@ -11,11 +11,12 @@ class RunSQLStepRunner extends BaseStepRunner { /** - * @param RunSQLStep $input - */ - function run( - RunSQLStep $input, - Tracker $progress = null + * @param RunSQLStep $input + * @param \WordPress\Blueprints\Progress\Tracker|null $progress + */ + function run( + $input, + $progress = null ) { return $this->getRuntime()->evalPhpInSubProcess( <<<'CODE' getResource( $input->sql ) ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Running SQL queries"; } } diff --git a/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php b/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php index 7bbbc7cb..0ef91f3f 100644 --- a/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php @@ -6,7 +6,11 @@ use WordPress\Blueprints\Progress\Tracker; class RunWordPressInstallerStepRunner extends BaseStepRunner { - function run( RunWordPressInstallerStep $input, Tracker $tracker ) { + /** + * @param \WordPress\Blueprints\Model\DataClass\RunWordPressInstallerStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { return $this->getRuntime()->runShellCommand( [ 'php', @@ -23,8 +27,8 @@ function run( RunWordPressInstallerStep $input, Tracker $tracker ) { ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Installing WordPress"; } - + } diff --git a/src/WordPress/Blueprints/Runner/Step/SetSiteOptionsStepRunner.php b/src/WordPress/Blueprints/Runner/Step/SetSiteOptionsStepRunner.php index 353da168..e032b12d 100644 --- a/src/WordPress/Blueprints/Runner/Step/SetSiteOptionsStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/SetSiteOptionsStepRunner.php @@ -8,26 +8,27 @@ class SetSiteOptionsStepRunner extends BaseStepRunner { /** - * @param SetSiteOptionsStep $input - */ - function run( SetSiteOptionsStep $input, Tracker $tracker ) { + * @param SetSiteOptionsStep $input + * @param \WordPress\Blueprints\Progress\Tracker $tracker + */ + function run( $input, $tracker ) { // Running a custom PHP script is much faster than setting each option // with a separate wp-cli command. - return $this->getRuntime()->evalPhpInSubProcess( <<<'CODE' + return $this->getRuntime()->evalPhpInSubProcess( ' $value) { update_option($name, $value); } -CODE, +', [ 'OPTIONS' => json_encode( $input->options ), ] ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Setting site options"; } diff --git a/src/WordPress/Blueprints/Runner/Step/StepRunnerInterface.php b/src/WordPress/Blueprints/Runner/Step/StepRunnerInterface.php index 2b61b87e..1f3a83c1 100644 --- a/src/WordPress/Blueprints/Runner/Step/StepRunnerInterface.php +++ b/src/WordPress/Blueprints/Runner/Step/StepRunnerInterface.php @@ -5,12 +5,17 @@ use WordPress\Blueprints\Resources\ResourceManager; use WordPress\Blueprints\Runtime\RuntimeInterface; -interface StepRunnerInterface -{ +interface StepRunnerInterface { - public function setResourceManager(ResourceManager $map); + /** + * @param \WordPress\Blueprints\Resources\ResourceManager $map + */ + public function setResourceManager( $map ); - public function setRuntime(RuntimeInterface $runtime): void; + /** + * @param \WordPress\Blueprints\Runtime\RuntimeInterface $runtime + */ + public function setRuntime( $runtime ); // @TODO: Document how this method isn't defined because // PHP doens't support covariant arguments diff --git a/src/WordPress/Blueprints/Runner/Step/UnzipStepRunner.php b/src/WordPress/Blueprints/Runner/Step/UnzipStepRunner.php index 081ba247..27866085 100644 --- a/src/WordPress/Blueprints/Runner/Step/UnzipStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/UnzipStepRunner.php @@ -16,8 +16,8 @@ class UnzipStepRunner extends BaseStepRunner { * @return void */ public function run( - UnzipStep $input, - Tracker $progress_tracker + $input, + $progress_tracker ) { $progress_tracker->set( 10, 'Unzipping...' ); diff --git a/src/WordPress/Blueprints/Runner/Step/WPCLIStepRunner.php b/src/WordPress/Blueprints/Runner/Step/WPCLIStepRunner.php index 76c70c66..d3bbf517 100644 --- a/src/WordPress/Blueprints/Runner/Step/WPCLIStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/WPCLIStepRunner.php @@ -8,7 +8,7 @@ class WPCLIStepRunner extends BaseStepRunner { /** * @param WPCLIStep $input */ - function run( WPCLIStep $input ) { + function run( $input ) { $this->getRuntime()->runShellCommand( $input->command ); } } diff --git a/src/WordPress/Blueprints/Runner/Step/WriteFileStepRunner.php b/src/WordPress/Blueprints/Runner/Step/WriteFileStepRunner.php index e3f12bf0..a7a83930 100644 --- a/src/WordPress/Blueprints/Runner/Step/WriteFileStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/WriteFileStepRunner.php @@ -6,9 +6,13 @@ use WordPress\Blueprints\Progress\Tracker; class WriteFileStepRunner extends BaseStepRunner { - public function run( - WriteFileStep $input, - Tracker $progress = null + /** + * @param \WordPress\Blueprints\Model\DataClass\WriteFileStep $input + * @param \WordPress\Blueprints\Progress\Tracker|null $progress + */ + public function run( + $input, + $progress = null ) { $path = $this->getRuntime()->resolvePath( $input->path ); // @TODO: Treat $input->path as relative path to the document root (unless it's absolute) @@ -25,7 +29,7 @@ public function run( fclose( $fp2 ); } - public function getDefaultCaption( $input ): null|string { + public function getDefaultCaption( $input ) { return "Writing file " . $input->path; } diff --git a/src/WordPress/Blueprints/Runtime/ProcessFailedException.php b/src/WordPress/Blueprints/Runtime/ProcessFailedException.php index a49cda3f..5bd5909d 100644 --- a/src/WordPress/Blueprints/Runtime/ProcessFailedException.php +++ b/src/WordPress/Blueprints/Runtime/ProcessFailedException.php @@ -8,9 +8,12 @@ class ProcessFailedException extends BlueprintException { - protected Process $process; + /** + * @var \Symfony\Component\Process\Process + */ + protected $process; - public function __construct( Process $process, ?Throwable $previous = null ) { + public function __construct( Process $process, Throwable $previous = null ) { $this->process = $process; parent::__construct( "Process `" . $process->getCommandLine() . "` failed with exit code " . $process->getExitCode() . " and the following stderr output: \n" . $process->getErrorOutput() . "\n" . $process->getOutput(), diff --git a/src/WordPress/Blueprints/Runtime/Runtime.php b/src/WordPress/Blueprints/Runtime/Runtime.php index 40d8a5b4..011b3918 100644 --- a/src/WordPress/Blueprints/Runtime/Runtime.php +++ b/src/WordPress/Blueprints/Runtime/Runtime.php @@ -9,14 +9,14 @@ class Runtime implements RuntimeInterface { - public Filesystem $fs; - protected string $documentRoot; + public $fs; + protected $documentRoot; - public function __construct( + public function __construct( string $documentRoot ) { - $this->documentRoot = $documentRoot; - $this->fs = new Filesystem(); + $this->documentRoot = $documentRoot; + $this->fs = new Filesystem(); if ( ! file_exists( $this->getDocumentRoot() ) ) { $this->fs->mkdir( $this->getDocumentRoot() ); } @@ -34,7 +34,10 @@ public function getDocumentRoot(): string { return $this->documentRoot; } - public function resolvePath( string $path ): string { + /** + * @param string $path + */ + public function resolvePath( $path ): string { return Path::makeAbsolute( $path, $this->getDocumentRoot() ); } @@ -68,11 +71,15 @@ public function getTempRoot() { } // @TODO: Move this to a separate class - public function evalPhpInSubProcess( + /** + * @param mixed[]|null $env + * @param float $timeout + */ + public function evalPhpInSubProcess( $code, - ?array $env = null, + $env = null, $input = null, - ?float $timeout = 60 + $timeout = 60 ) { return $this->runShellCommand( [ @@ -81,22 +88,30 @@ public function evalPhpInSubProcess( '?>' . $code, ], null, - [ - 'DOCROOT' => $this->getDocumentRoot(), - ...( $env ?? [] ), - ], + array_merge( + [ + 'DOCROOT' => $this->getDocumentRoot(), + ], + $env ?? [] + ), $input, $timeout ); } // @TODO: Move this to a separate class - public function runShellCommand( - array $command, - ?string $cwd = null, - ?array $env = null, + /** + * @param mixed[] $command + * @param string|null $cwd + * @param mixed[]|null $env + * @param float $timeout + */ + public function runShellCommand( + $command, + $cwd = null, + $env = null, $input = null, - ?float $timeout = 60 + $timeout = 60 ) { $process = $this->startProcess( $command, @@ -114,14 +129,20 @@ public function runShellCommand( return $process->getOutput(); } - public function startProcess( - array $command, - ?string $cwd = null, - ?array $env = null, + /** + * @param mixed[] $command + * @param string|null $cwd + * @param mixed[]|null $env + * @param float $timeout + */ + public function startProcess( + $command, + $cwd = null, + $env = null, $input = null, - ?float $timeout = 60 + $timeout = 60 ): Process { - $cwd ??= $this->getDocumentRoot(); + $cwd = $cwd ?? $this->getDocumentRoot(); return new Process( $command, diff --git a/src/WordPress/Blueprints/Runtime/RuntimeInterface.php b/src/WordPress/Blueprints/Runtime/RuntimeInterface.php index 34d65e4d..cab23cc5 100644 --- a/src/WordPress/Blueprints/Runtime/RuntimeInterface.php +++ b/src/WordPress/Blueprints/Runtime/RuntimeInterface.php @@ -6,12 +6,18 @@ interface RuntimeInterface { - public function startProcess( - array $command, - ?string $cwd = null, - ?array $env = null, - mixed $input = null, - ?float $timeout = 60 + /** + * @param mixed[] $command + * @param string|null $cwd + * @param mixed[]|null $env + * @param float $timeout + */ + public function startProcess( + $command, + $cwd = null, + $env = null, + $input = null, + $timeout = 60 ): Process; } diff --git a/src/WordPress/Blueprints/bin/autogenerate_models.php b/src/WordPress/Blueprints/bin/autogenerate_models.php index c03ca0da..6be4c267 100644 --- a/src/WordPress/Blueprints/bin/autogenerate_models.php +++ b/src/WordPress/Blueprints/bin/autogenerate_models.php @@ -78,7 +78,9 @@ */ $modelInfoClass = ( new PhpNamespace( $targetNamespace ) )->addClass( 'ModelInfo' ); foreach ( $interfaceImplementors as $interfaceName => $implementors ) { - $implementorsClassExpressions = array_map( fn( $implementor ) => $implementor . '::class', $implementors ); + $implementorsClassExpressions = array_map( function ($implementor) { + return $implementor . '::class'; + }, $implementors ); $modelInfoClass->addMethod( 'get' . $interfaceName . 'Implementations' ) ->setStatic( true ) ->setReturnType( 'array' ) @@ -109,7 +111,9 @@ foreach ( $interfaceImplementors as $interfaceName => $implementors ) { $unionReplacements[ implode( '|', $implementors ) ] = $interfaceName; - $arrayUnion = array_map( fn( $implementor ) => $implementor . '[]', $implementors ); + $arrayUnion = array_map( function ($implementor) { + return $implementor . '[]'; + }, $implementors ); $unionReplacements[ implode( '|', $arrayUnion ) ] = $interfaceName . '[]'; } @@ -143,7 +147,7 @@ function fixTypeHint( string $typeHint, array $replacements ): string { $description = $janeProperty->getDescription(); $typeHint = $janeProperty->getType()->getTypeHint( '' ); $docTypeHint = $janeProperty->getType()->getDocTypeHint( '' ); - if ( str_contains( $docTypeHint, $targetNamespace ) ) { + if ( strpos($docTypeHint, $targetNamespace) !== false ) { // Jane prepends "\$namespace\Model\" to type hints, let's remove that. $docTypeHint = str_replace( '\\' . $targetNamespace . '\\Model\\', '', $docTypeHint ); // Let's replace the lengthy union types with the interface types. @@ -182,7 +186,7 @@ function fixTypeHint( string $typeHint, array $replacements ): string { $setterArg = $setter->addParameter( $janeProperty->getName() ); $argTypeHint = $janeProperty->getType()->getTypeHint( $targetNamespace ) . ''; if ( $argTypeHint ) { - if ( str_contains( $argTypeHint, '\\' ) ) { + if ( strpos($argTypeHint, '\\') !== false ) { $argTypeHint = $targetNamespace . '\\' . str_replace( '\\' . $targetNamespace . '\\Model\\', '', $argTypeHint ); diff --git a/src/WordPress/Blueprints/functions.php b/src/WordPress/Blueprints/functions.php index 66a661eb..bdc97850 100644 --- a/src/WordPress/Blueprints/functions.php +++ b/src/WordPress/Blueprints/functions.php @@ -8,6 +8,7 @@ use WordPress\Blueprints\Runtime\Runtime; function run_blueprint( $json, $options = [] ) { + $environment = $options['environment'] ?? ContainerBuilder::ENVIRONMENT_NATIVE; $documentRoot = $options['documentRoot'] ?? '/wordpress'; $progressSubscriber = $options['progressSubscriber'] ?? null; diff --git a/src/WordPress/DataSource/BaseDataSource.php b/src/WordPress/DataSource/BaseDataSource.php index 2d0c8ee2..8407aaf3 100644 --- a/src/WordPress/DataSource/BaseDataSource.php +++ b/src/WordPress/DataSource/BaseDataSource.php @@ -6,7 +6,7 @@ abstract class BaseDataSource implements DataSourceInterface { - public EventDispatcher $events; + public $events; public function __construct() { $this->events = new EventDispatcher(); diff --git a/src/WordPress/DataSource/DataSourceProgressEvent.php b/src/WordPress/DataSource/DataSourceProgressEvent.php index e4ac5700..b444d112 100644 --- a/src/WordPress/DataSource/DataSourceProgressEvent.php +++ b/src/WordPress/DataSource/DataSourceProgressEvent.php @@ -5,10 +5,25 @@ use Symfony\Contracts\EventDispatcher\Event; class DataSourceProgressEvent extends Event { - public function __construct( - public string $url, - public int $downloadedBytes, - public int|null $totalBytes - ) { - } + /** + * @var string + */ + public $url; + /** + * @var int + */ + public $downloadedBytes; + /** + * @var int|null + */ + public $totalBytes; + /** + * @param int|null $totalBytes + */ + public function __construct(string $url, int $downloadedBytes, $totalBytes) + { + $this->url = $url; + $this->downloadedBytes = $downloadedBytes; + $this->totalBytes = $totalBytes; + } } diff --git a/src/WordPress/DataSource/PlaygroundFetchSource.php b/src/WordPress/DataSource/PlaygroundFetchSource.php index a67eb032..f18089bf 100644 --- a/src/WordPress/DataSource/PlaygroundFetchSource.php +++ b/src/WordPress/DataSource/PlaygroundFetchSource.php @@ -12,7 +12,7 @@ class PlaygroundFetchSource extends BaseDataSource { public function stream( $resourceIdentifier ) { $url = $resourceIdentifier; $proc_handle = proc_open( - [ 'fetch', $url, ], + is_array([ 'fetch', $url, ]) ? implode(' ', array_map('escapeshellarg', [ 'fetch', $url, ])) : [ 'fetch', $url, ], [ 1 => [ 'pipe', 'w' ], 2 => [ 'pipe', 'w' ] ], $pipes ); diff --git a/src/WordPress/DataSource/UrlSource.php b/src/WordPress/DataSource/UrlSource.php index c397e008..d02fe310 100644 --- a/src/WordPress/DataSource/UrlSource.php +++ b/src/WordPress/DataSource/UrlSource.php @@ -10,10 +10,16 @@ class UrlSource extends BaseDataSource { + protected $client; + protected $cache; + public function __construct( - protected Client $client, - protected CacheInterface $cache + Client $client, + CacheInterface $cache ) { + $this->client = $client; + $this->cache = $cache; + parent::__construct(); $client->set_progress_callback( function ( Request $request, $downloaded, $total ) { $this->events->dispatch( new DataSourceProgressEvent( @@ -62,7 +68,7 @@ public function stream( $resourceIdentifier ) { return StreamPeekerWrapper::create_resource( new StreamPeekerData( $stream, - $onChunk, + $onChunk ) ); } diff --git a/src/WordPress/JsonMapper/JsonMapper.php b/src/WordPress/JsonMapper/JsonMapper.php index e001d22a..86b54a9e 100644 --- a/src/WordPress/JsonMapper/JsonMapper.php +++ b/src/WordPress/JsonMapper/JsonMapper.php @@ -45,7 +45,7 @@ public function __construct( array $custom_factories = array() ) { * @throws JsonMapperException If mapping the value to an associated property type failed or if setting was * impossible. */ - public function hydrate( stdClass $json, string $class_name ) { + public function hydrate( $json, $class_name ) { return $this->has_factory( $class_name ) ? $this->run_factory( $class_name, $json ) : $this->create_and_hydrate( $class_name, $json ); diff --git a/src/WordPress/JsonMapper/PropertyParser.php b/src/WordPress/JsonMapper/PropertyParser.php index fcfebfea..e200c9e0 100644 --- a/src/WordPress/JsonMapper/PropertyParser.php +++ b/src/WordPress/JsonMapper/PropertyParser.php @@ -40,7 +40,7 @@ public static function get_array_dimensions( $type ) { * * @return array the property map, key: property name */ - public static function compute_property_map( ReflectionClass $reflection_class ) { + public static function compute_property_map( $reflection_class ) { $property_map = array(); foreach ( self::get_properties( $reflection_class ) as $reflection_property ) { diff --git a/src/WordPress/JsonMapper/Utils.php b/src/WordPress/JsonMapper/Utils.php index e186cde5..7086bcdd 100644 --- a/src/WordPress/JsonMapper/Utils.php +++ b/src/WordPress/JsonMapper/Utils.php @@ -6,7 +6,10 @@ class Utils { static public $scalar_types = array( 'string', 'bool', 'boolean', 'int', 'integer', 'double', 'float' ); - static public function is_type_scalar( string $type ) { + /** + * @param string $type + */ + static public function is_type_scalar( $type ) { return in_array( $type, self::$scalar_types, true ); } diff --git a/src/WordPress/Streams/StreamPeekerData.php b/src/WordPress/Streams/StreamPeekerData.php index a8e46234..a1b355a4 100644 --- a/src/WordPress/Streams/StreamPeekerData.php +++ b/src/WordPress/Streams/StreamPeekerData.php @@ -4,7 +4,13 @@ class StreamPeekerData extends VanillaStreamWrapperData { - public function __construct( public $fp, public $onChunk = null, public $onClose = null ) { - parent::__construct( $fp ); + public $fp; + public $onChunk = null; + public $onClose = null; + public function __construct( $fp, $onChunk = null, $onClose = null ) { + $this->fp = $fp; + $this->onChunk = $onChunk; + $this->onClose = $onClose; + parent::__construct( $fp ); } } diff --git a/src/WordPress/Streams/StreamWrapperInterface.php b/src/WordPress/Streams/StreamWrapperInterface.php index 322a3a4b..9bc9d752 100644 --- a/src/WordPress/Streams/StreamWrapperInterface.php +++ b/src/WordPress/Streams/StreamWrapperInterface.php @@ -13,14 +13,17 @@ interface StreamWrapperInterface { * * @return bool */ - public function stream_set_option( int $option, int $arg1, ?int $arg2 ): bool; + public function stream_set_option( $option, $arg1, $arg2 = null ): bool; /** * Opens the stream */ public function stream_open( $path, $mode, $options, &$opened_path ); - public function stream_cast( int $cast_as ); + /** + * @param int $cast_as + */ + public function stream_cast( $cast_as ); /** * Reads from the stream diff --git a/src/WordPress/Streams/VanillaStreamWrapper.php b/src/WordPress/Streams/VanillaStreamWrapper.php index 8dfb4783..810af238 100644 --- a/src/WordPress/Streams/VanillaStreamWrapper.php +++ b/src/WordPress/Streams/VanillaStreamWrapper.php @@ -11,7 +11,10 @@ class VanillaStreamWrapper implements StreamWrapperInterface { const SCHEME = 'vanilla'; - static public function create_resource( VanillaStreamWrapperData $data ) { + /** + * @param \WordPress\Streams\VanillaStreamWrapperData $data + */ + static public function create_resource( $data ) { static::register(); $context = stream_context_create( [ @@ -38,7 +41,12 @@ static public function unregister() { } - public function stream_set_option( int $option, int $arg1, ?int $arg2 ): bool { + /** + * @param int $option + * @param int $arg1 + * @param int|null $arg2 + */ + public function stream_set_option( $option, $arg1, $arg2 = null ): bool { if ( \STREAM_OPTION_BLOCKING === $option ) { return stream_set_blocking( $this->stream, (bool) $arg1 ); } elseif ( \STREAM_OPTION_READ_TIMEOUT === $option ) { @@ -64,7 +72,10 @@ public function stream_open( $path, $mode, $options, &$opened_path ) { return true; } - public function stream_cast( int $cast_as ) { + /** + * @param int $cast_as + */ + public function stream_cast( $cast_as ) { return $this->stream; } diff --git a/src/WordPress/Util/Map.php b/src/WordPress/Util/Map.php index 69c35216..65ff8558 100644 --- a/src/WordPress/Util/Map.php +++ b/src/WordPress/Util/Map.php @@ -7,7 +7,7 @@ use Traversable; class Map implements ArrayAccess, IteratorAggregate { - private array $pairs = []; + private $pairs = []; public function __construct() { } @@ -22,7 +22,8 @@ public function offsetExists( $offset ): bool { return false; } - public function offsetGet( $offset ): mixed { + #[\ReturnTypeWillChange] + public function offsetGet( $offset ) { foreach ( $this->pairs as $pair ) { if ( $pair[0] === $offset ) { return $pair[1]; @@ -33,7 +34,7 @@ public function offsetGet( $offset ): mixed { throw new \Exception( "Stream for resource " . json_encode( $offset ) . " not found" ); } - public function offsetSet( $offset, $value ): void { + public function offsetSet( $offset, $value ) { foreach ( $this->pairs as $k => $pair ) { if ( $pair[0] === $offset ) { $this->pairs[ $k ] = [ $offset, $value ]; @@ -44,7 +45,7 @@ public function offsetSet( $offset, $value ): void { $this->pairs[] = [ $offset, $value ]; } - public function offsetUnset( $offset ): void { + public function offsetUnset( $offset ) { foreach ( $this->pairs as $i => $pair ) { if ( $pair[0] === $offset ) { unset( $this->pairs[ $i ] ); diff --git a/src/WordPress/Zip/ZipCentralDirectoryEntry.php b/src/WordPress/Zip/ZipCentralDirectoryEntry.php index 0527dd7e..807d9260 100644 --- a/src/WordPress/Zip/ZipCentralDirectoryEntry.php +++ b/src/WordPress/Zip/ZipCentralDirectoryEntry.php @@ -4,24 +4,24 @@ class ZipCentralDirectoryEntry { - public bool $isDirectory; - public int $firstByteAt; - public int $versionCreated; - public int $versionNeeded; - public int $generalPurpose; - public int $compressionMethod; - public int $lastModifiedTime; - public int $lastModifiedDate; - public int $crc; - public int $compressedSize; - public int $uncompressedSize; - public int $diskNumber; - public int $internalAttributes; - public int $externalAttributes; - public int $lastByteAt; - public string $path; - public string $extra; - public string $fileComment; + public $isDirectory; + public $firstByteAt; + public $versionCreated; + public $versionNeeded; + public $generalPurpose; + public $compressionMethod; + public $lastModifiedTime; + public $lastModifiedDate; + public $crc; + public $compressedSize; + public $uncompressedSize; + public $diskNumber; + public $internalAttributes; + public $externalAttributes; + public $lastByteAt; + public $path; + public $extra; + public $fileComment; public function __construct( int $versionCreated, @@ -42,24 +42,24 @@ public function __construct( string $extra, string $fileComment ) { - $this->fileComment = $fileComment; - $this->extra = $extra; - $this->path = $path; - $this->lastByteAt = $lastByteAt; + $this->fileComment = $fileComment; + $this->extra = $extra; + $this->path = $path; + $this->lastByteAt = $lastByteAt; $this->externalAttributes = $externalAttributes; $this->internalAttributes = $internalAttributes; - $this->diskNumber = $diskNumber; - $this->uncompressedSize = $uncompressedSize; - $this->compressedSize = $compressedSize; - $this->crc = $crc; - $this->lastModifiedDate = $lastModifiedDate; - $this->lastModifiedTime = $lastModifiedTime; - $this->compressionMethod = $compressionMethod; - $this->generalPurpose = $generalPurpose; - $this->versionNeeded = $versionNeeded; - $this->versionCreated = $versionCreated; - $this->firstByteAt = $firstByteAt; - $this->isDirectory = $this->path[- 1] === '/'; + $this->diskNumber = $diskNumber; + $this->uncompressedSize = $uncompressedSize; + $this->compressedSize = $compressedSize; + $this->crc = $crc; + $this->lastModifiedDate = $lastModifiedDate; + $this->lastModifiedTime = $lastModifiedTime; + $this->compressionMethod = $compressionMethod; + $this->generalPurpose = $generalPurpose; + $this->versionNeeded = $versionNeeded; + $this->versionCreated = $versionCreated; + $this->firstByteAt = $firstByteAt; + $this->isDirectory = $this->path[ - 1 ] === '/'; } public function isFileEntry() { diff --git a/src/WordPress/Zip/ZipEndCentralDirectoryEntry.php b/src/WordPress/Zip/ZipEndCentralDirectoryEntry.php index ed1df1df..d71a2365 100644 --- a/src/WordPress/Zip/ZipEndCentralDirectoryEntry.php +++ b/src/WordPress/Zip/ZipEndCentralDirectoryEntry.php @@ -4,13 +4,34 @@ class ZipEndCentralDirectoryEntry { - public int $diskNumber; - public int $centralDirectoryStartDisk; - public int $numberCentralDirectoryRecordsOnThisDisk; - public int $numberCentralDirectoryRecords; - public int $centralDirectorySize; - public int $centralDirectoryOffset; - public string $comment; + /** + * @var int + */ + public $diskNumber; + /** + * @var int + */ + public $centralDirectoryStartDisk; + /** + * @var int + */ + public $numberCentralDirectoryRecordsOnThisDisk; + /** + * @var int + */ + public $numberCentralDirectoryRecords; + /** + * @var int + */ + public $centralDirectorySize; + /** + * @var int + */ + public $centralDirectoryOffset; + /** + * @var string + */ + public $comment; public function __construct( int $diskNumber, diff --git a/src/WordPress/Zip/ZipFileEntry.php b/src/WordPress/Zip/ZipFileEntry.php index 3b794525..088a525d 100644 --- a/src/WordPress/Zip/ZipFileEntry.php +++ b/src/WordPress/Zip/ZipFileEntry.php @@ -3,18 +3,54 @@ namespace WordPress\Zip; class ZipFileEntry { - public bool $isDirectory; - public int $version; - public int $generalPurpose; - public int $compressionMethod; - public int $lastModifiedTime; - public int $lastModifiedDate; - public int $crc; - public int $compressedSize; - public int $uncompressedSize; - public string $path; - public string $extra; - public string $bytes; + /** + * @var bool + */ + public $isDirectory; + /** + * @var int + */ + public $version; + /** + * @var int + */ + public $generalPurpose; + /** + * @var int + */ + public $compressionMethod; + /** + * @var int + */ + public $lastModifiedTime; + /** + * @var int + */ + public $lastModifiedDate; + /** + * @var int + */ + public $crc; + /** + * @var int + */ + public $compressedSize; + /** + * @var int + */ + public $uncompressedSize; + /** + * @var string + */ + public $path; + /** + * @var string + */ + public $extra; + /** + * @var string + */ + public $bytes; public function __construct( int $version, diff --git a/src/WordPress/Zip/ZipStreamReader.php b/src/WordPress/Zip/ZipStreamReader.php index 053fde5f..af3cca38 100644 --- a/src/WordPress/Zip/ZipStreamReader.php +++ b/src/WordPress/Zip/ZipStreamReader.php @@ -143,7 +143,7 @@ static protected function readCentralDirectoryEntry( $stream ): ZipCentralDirect $data['firstByteAt'] + 30 + $data['pathLength'] + $data['fileCommentLength'] + $data['extraLength'] + $data['compressionMethod'] - 1, $path, $extra, - $fileComment, + $fileComment ); }