From 316488aa332101e9d2f3f9bf28b74cc6abcf432f Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 6 Mar 2024 16:12:44 -0500 Subject: [PATCH] Applying Rector Rules: Part 1 (#509) * Applying AddVoidReturnTypeWhereNoReturnRector * Applying RemoveUselessReturnTagRector and RenameForeachValueVariableToMatchExprVariableRector rules * Applying RemoveUnusedForeachKeyRector and RemoveDuplicatedArrayKeyRector * Applying more RecastingRemovalRector RemoveAndTrueRector SimplifyMirrorAssignRector * Applying rules: RemoveDeadContinueRector RemoveUnusedNonEmptyArrayBeforeForeachRector RemoveNullPropertyInitializationRector RemoveUselessReturnExprInConstructRector RemoveTypedPropertyDeadInstanceOfRector * Applying * Applying RemoveNonExistingVarAnnotationRector RemoveUselessVarTagRector RemovePhpVersionIdCheckRector RemoveAlwaysTrueIfConditionRector RemoveUnusedPrivateClassConstantRector RemoveUnusedPrivatePropertyRector RemoveDuplicatedCaseInSwitchRector RemoveDeadInstanceOfRector RemoveDeadTryCatchRector * Disabling Squiz.Commenting.VariableComment.MissingVar phpcs rule * Enabling a few more --- phpcs.xml | 1 + rector.php | 67 +++++++++---------- src/mantle/application/class-application.php | 22 +----- .../trait-manages-service-providers.php | 4 -- src/mantle/assets/class-asset.php | 8 +-- src/mantle/blocks/class-block.php | 28 -------- src/mantle/blocks/class-discover-blocks.php | 4 +- src/mantle/cache/class-array-repository.php | 4 +- src/mantle/console/class-command.php | 4 -- src/mantle/console/class-output-style.php | 2 +- .../concerns/trait-interacts-with-io.php | 4 -- .../class-lightweight-event-dispatcher.php | 2 - src/mantle/container/class-container.php | 2 - src/mantle/database/factory/class-factory.php | 2 - .../database/factory/class-fluent-factory.php | 2 - .../factory/class-network-factory.php | 2 - .../model/class-permalink-generator.php | 4 -- src/mantle/database/model/class-post.php | 2 - src/mantle/database/model/class-term.php | 2 - .../model/relations/class-relation.php | 2 - .../model/term/class-model-term-proxy.php | 2 - src/mantle/database/query/class-builder.php | 28 +------- .../database/query/class-collection.php | 2 - .../query/class-post-query-builder.php | 10 --- .../query/class-term-query-builder.php | 10 +-- .../query/concerns/trait-queries-dates.php | 2 - .../query/concerns/trait-query-bindings.php | 6 -- .../query/concerns/trait-query-clauses.php | 2 - src/mantle/facade/class-facade.php | 2 - .../filesystem/class-filesystem-adapter.php | 2 - src/mantle/filesystem/trait-file-helpers.php | 2 +- src/mantle/framework/class-alias-loader.php | 2 - src/mantle/framework/class-bootloader.php | 4 -- .../console/class-hook-usage-command.php | 2 +- src/mantle/framework/console/class-kernel.php | 6 -- .../class-package-discover-command.php | 2 - .../console/class-vendor-publish-command.php | 2 - .../console/class-view-cache-command.php | 4 -- .../generators/class-generator-command.php | 2 - .../events/class-events-manifest.php | 2 +- .../framework/exceptions/class-handler.php | 9 +-- .../manifest/class-model-manifest.php | 12 +--- .../class-http-client-exception.php | 2 - .../http-client/class-pending-request.php | 16 ----- src/mantle/http-client/class-pool.php | 2 - src/mantle/http-client/class-request.php | 4 -- src/mantle/http-client/class-response.php | 6 -- src/mantle/http/class-request.php | 4 -- .../http/routing/class-route-registrar.php | 2 - src/mantle/http/routing/class-route.php | 4 -- src/mantle/http/routing/class-router.php | 16 ----- .../http/routing/class-url-generator.php | 10 +-- src/mantle/http/view/class-factory.php | 2 +- src/mantle/log/class-log-manager.php | 4 -- src/mantle/queue/class-closure-job.php | 4 -- src/mantle/queue/class-queue-worker-job.php | 2 - .../admin/class-queue-jobs-table.php | 2 - .../wordpress/class-queue-worker-job.php | 2 - src/mantle/queue/trait-queueable.php | 4 -- src/mantle/rest-api/class-rest-field.php | 2 +- src/mantle/scheduling/class-event.php | 12 +--- src/mantle/scheduling/class-schedule.php | 2 - src/mantle/support/class-environment.php | 2 - src/mantle/support/class-pipeline.php | 2 - src/mantle/support/class-pluralizer.php | 4 +- src/mantle/support/class-reflector.php | 4 +- src/mantle/support/class-service-provider.php | 4 -- src/mantle/support/class-str.php | 4 +- src/mantle/support/class-stringable.php | 4 +- .../support/helpers/helpers-general.php | 4 +- .../testing/class-assertable-json-string.php | 2 - .../testing/class-installation-manager.php | 4 +- .../testing/class-mock-http-sequence.php | 4 -- .../class-pending-testable-request.php | 8 +-- src/mantle/testing/class-test-case.php | 4 -- src/mantle/testing/class-test-command.php | 10 --- src/mantle/testing/class-test-response.php | 10 --- .../concerns/trait-dependency-assertions.php | 2 +- .../testing/concerns/trait-deprecations.php | 2 - .../concerns/trait-element-assertions.php | 2 - .../concerns/trait-interacts-with-hooks.php | 2 - .../concerns/trait-rsync-installation.php | 6 -- .../testing/concerns/trait-with-faker.php | 2 - .../testing/doubles/class-spy-rest-server.php | 4 +- src/mantle/testing/mail/class-mock-mailer.php | 2 +- src/mantle/testkit/class-application.php | 2 +- 86 files changed, 70 insertions(+), 409 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 59892b9eb..800712150 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -30,6 +30,7 @@ + diff --git a/rector.php b/rector.php index e0034e243..89b2704d1 100644 --- a/rector.php +++ b/rector.php @@ -84,40 +84,38 @@ // Dead Code Set /////////////////////////////////////////////////// // easy picks - // RemoveUnusedForeachKeyRector::class, - // RemoveDuplicatedArrayKeyRector::class, - // RecastingRemovalRector::class, - // RemoveAndTrueRector::class, - // SimplifyMirrorAssignRector::class, - // RemoveDeadContinueRector::class, - // RemoveUnusedNonEmptyArrayBeforeForeachRector::class, - // RemoveNullPropertyInitializationRector::class, - // RemoveUselessReturnExprInConstructRector::class, - // RemoveTypedPropertyDeadInstanceOfRector::class, - // TernaryToBooleanOrFalseToBooleanAndRector::class, - // RemoveDoubleAssignRector::class, - // RemoveConcatAutocastRector::class, - // SimplifyIfElseWithSameContentRector::class, - // SimplifyUselessVariableRector::class, - // RemoveDeadZeroAndOneOperationRector::class, + RemoveUnusedForeachKeyRector::class, + RemoveDuplicatedArrayKeyRector::class, + RecastingRemovalRector::class, + RemoveAndTrueRector::class, + SimplifyMirrorAssignRector::class, + RemoveDeadContinueRector::class, + RemoveUnusedNonEmptyArrayBeforeForeachRector::class, + RemoveNullPropertyInitializationRector::class, + RemoveUselessReturnExprInConstructRector::class, + RemoveTypedPropertyDeadInstanceOfRector::class, + TernaryToBooleanOrFalseToBooleanAndRector::class, + RemoveDoubleAssignRector::class, + RemoveConcatAutocastRector::class, + SimplifyIfElseWithSameContentRector::class, + SimplifyUselessVariableRector::class, + RemoveDeadZeroAndOneOperationRector::class, // docblock - // RemoveUselessParamTagRector::class, - // RemoveUselessReturnTagRector::class, - // RemoveNonExistingVarAnnotationRector::class, - // RemoveUselessVarTagRector::class, - // RemovePhpVersionIdCheckRector::class, - // RemoveAlwaysTrueIfConditionRector::class, - // RemoveUnusedPrivateClassConstantRector::class, - // RemoveUnusedPrivatePropertyRector::class, - // RemoveDuplicatedCaseInSwitchRector::class, - // RemoveDeadInstanceOfRector::class, - // RemoveDeadTryCatchRector::class, - // RemoveDeadIfForeachForRector::class, - // RemoveDeadStmtRector::class, - // UnwrapFutureCompatibleIfPhpVersionRector::class, - // RemoveParentCallWithoutParentRector::class, - // RemoveDeadConditionAboveReturnRector::class, - // RemoveDeadLoopRector::class, + RemoveNonExistingVarAnnotationRector::class, + RemoveUselessVarTagRector::class, + RemovePhpVersionIdCheckRector::class, + RemoveAlwaysTrueIfConditionRector::class, + RemoveUnusedPrivateClassConstantRector::class, + RemoveUnusedPrivatePropertyRector::class, + RemoveDuplicatedCaseInSwitchRector::class, + RemoveDeadInstanceOfRector::class, + RemoveDeadTryCatchRector::class, + RemoveDeadIfForeachForRector::class, + RemoveDeadStmtRector::class, + UnwrapFutureCompatibleIfPhpVersionRector::class, + RemoveParentCallWithoutParentRector::class, + RemoveDeadConditionAboveReturnRector::class, + RemoveDeadLoopRector::class, // // removing methods could be risky if there is some magic loading them // RemoveUnusedPromotedPropertyRector::class, // RemoveUnusedPrivateMethodParameterRector::class, @@ -145,5 +143,6 @@ AddVoidReturnTypeWhereNoReturnRector::class => [ __DIR__ . '/src/Mantle/testing/concerns/trait-core-shim.php', __DIR__ . '/tests/Testing/CoreTestShimTest.php', - ] + ], + RemoveUselessParamTagRector::class, ]); diff --git a/src/mantle/application/class-application.php b/src/mantle/application/class-application.php index 5d40da1dc..a4dd44d72 100644 --- a/src/mantle/application/class-application.php +++ b/src/mantle/application/class-application.php @@ -43,36 +43,26 @@ class Application extends Container implements \Mantle\Contracts\Application { /** * Bootstrap path of the application. - * - * @var string|null */ protected ?string $bootstrap_path = null; /** * Storage path of the application. - * - * @var string|null */ protected ?string $storage_path = null; /** * Root URL of the application. - * - * @var string|null */ protected ?string $root_url = null; /** * Indicates if the application has been bootstrapped before. - * - * @var bool */ protected bool $has_been_bootstrapped = false; /** * Indicates if the application has "booted". - * - * @var bool */ protected bool $booted = false; @@ -99,29 +89,21 @@ class Application extends Container implements \Mantle\Contracts\Application { /** * Environment file name. - * - * @var string */ protected string $environment_file = '.env'; /** * The custom environment path defined by the developer. - * - * @var string */ protected ?string $environment_path = null; /** * Storage of the overridden environment name. - * - * @var string */ protected ?string $environment; /** * Indicates if the application is running in the console. - * - * @var bool */ protected ?bool $is_running_in_console = null; @@ -360,7 +342,7 @@ public function get_config_path(): string { * Determine if the application has been bootstrapped before. */ public function has_been_bootstrapped(): bool { - return (bool) $this->has_been_bootstrapped; + return $this->has_been_bootstrapped; } /** @@ -530,7 +512,7 @@ public function environment(): string { * @param string|array ...$environments Environments to check. */ public function is_environment( ...$environments ): bool { - return in_array( $this->environment(), (array) $environments, true ); + return in_array( $this->environment(), $environments, true ); } /** diff --git a/src/mantle/application/concerns/trait-manages-service-providers.php b/src/mantle/application/concerns/trait-manages-service-providers.php index c5a410784..a2fa64ece 100644 --- a/src/mantle/application/concerns/trait-manages-service-providers.php +++ b/src/mantle/application/concerns/trait-manages-service-providers.php @@ -106,10 +106,6 @@ public function register( Service_Provider|string $provider ): static { $provider = new $provider( $this ); } - if ( ! ( $provider instanceof Service_Provider ) ) { - throw new InvalidArgumentException( "Provider is not instance of Service_Provider: {$provider_name}" ); - } - $provider->register(); $this->service_providers[ $provider_name ] = $provider; diff --git a/src/mantle/assets/class-asset.php b/src/mantle/assets/class-asset.php index 15056abef..795944beb 100644 --- a/src/mantle/assets/class-asset.php +++ b/src/mantle/assets/class-asset.php @@ -23,26 +23,20 @@ class Asset { * * @var string */ - protected $media = null; + protected $media; /** * Enqueue on frontend. - * - * @var bool */ protected bool $frontend = true; /** * Enqueue in the admin area. - * - * @var bool */ protected bool $admin = true; /** * Enqueue in the block editor area. - * - * @var bool */ protected bool $block_editor = false; diff --git a/src/mantle/blocks/class-block.php b/src/mantle/blocks/class-block.php index 5b7a4c10e..7b96edad1 100644 --- a/src/mantle/blocks/class-block.php +++ b/src/mantle/blocks/class-block.php @@ -31,43 +31,31 @@ abstract class Block implements Block_Contract { /** * A custom override value for the block's Editor script location. - * - * @var string */ protected string $editor_script = ''; /** * A custom override value for the block's Editor script asset file location. - * - * @var string */ protected string $editor_script_asset = ''; /** * A custom override value for the block's Editor script dependencies. - * - * @var array */ protected array $editor_script_dependencies = []; /** * A custom override value for the block's Editor script handle. - * - * @var string */ protected string $editor_script_handle = ''; /** * A custom override value for the block's Editor style location. - * - * @var string */ protected string $editor_style = ''; /** * A custom override value for the block's Editor style handle. - * - * @var string */ protected string $editor_style_handle = ''; @@ -75,58 +63,42 @@ abstract class Block implements Block_Contract { * The block's entry file without the extension. * * Generally this is going to be an index file (e.g. index.js, index.jsx) - * - * @var string */ protected string $entry_filename = 'index'; /** * A custom override value for the block's Frontend script location. - * - * @var string */ protected string $frontend_script = ''; /** * A custom override value for the block's Frontend script handle. - * - * @var string */ protected string $frontend_script_handle = ''; /** * A custom override value for the block's Frontend style location. - * - * @var string */ protected string $frontend_style = ''; /** * A custom override value for the block's Frontend style handle. - * - * @var string */ protected string $frontend_style_handle = ''; /** * Whether the block is a dynamic block or not. * Default is true. - * - * @var bool */ protected bool $is_dynamic = true; /** * The name of the block. - * - * @var string */ protected string $name = ''; /** * The namespace of the block. - * - * @var string */ protected string $namespace = ''; diff --git a/src/mantle/blocks/class-discover-blocks.php b/src/mantle/blocks/class-discover-blocks.php index 1a388287d..6e236175e 100644 --- a/src/mantle/blocks/class-discover-blocks.php +++ b/src/mantle/blocks/class-discover-blocks.php @@ -81,7 +81,7 @@ protected static function class_from_file( SplFileInfo $file, string $base_path DIRECTORY_SEPARATOR, ); - $classname = str_replace( + return str_replace( [ DIRECTORY_SEPARATOR, ucfirst( basename( app()->get_app_path() ) ) . '\\', @@ -92,7 +92,5 @@ protected static function class_from_file( SplFileInfo $file, string $base_path ], ucfirst( Str::replace_last( '.php', '', $class ) ), ); - - return $classname; } } diff --git a/src/mantle/cache/class-array-repository.php b/src/mantle/cache/class-array-repository.php index b1881a436..f755f2d9a 100644 --- a/src/mantle/cache/class-array-repository.php +++ b/src/mantle/cache/class-array-repository.php @@ -84,7 +84,7 @@ public function put( $key, $value, $ttl = null ): bool { * @return int|bool */ public function increment( $key, $value = 1 ) { - $value = (int) $this->get( $key, 0 ); + $value = $this->get( $key, 0 ); return $this->set( $key, $value += $value ); } @@ -96,7 +96,7 @@ public function increment( $key, $value = 1 ) { * @return int|bool */ public function decrement( $key, $value = 1 ) { - $value = (int) $this->get( $key, 0 ); + $value = $this->get( $key, 0 ); return $this->set( $key, $value -= $value ); } diff --git a/src/mantle/console/class-command.php b/src/mantle/console/class-command.php index 6ca8b04bc..b00e41b3e 100644 --- a/src/mantle/console/class-command.php +++ b/src/mantle/console/class-command.php @@ -59,15 +59,11 @@ abstract class Command extends Symfony_Command { /** * The command's help text. - * - * @var string */ protected string $help; /** * Container instance. - * - * @var \Mantle\Contracts\Application */ protected \Mantle\Contracts\Application $container; diff --git a/src/mantle/console/class-output-style.php b/src/mantle/console/class-output-style.php index f1324a1dc..413cb8f2d 100644 --- a/src/mantle/console/class-output-style.php +++ b/src/mantle/console/class-output-style.php @@ -68,7 +68,7 @@ public function format_xml( array $headers, array $data ): void { $xml = new \SimpleXMLElement( '' ); - foreach ( $data as $headers => $row ) { + foreach ( $data as $row ) { $item = $xml->addChild( 'item' ); foreach ( $row as $key => $value ) { diff --git a/src/mantle/console/concerns/trait-interacts-with-io.php b/src/mantle/console/concerns/trait-interacts-with-io.php index 76e5566ac..d6ff28fd7 100644 --- a/src/mantle/console/concerns/trait-interacts-with-io.php +++ b/src/mantle/console/concerns/trait-interacts-with-io.php @@ -21,15 +21,11 @@ trait Interacts_With_IO { /** * The input implementation. - * - * @var InputInterface */ protected InputInterface $input; /** * Output interface. - * - * @var Output_Style */ protected Output_Style $output; diff --git a/src/mantle/console/events/class-lightweight-event-dispatcher.php b/src/mantle/console/events/class-lightweight-event-dispatcher.php index 82cd06168..6d7d1438e 100644 --- a/src/mantle/console/events/class-lightweight-event-dispatcher.php +++ b/src/mantle/console/events/class-lightweight-event-dispatcher.php @@ -20,8 +20,6 @@ class Lightweight_Event_Dispatcher extends Dispatcher { /** * Event listeners. - * - * @var array */ protected array $listeners = []; diff --git a/src/mantle/container/class-container.php b/src/mantle/container/class-container.php index 9b9f1ac4f..b09eaf07c 100644 --- a/src/mantle/container/class-container.php +++ b/src/mantle/container/class-container.php @@ -24,8 +24,6 @@ class Container implements ArrayAccess, \Mantle\Contracts\Container { /** * The current globally available container (if any). - * - * @var \Mantle\Contracts\Container|null */ protected static ?\Mantle\Contracts\Container $instance; diff --git a/src/mantle/database/factory/class-factory.php b/src/mantle/database/factory/class-factory.php index c879f43a5..a2bb6b25a 100644 --- a/src/mantle/database/factory/class-factory.php +++ b/src/mantle/database/factory/class-factory.php @@ -37,8 +37,6 @@ abstract class Factory { /** * Flag to return the factory as a model. - * - * @var bool */ protected bool $as_models = false; diff --git a/src/mantle/database/factory/class-fluent-factory.php b/src/mantle/database/factory/class-fluent-factory.php index be7e0ed73..bae6618cc 100644 --- a/src/mantle/database/factory/class-fluent-factory.php +++ b/src/mantle/database/factory/class-fluent-factory.php @@ -27,8 +27,6 @@ class Fluent_Factory extends Factory { /** * Number of objects to create. - * - * @var int */ protected int $count = 1; diff --git a/src/mantle/database/factory/class-network-factory.php b/src/mantle/database/factory/class-network-factory.php index 504a04e9f..0b5083e1f 100644 --- a/src/mantle/database/factory/class-network-factory.php +++ b/src/mantle/database/factory/class-network-factory.php @@ -19,8 +19,6 @@ class Network_Factory extends Factory { /** * Network ID tracker. - * - * @var int */ protected int $network_id = 2; diff --git a/src/mantle/database/model/class-permalink-generator.php b/src/mantle/database/model/class-permalink-generator.php index f56eebd55..7d60ff31b 100644 --- a/src/mantle/database/model/class-permalink-generator.php +++ b/src/mantle/database/model/class-permalink-generator.php @@ -20,15 +20,11 @@ class Permalink_Generator { /** * Model instance. - * - * @var Model|null */ protected ?Model $model; /** * Route to generate for. - * - * @var string|null */ protected ?string $route; diff --git a/src/mantle/database/model/class-post.php b/src/mantle/database/model/class-post.php index b2cfb873e..1928817e3 100644 --- a/src/mantle/database/model/class-post.php +++ b/src/mantle/database/model/class-post.php @@ -175,8 +175,6 @@ public static function for( string $post_type ): self { $instance = new class() extends Post { /** * Post type for the model. - * - * @var string */ public static string $for_object_name = ''; diff --git a/src/mantle/database/model/class-term.php b/src/mantle/database/model/class-term.php index 2f48bac4e..074a083a5 100644 --- a/src/mantle/database/model/class-term.php +++ b/src/mantle/database/model/class-term.php @@ -108,8 +108,6 @@ public static function for( string $taxonomy ): self { $instance = new class() extends Term { /** * Object name. - * - * @var string */ public static string $for_object_name = ''; diff --git a/src/mantle/database/model/relations/class-relation.php b/src/mantle/database/model/relations/class-relation.php index 1c127518a..365e25632 100644 --- a/src/mantle/database/model/relations/class-relation.php +++ b/src/mantle/database/model/relations/class-relation.php @@ -43,8 +43,6 @@ abstract class Relation { /** * Parent model instance. - * - * @var Model */ protected Model $parent; diff --git a/src/mantle/database/model/term/class-model-term-proxy.php b/src/mantle/database/model/term/class-model-term-proxy.php index bb6fa6725..afa1d4e00 100644 --- a/src/mantle/database/model/term/class-model-term-proxy.php +++ b/src/mantle/database/model/term/class-model-term-proxy.php @@ -20,8 +20,6 @@ class Model_Term_Proxy { /** * Model to retrieve term from. - * - * @var Post */ protected Post $model; diff --git a/src/mantle/database/query/class-builder.php b/src/mantle/database/query/class-builder.php index 6c14d5e33..c90a99017 100644 --- a/src/mantle/database/query/class-builder.php +++ b/src/mantle/database/query/class-builder.php @@ -46,29 +46,21 @@ abstract class Builder { /** * Result limit per-page. - * - * @var int|null */ protected ?int $limit = 100; /** * Result offset. - * - * @var int */ protected int $offset = 0; /** * Result page. - * - * @var int */ protected int $page = 1; /** * Where arguments for the query. - * - * @var array */ protected array $wheres = []; @@ -88,50 +80,36 @@ abstract class Builder { /** * Meta Query. - * - * @var array */ protected array $meta_query = []; /** * Query Variable Aliases - * - * @var array */ protected array $query_aliases = []; /** * Query Where In Aliases - * - * @var array */ protected array $query_where_in_aliases = []; /** * Query Where Not In Aliases - * - * @var array */ protected array $query_where_not_in_aliases = []; /** * Query order by aliases. - * - * @var array */ protected array $query_order_by_aliases = []; /** * Applied global scopes. - * - * @var array */ protected array $scopes = []; /** * Storage of the found rows for a query. - * - * @var int|null */ protected ?int $found_rows = 0; @@ -144,8 +122,6 @@ abstract class Builder { /** * Query hash for the built query. - * - * @var string */ protected string $query_hash = ''; @@ -234,7 +210,7 @@ public function whereIn( string $attribute, array $values ) { throw new Query_Exception( 'Unknown where in alias: ' . $attribute ); } - return $this->where( $attribute, (array) $values ); + return $this->where( $attribute, $values ); } /** @@ -572,7 +548,7 @@ protected function apply_scopes() { return $this; } - foreach ( $this->scopes as $identifier => $scope ) { + foreach ( $this->scopes as $scope ) { $this->call_scope( function( self $builder ) use ( $scope ) { if ( $scope instanceof Closure ) { diff --git a/src/mantle/database/query/class-collection.php b/src/mantle/database/query/class-collection.php index 913c6284b..6374e4c11 100644 --- a/src/mantle/database/query/class-collection.php +++ b/src/mantle/database/query/class-collection.php @@ -23,8 +23,6 @@ class Collection extends Base_Collection { /** * Total number of rows found for the query. - * - * @var int|null */ public ?int $found_rows = null; diff --git a/src/mantle/database/query/class-post-query-builder.php b/src/mantle/database/query/class-post-query-builder.php index a8ff00de6..e2b80b219 100644 --- a/src/mantle/database/query/class-post-query-builder.php +++ b/src/mantle/database/query/class-post-query-builder.php @@ -36,8 +36,6 @@ class Post_Query_Builder extends Builder { /** * Query Variable Aliases - * - * @var array */ protected array $query_aliases = [ 'date_gmt' => 'post_date_gmt', @@ -55,8 +53,6 @@ class Post_Query_Builder extends Builder { /** * Query Where In Aliases - * - * @var array */ protected array $query_where_in_aliases = [ 'author' => 'author__in', @@ -69,8 +65,6 @@ class Post_Query_Builder extends Builder { /** * Query Where Not In Aliases - * - * @var array */ protected array $query_where_not_in_aliases = [ 'author' => 'author__not_in', @@ -83,8 +77,6 @@ class Post_Query_Builder extends Builder { /** * Query order by aliases. - * - * @var array */ protected array $query_order_by_aliases = [ 'id' => 'ID', @@ -92,8 +84,6 @@ class Post_Query_Builder extends Builder { /** * Tax Query. - * - * @var array */ protected array $tax_query = []; diff --git a/src/mantle/database/query/class-term-query-builder.php b/src/mantle/database/query/class-term-query-builder.php index 17c3cb412..997a85cf0 100644 --- a/src/mantle/database/query/class-term-query-builder.php +++ b/src/mantle/database/query/class-term-query-builder.php @@ -23,8 +23,6 @@ class Term_Query_Builder extends Builder { /** * Query Variable Aliases - * - * @var array */ protected array $query_aliases = [ 'id' => 'include', @@ -33,8 +31,6 @@ class Term_Query_Builder extends Builder { /** * Query Where In Aliases - * - * @var array */ protected array $query_where_in_aliases = [ 'term_id' => 'include', @@ -44,8 +40,6 @@ class Term_Query_Builder extends Builder { /** * Query Where Not In Aliases - * - * @var array */ protected array $query_where_not_in_aliases = [ 'name' => 'name', @@ -55,8 +49,6 @@ class Term_Query_Builder extends Builder { /** * Query order by aliases. - * - * @var array */ protected array $query_order_by_aliases = [ 'id' => 'term_id', @@ -140,7 +132,7 @@ public function count(): int { $this->query_hash = spl_object_hash( $query ); - return (int) $this->with_clauses( + return $this->with_clauses( fn (): int => (int) $query->query( array_merge( $this->get_query_args(), diff --git a/src/mantle/database/query/concerns/trait-queries-dates.php b/src/mantle/database/query/concerns/trait-queries-dates.php index 9e6ba6776..49c05f53d 100644 --- a/src/mantle/database/query/concerns/trait-queries-dates.php +++ b/src/mantle/database/query/concerns/trait-queries-dates.php @@ -32,8 +32,6 @@ trait Queries_Dates { /** * The valid comparison operators for a date query. - * - * @var array */ protected array $date_operators = [ '=', diff --git a/src/mantle/database/query/concerns/trait-query-bindings.php b/src/mantle/database/query/concerns/trait-query-bindings.php index 3eb819b7c..fadb1160f 100644 --- a/src/mantle/database/query/concerns/trait-query-bindings.php +++ b/src/mantle/database/query/concerns/trait-query-bindings.php @@ -23,8 +23,6 @@ trait Query_Bindings { /** * Raw query bindings. - * - * @var array */ protected array $bindings = [ 'where' => [], @@ -32,8 +30,6 @@ trait Query_Bindings { /** * The valid operators for a raw query binding. - * - * @var array */ protected array $operators = [ '=', @@ -50,8 +46,6 @@ trait Query_Bindings { /** * Flag to indicate if a raw query clause has been added. - * - * @var bool */ protected bool $raw_query_clause_added = false; diff --git a/src/mantle/database/query/concerns/trait-query-clauses.php b/src/mantle/database/query/concerns/trait-query-clauses.php index 779033293..a2a8aa436 100644 --- a/src/mantle/database/query/concerns/trait-query-clauses.php +++ b/src/mantle/database/query/concerns/trait-query-clauses.php @@ -31,8 +31,6 @@ trait Query_Clauses { /** * Storage of the term query. - * - * @var \WP_Term_Query|null */ protected ?\WP_Term_Query $query_clause_query = null; diff --git a/src/mantle/facade/class-facade.php b/src/mantle/facade/class-facade.php index 95f336446..bf517b83f 100644 --- a/src/mantle/facade/class-facade.php +++ b/src/mantle/facade/class-facade.php @@ -20,8 +20,6 @@ abstract class Facade { /** * The application instance being facaded. - * - * @var \Mantle\Contracts\Application|null */ protected static ?Application $app = null; diff --git a/src/mantle/filesystem/class-filesystem-adapter.php b/src/mantle/filesystem/class-filesystem-adapter.php index 248621182..5548ed245 100644 --- a/src/mantle/filesystem/class-filesystem-adapter.php +++ b/src/mantle/filesystem/class-filesystem-adapter.php @@ -43,8 +43,6 @@ class Filesystem_Adapter implements Filesystem { /** * Path prefixer. - * - * @var PathPrefixer */ protected PathPrefixer $prefixer; diff --git a/src/mantle/filesystem/trait-file-helpers.php b/src/mantle/filesystem/trait-file-helpers.php index eea7a598b..68948c2f6 100644 --- a/src/mantle/filesystem/trait-file-helpers.php +++ b/src/mantle/filesystem/trait-file-helpers.php @@ -18,7 +18,7 @@ trait File_Helpers { * * @var string */ - protected $hash_name = null; + protected $hash_name; /** * Get the fully qualified path to the file. diff --git a/src/mantle/framework/class-alias-loader.php b/src/mantle/framework/class-alias-loader.php index 0a352c51c..9863a2431 100644 --- a/src/mantle/framework/class-alias-loader.php +++ b/src/mantle/framework/class-alias-loader.php @@ -29,8 +29,6 @@ class Alias_Loader { /** * The singleton instance of the loader. - * - * @var Alias_Loader|null */ protected static ?Alias_Loader $instance = null; diff --git a/src/mantle/framework/class-bootloader.php b/src/mantle/framework/class-bootloader.php index ffc72aad8..9b265f52d 100644 --- a/src/mantle/framework/class-bootloader.php +++ b/src/mantle/framework/class-bootloader.php @@ -29,15 +29,11 @@ class Bootloader implements Contract { /** * Current instance of the manager. - * - * @var Bootloader|null */ protected static ?Bootloader $instance = null; /** * Application base path. - * - * @var string|null */ protected ?string $base_path = null; diff --git a/src/mantle/framework/console/class-hook-usage-command.php b/src/mantle/framework/console/class-hook-usage-command.php index 5fad3efe6..82f55d0b8 100644 --- a/src/mantle/framework/console/class-hook-usage-command.php +++ b/src/mantle/framework/console/class-hook-usage-command.php @@ -194,7 +194,7 @@ protected function read_file( string $file ): Collection { continue; } - foreach ( $matches[1] as $i => $match ) { + foreach ( $matches[1] as $match ) { [ $method, $char_pos ] = $match; $line = Str::line_number( $contents, $char_pos ); diff --git a/src/mantle/framework/console/class-kernel.php b/src/mantle/framework/console/class-kernel.php index f2be73f34..1497266df 100644 --- a/src/mantle/framework/console/class-kernel.php +++ b/src/mantle/framework/console/class-kernel.php @@ -59,22 +59,16 @@ class Kernel implements \Mantle\Contracts\Console\Kernel { /** * Console application. - * - * @var Console_Application_Contract */ protected Console_Application_Contract $console_application; /** * Indicates if the Closure commands have been loaded. - * - * @var bool */ protected bool $commands_loaded = false; /** * Output interface - * - * @var OutputInterface */ protected ?OutputInterface $output; diff --git a/src/mantle/framework/console/class-package-discover-command.php b/src/mantle/framework/console/class-package-discover-command.php index 9affeb2af..a2ccab22c 100644 --- a/src/mantle/framework/console/class-package-discover-command.php +++ b/src/mantle/framework/console/class-package-discover-command.php @@ -30,8 +30,6 @@ class Package_Discover_Command extends Command { /** * Package Manifest. - * - * @var Package_Manifest */ protected Package_Manifest $manifest; diff --git a/src/mantle/framework/console/class-vendor-publish-command.php b/src/mantle/framework/console/class-vendor-publish-command.php index f3abc1e8d..527818692 100644 --- a/src/mantle/framework/console/class-vendor-publish-command.php +++ b/src/mantle/framework/console/class-vendor-publish-command.php @@ -34,8 +34,6 @@ class Vendor_Publish_Command extends Command { /** * Filesystem instance. - * - * @var Filesystem */ protected Filesystem $filesystem; diff --git a/src/mantle/framework/console/class-view-cache-command.php b/src/mantle/framework/console/class-view-cache-command.php index b6396a787..0b4945821 100644 --- a/src/mantle/framework/console/class-view-cache-command.php +++ b/src/mantle/framework/console/class-view-cache-command.php @@ -38,15 +38,11 @@ class View_Cache_Command extends Command { /** * Blade compiler. - * - * @var BladeCompiler */ protected BladeCompiler $blade; /** * View finder. - * - * @var View_Finder */ protected View_Finder $finder; diff --git a/src/mantle/framework/console/generators/class-generator-command.php b/src/mantle/framework/console/generators/class-generator-command.php index 505240858..8081016a0 100644 --- a/src/mantle/framework/console/generators/class-generator-command.php +++ b/src/mantle/framework/console/generators/class-generator-command.php @@ -43,8 +43,6 @@ abstract class Generator_Command extends Command { /** * String replacements. - * - * @var String_Replacements */ protected String_Replacements $replacements; diff --git a/src/mantle/framework/events/class-events-manifest.php b/src/mantle/framework/events/class-events-manifest.php index 3e2d9906b..d2c148ea1 100644 --- a/src/mantle/framework/events/class-events-manifest.php +++ b/src/mantle/framework/events/class-events-manifest.php @@ -24,7 +24,7 @@ class Events_Manifest { * * @var ?array */ - protected $manifest = null; + protected $manifest; /** * Base folder path. diff --git a/src/mantle/framework/exceptions/class-handler.php b/src/mantle/framework/exceptions/class-handler.php index a185f6232..a36eb33ad 100644 --- a/src/mantle/framework/exceptions/class-handler.php +++ b/src/mantle/framework/exceptions/class-handler.php @@ -40,8 +40,6 @@ class Handler implements Contract { /** * The container implementation. - * - * @var Application */ protected Application $container; @@ -94,11 +92,7 @@ public function report( Throwable $e ): void { return; } - try { - $logger = $this->container->make( LoggerInterface::class ); - } catch ( Exception $e ) { - throw $e; - } + $logger = $this->container->make( LoggerInterface::class ); $logger->error( $e->getMessage(), @@ -352,7 +346,6 @@ function ( $trace ) { * @template TThrowable of Throwable * * @param Throwable $e Exception thrown. - * @return bool * @phpstan-param TThrowable $e * @phpstan-return (TThrowable is HttpException ? true : false) */ diff --git a/src/mantle/framework/manifest/class-model-manifest.php b/src/mantle/framework/manifest/class-model-manifest.php index f109a59c0..37a84a92a 100644 --- a/src/mantle/framework/manifest/class-model-manifest.php +++ b/src/mantle/framework/manifest/class-model-manifest.php @@ -23,29 +23,21 @@ class Model_Manifest { /** * Manifest from the disk. - * - * @var array|null */ protected ?array $manifest = null; /** * Base folder path. - * - * @var string */ protected string $base_path; /** * Vendor folder path. - * - * @var string */ protected string $vendor_path; /** * Package Manifest file path. - * - * @var string */ protected string $manifest_path; @@ -74,14 +66,14 @@ public function models() { */ protected function get_manifest(): array { if ( isset( $this->manifest ) ) { - return (array) $this->manifest; + return $this->manifest; } // Skip when the manifest doesn't exist. if ( ! file_exists( $this->manifest_path ) ) { $this->manifest = []; - return (array) $this->manifest; + return $this->manifest; } $this->manifest = include $this->manifest_path; diff --git a/src/mantle/http-client/class-http-client-exception.php b/src/mantle/http-client/class-http-client-exception.php index ae911bb34..07253af6f 100644 --- a/src/mantle/http-client/class-http-client-exception.php +++ b/src/mantle/http-client/class-http-client-exception.php @@ -15,8 +15,6 @@ class Http_Client_Exception extends Exception { /** * Error response. - * - * @var Response */ public Response $response; diff --git a/src/mantle/http-client/class-pending-request.php b/src/mantle/http-client/class-pending-request.php index ba3f8183f..54ec8392e 100644 --- a/src/mantle/http-client/class-pending-request.php +++ b/src/mantle/http-client/class-pending-request.php @@ -22,29 +22,21 @@ class Pending_Request { /** * Base URL for the request. - * - * @var string */ protected string $base_url = ''; /** * Method for the request. - * - * @var string */ public string $method; /** * URL for the request. - * - * @var string */ protected string $url; /** * Options for the request. - * - * @var array */ protected array $options = []; @@ -57,29 +49,21 @@ class Pending_Request { /** * Pending files for the request. - * - * @var array */ protected array $pending_files = []; /** * Body format. - * - * @var string */ protected string $body_format; /** * Middleware for the request. - * - * @var array */ protected array $middleware = []; /** * Flag if the request is for a pooled request. - * - * @var bool */ protected bool $pooled = false; diff --git a/src/mantle/http-client/class-pool.php b/src/mantle/http-client/class-pool.php index 8fd56e495..b8fbe731d 100644 --- a/src/mantle/http-client/class-pool.php +++ b/src/mantle/http-client/class-pool.php @@ -24,8 +24,6 @@ class Pool { /** * Base pending request. - * - * @var Pending_Request */ protected Pending_Request $base_request; diff --git a/src/mantle/http-client/class-request.php b/src/mantle/http-client/class-request.php index a2b98bbaf..a58d10921 100644 --- a/src/mantle/http-client/class-request.php +++ b/src/mantle/http-client/class-request.php @@ -20,15 +20,11 @@ class Request { /** * The request arguments. - * - * @var array */ protected array $args; /** * The request URL. - * - * @var string */ protected string $url; diff --git a/src/mantle/http-client/class-response.php b/src/mantle/http-client/class-response.php index 77dc5d0c3..63af1b1aa 100644 --- a/src/mantle/http-client/class-response.php +++ b/src/mantle/http-client/class-response.php @@ -27,22 +27,16 @@ class Response implements ArrayAccess { /** * Raw response from `wp_remote_request()`. - * - * @var array */ protected array $response; /** * The decoded JSON response. - * - * @var array|null */ protected ?array $decoded; /** * The decoded XML Element response. - * - * @var SimpleXMLElement|null */ protected ?SimpleXMLElement $element; diff --git a/src/mantle/http/class-request.php b/src/mantle/http/class-request.php index a93a5c42b..8b909529c 100644 --- a/src/mantle/http/class-request.php +++ b/src/mantle/http/class-request.php @@ -28,15 +28,11 @@ class Request extends SymfonyRequest implements ArrayAccess, Arrayable { /** * Route parameters. - * - * @var ParameterBag|null */ protected ?ParameterBag $route_parameters = null; /** * The decoded JSON content for the request. - * - * @var ParameterBag|null */ protected ?ParameterBag $json = null; diff --git a/src/mantle/http/routing/class-route-registrar.php b/src/mantle/http/routing/class-route-registrar.php index b76b67cee..4d641ff9b 100644 --- a/src/mantle/http/routing/class-route-registrar.php +++ b/src/mantle/http/routing/class-route-registrar.php @@ -26,8 +26,6 @@ class Route_Registrar { /** * Router instance. - * - * @var Router|null */ protected ?Router $router; diff --git a/src/mantle/http/routing/class-route.php b/src/mantle/http/routing/class-route.php index 193581331..ec550d0be 100644 --- a/src/mantle/http/routing/class-route.php +++ b/src/mantle/http/routing/class-route.php @@ -40,15 +40,11 @@ class Route extends Symfony_Route { /** * Route action. - * - * @var array */ protected array $action; /** * Container instance. - * - * @var Container */ protected Container $container; diff --git a/src/mantle/http/routing/class-router.php b/src/mantle/http/routing/class-router.php index 7894f4eb2..63efcd51e 100644 --- a/src/mantle/http/routing/class-router.php +++ b/src/mantle/http/routing/class-router.php @@ -41,57 +41,41 @@ class Router implements Router_Contract { /** * Events instance. - * - * @var Dispatcher */ protected Dispatcher $events; /** * Container instance. - * - * @var Container */ protected Container $container; /** * Route Collection - * - * @var RouteCollection */ protected RouteCollection $routes; /** * All of the short-hand keys for middlewares. - * - * @var array */ protected array $middleware = []; /** * All of the middleware groups. - * - * @var array */ protected array $middleware_groups = []; /** * The registered route value binders. - * - * @var array */ protected array $binders = []; /** * REST Route Registrar - * - * @var Rest_Route_Registrar|null */ protected ?Rest_Route_Registrar $rest_registrar = null; /** * Data Object Router - * - * @var Entity_Router */ protected Entity_Router $model_router; diff --git a/src/mantle/http/routing/class-url-generator.php b/src/mantle/http/routing/class-url-generator.php index 404990c60..2f53f4322 100644 --- a/src/mantle/http/routing/class-url-generator.php +++ b/src/mantle/http/routing/class-url-generator.php @@ -32,22 +32,16 @@ class Url_Generator extends UrlGenerator implements Generator_Contract { /** * The forced scheme for URLs. - * - * @var string|null */ protected ?string $force_scheme = null; /** * A cached copy of the URL root for the current request. - * - * @var string|null */ protected ?string $cached_root; /** * A cached copy of the URL scheme for the current request. - * - * @var string|null */ protected ?string $cached_scheme = null; @@ -79,7 +73,7 @@ public function set_request( Request $request ) { // Set the host for the request context if it is not already set. if ( empty( $this->context->getHost() ) ) { - $this->context->setHost( (string) parse_url( (string) $this->root_url, PHP_URL_HOST ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url + $this->context->setHost( (string) parse_url( $this->root_url, PHP_URL_HOST ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url } if ( ! $this->context->hasParameter( '_locale' ) ) { @@ -137,7 +131,7 @@ public function to( string $path, array $extra_query = [], array $extra_params = '/', array_map( 'rawurlencode', - (array) $this->format_parameters( $extra_params ) + $this->format_parameters( $extra_params ) ) ); diff --git a/src/mantle/http/view/class-factory.php b/src/mantle/http/view/class-factory.php index b644646db..5c604e68b 100644 --- a/src/mantle/http/view/class-factory.php +++ b/src/mantle/http/view/class-factory.php @@ -68,7 +68,7 @@ class Factory implements ViewFactory { * * @var View|null */ - protected $current = null; + protected $current; /** * The extension to engine bindings. diff --git a/src/mantle/log/class-log-manager.php b/src/mantle/log/class-log-manager.php index 9bc75d77e..3742f8700 100644 --- a/src/mantle/log/class-log-manager.php +++ b/src/mantle/log/class-log-manager.php @@ -38,15 +38,11 @@ class Log_Manager implements LoggerInterface { /** * Dispatcher instance. - * - * @var Dispatcher */ protected ?Dispatcher $dispatcher; /** * Default logger instance for the application. - * - * @var Logger|null */ protected ?Logger $drive; diff --git a/src/mantle/queue/class-closure-job.php b/src/mantle/queue/class-closure-job.php index e2a92886b..022fc614c 100644 --- a/src/mantle/queue/class-closure-job.php +++ b/src/mantle/queue/class-closure-job.php @@ -24,15 +24,11 @@ class Closure_Job implements Can_Queue { /** * The delay before the job will be run. - * - * @var int|DateTimeInterface */ public int|DateTimeInterface $delay; /** * The callbacks that should be run on failure. - * - * @var array */ public array $failure_callbacks = []; diff --git a/src/mantle/queue/class-queue-worker-job.php b/src/mantle/queue/class-queue-worker-job.php index 91fce5149..f05b5c588 100644 --- a/src/mantle/queue/class-queue-worker-job.php +++ b/src/mantle/queue/class-queue-worker-job.php @@ -17,8 +17,6 @@ abstract class Queue_Worker_Job { /** * Flag if the job failed. - * - * @var bool */ public bool $failed = false; diff --git a/src/mantle/queue/providers/wordpress/admin/class-queue-jobs-table.php b/src/mantle/queue/providers/wordpress/admin/class-queue-jobs-table.php index 1f16fe374..7f3bfbffa 100644 --- a/src/mantle/queue/providers/wordpress/admin/class-queue-jobs-table.php +++ b/src/mantle/queue/providers/wordpress/admin/class-queue-jobs-table.php @@ -26,8 +26,6 @@ class Queue_Jobs_Table extends WP_List_Table { /** * Number of items per page. - * - * @var int */ public int $per_page = 50; diff --git a/src/mantle/queue/providers/wordpress/class-queue-worker-job.php b/src/mantle/queue/providers/wordpress/class-queue-worker-job.php index 87f6fa877..e79f03b0b 100644 --- a/src/mantle/queue/providers/wordpress/class-queue-worker-job.php +++ b/src/mantle/queue/providers/wordpress/class-queue-worker-job.php @@ -25,8 +25,6 @@ class Queue_Worker_Job extends \Mantle\Queue\Queue_Worker_Job { /** * Flag if the job failed. - * - * @var bool */ public bool $failed = false; diff --git a/src/mantle/queue/trait-queueable.php b/src/mantle/queue/trait-queueable.php index 5ee4f046b..43ae2f750 100644 --- a/src/mantle/queue/trait-queueable.php +++ b/src/mantle/queue/trait-queueable.php @@ -19,15 +19,11 @@ trait Queueable { /** * The delay before the job will be run. - * - * @var int|DateTimeInterface */ public int|DateTimeInterface $delay; /** * The name of the queue for the job. - * - * @var string */ public string $queue; diff --git a/src/mantle/rest-api/class-rest-field.php b/src/mantle/rest-api/class-rest-field.php index ebe9691ca..8c8b3f949 100644 --- a/src/mantle/rest-api/class-rest-field.php +++ b/src/mantle/rest-api/class-rest-field.php @@ -55,7 +55,7 @@ class REST_Field implements REST_Field_Contract, REST_Field_Schema, REST_Field_G * * @var Closure|string|null */ - protected $update_callback = null; + protected $update_callback; /** * Constructor. diff --git a/src/mantle/scheduling/class-event.php b/src/mantle/scheduling/class-event.php index e60f56af6..59deca135 100644 --- a/src/mantle/scheduling/class-event.php +++ b/src/mantle/scheduling/class-event.php @@ -29,8 +29,6 @@ class Event { /** * The cron expression representing the event's frequency. - * - * @var string */ public string $expression = '* * * * *'; @@ -71,23 +69,17 @@ class Event { /** * The human readable description of the event. - * - * @var string */ public string $description; /** * The exit status code of the command. * 0 for success and 1 for failure. - * - * @var int|null */ public ?int $exit_code; /** * Exception thrown for the command. - * - * @var \Throwable */ public \Throwable $exception; @@ -197,8 +189,8 @@ public function runs_in_environment( $environment ): bool { * @param Application $app Application instance. */ public function filters_pass( Application $app ): bool { - foreach ( $this->filters as $callback ) { - if ( ! $app->call( $callback ) ) { + foreach ( $this->filters as $filter ) { + if ( ! $app->call( $filter ) ) { return false; } } diff --git a/src/mantle/scheduling/class-schedule.php b/src/mantle/scheduling/class-schedule.php index 3bf8cf1bd..3aaa617a7 100644 --- a/src/mantle/scheduling/class-schedule.php +++ b/src/mantle/scheduling/class-schedule.php @@ -39,8 +39,6 @@ class Schedule { /** * Timezone for scheduling. - * - * @var DateTimeZone|null */ protected ?DateTimeZone $timezone = null; diff --git a/src/mantle/support/class-environment.php b/src/mantle/support/class-environment.php index 6ba7c5d1c..bf7b6eabf 100644 --- a/src/mantle/support/class-environment.php +++ b/src/mantle/support/class-environment.php @@ -20,8 +20,6 @@ class Environment { /** * Variable repository. - * - * @var RepositoryInterface|null */ protected static ?RepositoryInterface $repository; diff --git a/src/mantle/support/class-pipeline.php b/src/mantle/support/class-pipeline.php index dc509bb19..36cb1cd6a 100644 --- a/src/mantle/support/class-pipeline.php +++ b/src/mantle/support/class-pipeline.php @@ -22,8 +22,6 @@ class Pipeline implements PipelineContract { /** * The container implementation. - * - * @var Container|null */ protected ?Container $container; diff --git a/src/mantle/support/class-pluralizer.php b/src/mantle/support/class-pluralizer.php index a7680dd0c..3b630b075 100755 --- a/src/mantle/support/class-pluralizer.php +++ b/src/mantle/support/class-pluralizer.php @@ -17,8 +17,6 @@ class Pluralizer { /** * The cached inflector instance. - * - * @var Inflector|null */ protected static ?Inflector $inflector = null; @@ -52,7 +50,7 @@ public static function plural( string $value, int|array|\Countable $count = 2 ): $count = count( $count ); } - if ( (int) abs( $count ) === 1 || static::uncountable( $value ) || preg_match( '/^(.*)[A-Za-z0-9\x{0080}-\x{FFFF}]$/u', $value ) == 0 ) { + if ( abs( $count ) === 1 || static::uncountable( $value ) || preg_match( '/^(.*)[A-Za-z0-9\x{0080}-\x{FFFF}]$/u', $value ) == 0 ) { return $value; } diff --git a/src/mantle/support/class-reflector.php b/src/mantle/support/class-reflector.php index c35b7e6b4..6328ececf 100644 --- a/src/mantle/support/class-reflector.php +++ b/src/mantle/support/class-reflector.php @@ -103,8 +103,6 @@ protected static function get_type_name( $parameter, $type ) { public static function is_parameter_subclass_of( $parameter, $class_name ) { $param_class_name = static::get_parameter_class_name( $parameter ); - return ( $param_class_name && class_exists( $param_class_name ) ) - ? ( new ReflectionClass( $param_class_name ) )->isSubclassOf( $class_name ) - : false; + return $param_class_name && class_exists( $param_class_name ) && ( new ReflectionClass( $param_class_name ) )->isSubclassOf( $class_name ); } } diff --git a/src/mantle/support/class-service-provider.php b/src/mantle/support/class-service-provider.php index 85be9c015..160672871 100644 --- a/src/mantle/support/class-service-provider.php +++ b/src/mantle/support/class-service-provider.php @@ -24,15 +24,11 @@ abstract class Service_Provider implements LoggerAwareInterface { /** * The paths that should be published. - * - * @var array */ public static array $publishes = []; /** * The paths that should be published by group. - * - * @var array */ public static array $publish_tags = []; diff --git a/src/mantle/support/class-str.php b/src/mantle/support/class-str.php index bee2a16d3..bb42d7b05 100644 --- a/src/mantle/support/class-str.php +++ b/src/mantle/support/class-str.php @@ -1030,11 +1030,9 @@ public static function remove( $search, $subject, bool $case_sensitive = true ) $search = collect( $search )->all(); } - $subject = $case_sensitive + return $case_sensitive ? str_replace( $search, '', $subject ) : str_ireplace( $search, '', $subject ); - - return $subject; } /** diff --git a/src/mantle/support/class-stringable.php b/src/mantle/support/class-stringable.php index 58d5e82b3..bd1fcac8b 100644 --- a/src/mantle/support/class-stringable.php +++ b/src/mantle/support/class-stringable.php @@ -29,8 +29,6 @@ class Stringable implements ArrayAccess, JsonSerializable, \Stringable { /** * The underlying string value. - * - * @var string */ protected string $value = ''; @@ -1201,6 +1199,6 @@ public function __get( $key ) { * @return string */ public function __toString() { - return (string) $this->value; + return $this->value; } } diff --git a/src/mantle/support/helpers/helpers-general.php b/src/mantle/support/helpers/helpers-general.php index 4dbbaa21c..ce17e5c73 100644 --- a/src/mantle/support/helpers/helpers-general.php +++ b/src/mantle/support/helpers/helpers-general.php @@ -200,7 +200,7 @@ function preg_replace_array( $pattern, array $replacements, $subject ) { return preg_replace_callback( $pattern, function () use ( &$replacements ) { - foreach ( $replacements as $key => $value ) { + foreach ( $replacements as $replacement ) { return array_shift( $replacements ); } }, @@ -265,7 +265,7 @@ public function __toString() { }; } - return Str::of( (string) $string ); + return Str::of( $string ); } /** diff --git a/src/mantle/testing/class-assertable-json-string.php b/src/mantle/testing/class-assertable-json-string.php index 0dc24ab17..69f2fa2bb 100644 --- a/src/mantle/testing/class-assertable-json-string.php +++ b/src/mantle/testing/class-assertable-json-string.php @@ -30,8 +30,6 @@ class Assertable_Json_String implements ArrayAccess, Countable { /** * The decoded JSON contents. - * - * @var array|null */ protected ?array $decoded; diff --git a/src/mantle/testing/class-installation-manager.php b/src/mantle/testing/class-installation-manager.php index 3017b8ae3..6115b52d2 100644 --- a/src/mantle/testing/class-installation-manager.php +++ b/src/mantle/testing/class-installation-manager.php @@ -200,8 +200,8 @@ public function install() { return $this; } - foreach ( $this->before_install_callbacks as $callback ) { - $callback(); + foreach ( $this->before_install_callbacks as $before_install_callback ) { + $before_install_callback(); } try { diff --git a/src/mantle/testing/class-mock-http-sequence.php b/src/mantle/testing/class-mock-http-sequence.php index 827844f03..9b43d289e 100644 --- a/src/mantle/testing/class-mock-http-sequence.php +++ b/src/mantle/testing/class-mock-http-sequence.php @@ -21,15 +21,11 @@ class Mock_Http_Sequence { /** * Indicates that invoking this sequence when it is empty should throw an * exception. - * - * @var bool */ protected bool $fail_when_empty = true; /** * Empty response when the sequence is empty. - * - * @var Mock_Http_Response|null */ protected ?Mock_Http_Response $empty_response = null; diff --git a/src/mantle/testing/class-pending-testable-request.php b/src/mantle/testing/class-pending-testable-request.php index 5da0e3650..79fc4270f 100644 --- a/src/mantle/testing/class-pending-testable-request.php +++ b/src/mantle/testing/class-pending-testable-request.php @@ -38,22 +38,16 @@ class Pending_Testable_Request { /** * Indicates whether redirects should be followed. - * - * @var bool */ public bool $follow_redirects = false; /** * The headers for the request. - * - * @var HeaderBag */ public HeaderBag $headers; /** * The cookies for the request. - * - * @var InputBag */ public InputBag $cookies; @@ -322,7 +316,7 @@ public function call( string $method, mixed $uri, array $parameters = [], array ob_end_clean(); $response_content = $this->rest_api_response['body']; - $response_headers = array_merge( (array) $response_headers, (array) $this->rest_api_response['headers'] ); + $response_headers = array_merge( (array) $response_headers, $this->rest_api_response['headers'] ); } else { try { // Execute the request, inasmuch as WordPress would. diff --git a/src/mantle/testing/class-test-case.php b/src/mantle/testing/class-test-case.php index 884e8ccd7..10714b15f 100644 --- a/src/mantle/testing/class-test-case.php +++ b/src/mantle/testing/class-test-case.php @@ -73,15 +73,11 @@ abstract class Test_Case extends BaseTestCase { /** * Application instance. - * - * @var Application|null */ protected ?Application $app = null; /** * Factory Instance. - * - * @var Factory_Container|null */ protected static ?Factory_Container $factory; diff --git a/src/mantle/testing/class-test-command.php b/src/mantle/testing/class-test-command.php index ccc2095d9..5e6239190 100644 --- a/src/mantle/testing/class-test-command.php +++ b/src/mantle/testing/class-test-command.php @@ -25,36 +25,26 @@ class Test_Command { /** * Instance of the Command Tester. - * - * @var CommandTester */ protected CommandTester $tester; /** * Flag if the command has been executed. - * - * @var boolean */ protected bool $has_executed = false; /** * All of the expected output lines. - * - * @var array */ public array $expected_output = []; /** * All of the output lines that aren't expected to be displayed. - * - * @var array */ public array $unexpected_output = []; /** * Expected exit code. - * - * @var int */ public ?int $expected_exit_code = null; diff --git a/src/mantle/testing/class-test-response.php b/src/mantle/testing/class-test-response.php index 6fa38432a..8e71f4315 100644 --- a/src/mantle/testing/class-test-response.php +++ b/src/mantle/testing/class-test-response.php @@ -23,36 +23,26 @@ class Test_Response { /** * Application instance. - * - * @var Application */ protected Application $app; /** * Response headers. - * - * @var array */ public array $headers; /** * Response content. - * - * @var string */ protected string $content; /** * Response status code. - * - * @var int */ protected int $status_code; /** * Assertable JSON string. - * - * @var Assertable_Json_String */ protected Assertable_Json_String $decoded_json; diff --git a/src/mantle/testing/concerns/trait-dependency-assertions.php b/src/mantle/testing/concerns/trait-dependency-assertions.php index 0a6aa3d2a..71cbfbdc3 100644 --- a/src/mantle/testing/concerns/trait-dependency-assertions.php +++ b/src/mantle/testing/concerns/trait-dependency-assertions.php @@ -60,7 +60,7 @@ public static function assertDependencyLoaded( string $dependency ): void { ->count() > 0, sprintf( '%s dependency not found in included files.', - (string) $dependency + $dependency ) ); } diff --git a/src/mantle/testing/concerns/trait-deprecations.php b/src/mantle/testing/concerns/trait-deprecations.php index c7495afef..f14ade2fc 100644 --- a/src/mantle/testing/concerns/trait-deprecations.php +++ b/src/mantle/testing/concerns/trait-deprecations.php @@ -41,8 +41,6 @@ trait Deprecations { /** * Trace storage for deprecated calls. - * - * @var array */ private array $caught_deprecated_traces = []; diff --git a/src/mantle/testing/concerns/trait-element-assertions.php b/src/mantle/testing/concerns/trait-element-assertions.php index 379ae46de..3c62b703d 100644 --- a/src/mantle/testing/concerns/trait-element-assertions.php +++ b/src/mantle/testing/concerns/trait-element-assertions.php @@ -18,8 +18,6 @@ trait Element_Assertions { /** * DOM Document Storage. - * - * @var DOMDocument */ protected DOMDocument $document; diff --git a/src/mantle/testing/concerns/trait-interacts-with-hooks.php b/src/mantle/testing/concerns/trait-interacts-with-hooks.php index 97a10da79..5315cd016 100644 --- a/src/mantle/testing/concerns/trait-interacts-with-hooks.php +++ b/src/mantle/testing/concerns/trait-interacts-with-hooks.php @@ -26,8 +26,6 @@ trait Interacts_With_Hooks { /** * Expectation Container - * - * @var Expectation_Container|null */ protected ?Expectation_Container $expectation_container; diff --git a/src/mantle/testing/concerns/trait-rsync-installation.php b/src/mantle/testing/concerns/trait-rsync-installation.php index 44d4a381e..c27af5aab 100644 --- a/src/mantle/testing/concerns/trait-rsync-installation.php +++ b/src/mantle/testing/concerns/trait-rsync-installation.php @@ -34,23 +34,17 @@ trait Rsync_Installation { /** * Storage location to rsync the codebase to. - * - * @var string */ protected ?string $rsync_to = null; /** * Storage location to rsync the codebase from. - * - * @var string */ protected ?string $rsync_from = null; /** * Subdirectory from the parent folder being rsync-ed to the previous working * directory. - * - * @var string */ protected ?string $rsync_subdir = ''; diff --git a/src/mantle/testing/concerns/trait-with-faker.php b/src/mantle/testing/concerns/trait-with-faker.php index aabb096e6..3a1171983 100644 --- a/src/mantle/testing/concerns/trait-with-faker.php +++ b/src/mantle/testing/concerns/trait-with-faker.php @@ -17,8 +17,6 @@ trait With_Faker { /** * Faker instance. - * - * @var Generator */ protected Generator $faker; diff --git a/src/mantle/testing/doubles/class-spy-rest-server.php b/src/mantle/testing/doubles/class-spy-rest-server.php index d4fa46949..2bbc37905 100644 --- a/src/mantle/testing/doubles/class-spy-rest-server.php +++ b/src/mantle/testing/doubles/class-spy-rest-server.php @@ -7,8 +7,8 @@ class Spy_REST_Server extends WP_REST_Server { public array $sent_headers = []; - public $sent_body = null; - public $last_request = null; + public $sent_body; + public $last_request; public $override_by_default = false; /** diff --git a/src/mantle/testing/mail/class-mock-mailer.php b/src/mantle/testing/mail/class-mock-mailer.php index 6aa19a12b..f8b50f227 100644 --- a/src/mantle/testing/mail/class-mock-mailer.php +++ b/src/mantle/testing/mail/class-mock-mailer.php @@ -58,7 +58,7 @@ public function postSend() { * @return object|false */ public function get_sent( $index = 0 ) { - return isset( $this->mock_sent[ $index ] ) ? (object) $this->mock_sent[ $index ] : false; + return isset( $this->mock_sent[ $index ] ) ? $this->mock_sent[ $index ] : false; } /** diff --git a/src/mantle/testkit/class-application.php b/src/mantle/testkit/class-application.php index b2ec0a4a0..b7e78bbe4 100644 --- a/src/mantle/testkit/class-application.php +++ b/src/mantle/testkit/class-application.php @@ -408,7 +408,7 @@ public function environment(): string { * @param string|array ...$environments Environments to check. */ public function is_environment( ...$environments ): bool { - return in_array( $this->environment(), (array) $environments, true ); + return in_array( $this->environment(), $environments, true ); } /**