From 7a8769e1edcce089872f828ae0b3531514c54d8e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 16 Feb 2025 16:04:35 +0700 Subject: [PATCH 1/9] Enable Rector php 8.0 set --- lib/ar-softdelete/src/SoftDeleteBehavior.php | 2 +- .../src/SoftDeleteQueryBehavior.php | 8 +-- lib/yii2/Yii.php | 2 +- rector.php | 15 +++- src/Craft.php | 1 - src/auth/sso/BaseExternalProvider.php | 1 - src/auth/sso/mapper/SetUserValueTrait.php | 1 - src/auth/sso/mapper/UserMapInterface.php | 1 - src/base/Element.php | 16 ++--- src/base/ElementInterface.php | 2 - src/base/Field.php | 2 +- src/base/MemoizableArray.php | 11 +-- src/base/NestedElementTrait.php | 15 ++-- src/base/PreviewableFieldInterface.php | 1 - src/base/conditions/BaseCondition.php | 10 +-- src/base/conditions/BaseConditionRule.php | 2 +- .../conditions/BaseDateRangeConditionRule.php | 6 -- src/base/conditions/BaseTextConditionRule.php | 1 - src/behaviors/FieldLayoutBehavior.php | 2 +- src/cache/ElementQueryTagDependency.php | 8 +-- src/config/GeneralConfig.php | 28 -------- src/console/controllers/MigrateController.php | 4 +- .../controllers/ProjectConfigController.php | 18 ++--- src/console/controllers/SetupController.php | 1 - .../controllers/utils/RepairController.php | 1 - src/controllers/AppController.php | 2 +- src/controllers/BaseUpdaterController.php | 12 ++-- src/controllers/DashboardController.php | 6 +- src/controllers/ElementIndexesController.php | 8 +-- src/controllers/ElementsController.php | 3 +- src/controllers/FieldsController.php | 6 +- src/controllers/QueueController.php | 2 +- src/controllers/SystemSettingsController.php | 6 +- src/db/CoalesceColumnsExpression.php | 8 +-- src/db/FixedOrderExpression.php | 23 +----- src/db/MigrationManager.php | 2 +- src/db/Paginator.php | 9 +-- src/db/Query.php | 5 -- src/db/QueryParam.php | 1 - src/debug/LogTarget.php | 2 +- src/debug/MailPanel.php | 1 - src/elements/Address.php | 10 ++- src/elements/Asset.php | 70 ++++++++----------- src/elements/Category.php | 16 ++--- src/elements/Entry.php | 2 +- src/elements/GlobalSet.php | 2 +- src/elements/NestedElementManager.php | 2 +- src/elements/actions/ChangeSortOrder.php | 2 +- src/elements/db/ElementQuery.php | 26 ++----- .../db/ElementRelationParamParser.php | 4 -- src/elements/db/EntryQuery.php | 19 ++--- src/elements/db/NestedElementQueryTrait.php | 20 ++---- src/errors/ElementException.php | 8 +-- src/errors/FieldNotFoundException.php | 8 +-- src/errors/InvalidHtmlTagException.php | 27 +------ src/errors/InvalidLicenseKeyException.php | 11 +-- src/errors/InvalidPluginException.php | 11 +-- src/errors/InvalidSubpathException.php | 11 +-- src/errors/InvalidTypeException.php | 17 +---- src/errors/MigrateException.php | 17 +---- src/errors/MigrationException.php | 17 +---- src/errors/MissingAssetException.php | 26 +------ src/errors/MissingVolumeFolderException.php | 20 +----- src/errors/ShellCommandException.php | 23 +----- src/errors/SsoFailedException.php | 14 +--- src/errors/UnsupportedSiteException.php | 11 +-- src/errors/UploadFailedException.php | 11 +-- src/errors/UserLockedException.php | 8 +-- src/events/AuthorizationCheckEvent.php | 8 +-- src/events/CreateElementCheckEvent.php | 8 +-- src/events/FsEvent.php | 8 +-- src/fieldlayoutelements/BaseField.php | 1 - src/fieldlayoutelements/CustomField.php | 2 +- src/fieldlayoutelements/Html.php | 5 +- src/fields/BaseOptionsField.php | 1 - src/fields/Lightswitch.php | 1 - src/fields/Money.php | 1 - src/fields/Number.php | 3 +- src/fields/Range.php | 1 - src/fields/Table.php | 1 - src/fields/data/ColorData.php | 12 +--- src/fields/data/LinkData.php | 2 +- src/fields/data/MultiOptionsFieldData.php | 1 - src/fields/data/OptionData.php | 38 +++------- src/fields/linktypes/Url.php | 2 +- src/gql/ElementQueryConditionBuilder.php | 1 - src/gql/GqlEntityRegistry.php | 1 - src/gql/base/ArgumentHandler.php | 1 - src/gql/base/ElementResolver.php | 4 -- src/gql/base/Generator.php | 1 - src/gql/base/MutationResolver.php | 20 +----- src/gql/resolvers/mutations/Asset.php | 4 -- src/gql/resolvers/mutations/Category.php | 4 -- src/gql/resolvers/mutations/Entry.php | 8 --- src/gql/resolvers/mutations/GlobalSet.php | 2 - src/gql/resolvers/mutations/Tag.php | 4 -- src/gql/types/input/Addresses.php | 1 - src/gql/types/input/Matrix.php | 1 - src/helpers/App.php | 4 +- src/helpers/ArrayHelper.php | 5 +- src/helpers/Assets.php | 1 - src/helpers/ConfigHelper.php | 1 - src/helpers/Cp.php | 8 +-- src/helpers/DateTimeHelper.php | 1 - src/helpers/Db.php | 2 +- src/helpers/Diff.php | 6 -- src/helpers/ElementHelper.php | 2 +- src/helpers/FileHelper.php | 4 +- src/helpers/Gql.php | 5 -- src/helpers/Html.php | 2 - src/helpers/ImageTransforms.php | 1 - src/helpers/MailerHelper.php | 3 +- src/helpers/MoneyHelper.php | 4 -- src/helpers/Number.php | 2 - src/helpers/ProjectConfig.php | 2 - src/helpers/Session.php | 2 +- src/helpers/StringHelper.php | 4 +- src/helpers/Template.php | 2 +- src/i18n/Formatter.php | 6 +- src/i18n/Locale.php | 43 ++++-------- .../BaseContentRefactorMigration.php | 29 ++------ src/models/AssetIndexData.php | 2 +- src/models/CategoryGroup.php | 3 +- src/models/EntryType.php | 3 +- src/models/FieldLayoutTab.php | 2 +- src/models/GqlSchema.php | 4 +- src/models/GqlToken.php | 4 +- src/models/ImageTransform.php | 2 +- src/models/ImageTransformIndex.php | 2 +- src/models/ProjectConfigData.php | 3 - src/models/ReadOnlyProjectConfigData.php | 5 +- src/models/Section.php | 2 +- src/models/Site.php | 2 +- src/models/SiteGroup.php | 2 +- src/models/TagGroup.php | 2 +- src/models/UserGroup.php | 2 +- src/models/VolumeFolder.php | 2 +- src/queue/BaseBatchedJob.php | 2 - src/queue/jobs/ApplyNewPropagationMethod.php | 2 +- src/queue/jobs/PropagateElements.php | 2 +- src/search/SearchQuery.php | 10 +-- src/search/SearchQueryTermGroup.php | 8 +-- src/services/Assets.php | 7 +- src/services/Auth.php | 2 +- src/services/Dashboard.php | 2 +- src/services/Deprecator.php | 4 +- src/services/Elements.php | 24 +++---- src/services/Fields.php | 6 +- src/services/Fs.php | 2 +- src/services/Gql.php | 1 - src/services/ProjectConfig.php | 4 +- src/services/Revisions.php | 2 +- src/services/Security.php | 1 - src/services/Sso.php | 1 - src/test/Craft.php | 3 +- src/test/CraftConnector.php | 2 +- src/test/TestCase.php | 3 +- src/test/console/CommandTest.php | 35 ++-------- src/test/mockclasses/ToString.php | 12 +--- src/utilities/SystemReport.php | 2 +- src/validators/UrlValidator.php | 2 +- src/web/Controller.php | 2 +- src/web/ErrorHandler.php | 2 +- src/web/Request.php | 4 +- src/web/UrlManager.php | 2 +- src/web/UrlRule.php | 2 +- src/web/View.php | 5 +- src/web/twig/Extension.php | 37 +--------- src/web/twig/TemplateLoader.php | 8 +-- src/web/twig/TemplateLoaderException.php | 8 +-- src/web/twig/nodevisitors/GetAttrAdjuster.php | 2 +- .../RegisterResourceTokenParser.php | 15 +--- src/web/twig/variables/Image.php | 14 +--- tests/unit/config/GeneralConfigTest.php | 1 - tests/unit/db/QueryParamTest.php | 1 - tests/unit/elements/ElementCollectionTest.php | 14 ++-- tests/unit/elements/db/ElementQueryTest.php | 3 - .../db/ElementRelationParamParserTest.php | 2 - tests/unit/fields/MoneyTest.php | 2 - tests/unit/gql/DirectiveTest.php | 1 - tests/unit/gql/ElementFieldResolverTest.php | 2 - tests/unit/gql/ScalarTypesTest.php | 5 -- tests/unit/helpers/AppHelperTest.php | 4 -- tests/unit/helpers/ArrayHelperTest.php | 8 --- tests/unit/helpers/AssetsHelperTest.php | 1 - tests/unit/helpers/ConfigHelperTest.php | 3 - tests/unit/helpers/DateTimeHelperTest.php | 8 --- tests/unit/helpers/DiffHelperTest.php | 4 -- tests/unit/helpers/GqlHelperTest.php | 2 - tests/unit/helpers/JsonHelperTest.php | 1 - tests/unit/helpers/LocalizationHelperTest.php | 2 - tests/unit/helpers/MoneyHelperTest.php | 7 -- tests/unit/helpers/NumberHelperTest.php | 3 - .../unit/helpers/ProjectConfigHelperTest.php | 1 - tests/unit/helpers/StringHelperTest.php | 1 - tests/unit/helpers/TypecastHelperTest.php | 2 - tests/unit/helpers/dbhelper/DbHelperTest.php | 4 -- .../helpers/dbhelper/MysqlDbHelperTest.php | 1 - .../helpers/dbhelper/PgsqlDbHelperTest.php | 1 - tests/unit/i18n/FormatterTest.php | 1 - tests/unit/services/ProjectConfigTest.php | 2 - tests/unit/services/SearchTest.php | 1 - tests/unit/services/SecurityTest.php | 2 - tests/unit/validators/ArrayValidatorTest.php | 1 - .../unit/validators/PasswordValidatorTest.php | 1 - tests/unit/validators/UriValidatorTest.php | 1 - tests/unit/web/RequestTest.php | 3 - tests/unit/web/ResponseTest.php | 1 - tests/unit/web/ViewTest.php | 4 -- 209 files changed, 308 insertions(+), 1029 deletions(-) diff --git a/lib/ar-softdelete/src/SoftDeleteBehavior.php b/lib/ar-softdelete/src/SoftDeleteBehavior.php index c842ddeb024..d654962b2dc 100644 --- a/lib/ar-softdelete/src/SoftDeleteBehavior.php +++ b/lib/ar-softdelete/src/SoftDeleteBehavior.php @@ -532,7 +532,7 @@ private function detectRestoreAttributeValues() } elseif (!is_scalar($value) && is_callable($value)) { $restoreValue = null; } else { - throw new InvalidConfigException('Unable to automatically determine restore attribute values, "' . get_class($this) . '::$restoreAttributeValues" should be explicitly set.'); + throw new InvalidConfigException('Unable to automatically determine restore attribute values, "' . static::class . '::$restoreAttributeValues" should be explicitly set.'); } $restoreAttributeValues[$name] = $restoreValue; } diff --git a/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php b/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php index f95660c1665..0c51f2e2ce5 100644 --- a/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php +++ b/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php @@ -183,7 +183,7 @@ public function notDeleted() * @param mixed $deleted filter value. * @return \yii\db\ActiveQueryInterface|static */ - public function filterDeleted($deleted) + public function filterDeleted(mixed $deleted) { if ($deleted === '' || $deleted === null || $deleted === []) { return $this->notDeleted(); @@ -259,7 +259,7 @@ protected function defaultNotDeletedCondition() } elseif (!is_scalar($value) && is_callable($value)) { $restoreValue = null; } else { - throw new InvalidConfigException('Unable to automatically determine not delete condition, "' . get_class($this) . '::$notDeletedCondition" should be explicitly set.'); + throw new InvalidConfigException('Unable to automatically determine not delete condition, "' . static::class . '::$notDeletedCondition" should be explicitly set.'); } $condition[$attribute] = $restoreValue; @@ -297,12 +297,12 @@ protected function normalizeFilterCondition($condition) $alias = array_keys($fromTables)[0]; foreach ($condition as $attribute => $value) { - if (is_numeric($attribute) || strpos($attribute, '.') !== false) { + if (is_numeric($attribute) || str_contains($attribute, '.')) { continue; } unset($condition[$attribute]); - if (strpos($attribute, '[[') === false) { + if (!str_contains($attribute, '[[')) { $attribute = '[[' . $attribute . ']]'; } $attribute = $alias . '.' . $attribute; diff --git a/lib/yii2/Yii.php b/lib/yii2/Yii.php index 7d1d41a9565..40eb0c94638 100644 --- a/lib/yii2/Yii.php +++ b/lib/yii2/Yii.php @@ -58,7 +58,7 @@ public static function alias(string $path): string $path = FileHelper::normalizePath($path); foreach (self::$_aliasPaths as $alias => $aliasPath) { - if (strpos($path . DIRECTORY_SEPARATOR, $aliasPath . DIRECTORY_SEPARATOR) === 0) { + if (str_starts_with($path . DIRECTORY_SEPARATOR, $aliasPath . DIRECTORY_SEPARATOR)) { return $alias . str_replace('\\', '/', substr($path, strlen($aliasPath))); } } diff --git a/rector.php b/rector.php index c86ed8ecc46..eac11cc86d2 100644 --- a/rector.php +++ b/rector.php @@ -5,6 +5,8 @@ use Rector\Config\RectorConfig; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; +use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; +use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; return RectorConfig::configure() ->withPaths([ @@ -24,5 +26,16 @@ ClosureToArrowFunctionRector::class => [ __DIR__ . '/src/base/ApplicationTrait.php', ], + + // used by finally and next if + RemoveUnusedVariableInCatchRector::class => [ + __DIR__ . '/src/console/controllers/PluginController.php', + __DIR__ . '/src/helpers/DateTimeHelper.php', + ], + + // object check + ChangeSwitchToMatchRector::class => [ + __DIR__ . '/src/elements/Entry.php', + ], ]) - ->withPhpSets(php74: true); + ->withPhpSets(php80: true); diff --git a/src/Craft.php b/src/Craft.php index 02dd30114df..9025dd58b9b 100644 --- a/src/Craft.php +++ b/src/Craft.php @@ -106,7 +106,6 @@ public static function parseEnv(?string $str = null): string|null|false * $status = Craft::parseBooleanEnv('$SYSTEM_STATUS') ?? false; * ``` * - * @param mixed $value * @return bool|null * @since 3.7.22 * @deprecated in 3.7.29. [[App::parseBooleanEnv()]] should be used instead. diff --git a/src/auth/sso/BaseExternalProvider.php b/src/auth/sso/BaseExternalProvider.php index 1c0d12d29b9..152e7c47af8 100644 --- a/src/auth/sso/BaseExternalProvider.php +++ b/src/auth/sso/BaseExternalProvider.php @@ -334,7 +334,6 @@ protected function populateUser(User $user, array $data): User /** * Normalize a callback * - * @param mixed $callback * @param string|null $defaultClass * @return callable|null * @throws \yii\base\InvalidConfigException diff --git a/src/auth/sso/mapper/SetUserValueTrait.php b/src/auth/sso/mapper/SetUserValueTrait.php index 4cd254ca5fb..7a56fa87691 100644 --- a/src/auth/sso/mapper/SetUserValueTrait.php +++ b/src/auth/sso/mapper/SetUserValueTrait.php @@ -28,7 +28,6 @@ trait SetUserValueTrait * Set a value on a user; determine if we're setting a field value or property * * @param User $user - * @param mixed $value * @return void */ protected function setValue(User $user, mixed $value): void diff --git a/src/auth/sso/mapper/UserMapInterface.php b/src/auth/sso/mapper/UserMapInterface.php index 8515391a842..81bcfe00eb7 100644 --- a/src/auth/sso/mapper/UserMapInterface.php +++ b/src/auth/sso/mapper/UserMapInterface.php @@ -18,7 +18,6 @@ interface UserMapInterface { /** * @param User $user - * @param mixed $data * @return User */ public function __invoke(User $user, mixed $data): User; diff --git a/src/base/Element.php b/src/base/Element.php index 1427b628cb5..3c430d1b645 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -2526,7 +2526,7 @@ public function __toString(): string public function __isset($name): bool { // Is this the "field:handle" syntax? - if (strncmp($name, 'field:', 6) === 0) { + if (str_starts_with($name, 'field:')) { return $this->fieldByHandle(substr($name, 6)) !== null; } @@ -2544,7 +2544,7 @@ public function __get($name) } // Is this the "field:handle" syntax? - if (strncmp($name, 'field:', 6) === 0) { + if (str_starts_with($name, 'field:')) { return $this->getFieldValue(substr($name, 6)); } @@ -2562,7 +2562,7 @@ public function __get($name) public function __set($name, $value) { // Is this the "field:handle" syntax? - if (strncmp($name, 'field:', 6) === 0) { + if (str_starts_with($name, 'field:')) { $this->setFieldValue(substr($name, 6), $value); return; } @@ -2584,7 +2584,7 @@ public function __set($name, $value) */ public function __call($name, $params) { - if (strncmp($name, 'isFieldEmpty:', 13) === 0) { + if (str_starts_with($name, 'isFieldEmpty:')) { return $this->isFieldEmpty(substr($name, 13)); } @@ -2770,7 +2770,7 @@ public function getIterator(): Traversable public function getAttributeLabel($attribute): string { // Is this the "field:handle" syntax? - if (strncmp($attribute, 'field:', 6) === 0) { + if (str_starts_with($attribute, 'field:')) { $attribute = substr($attribute, 6); } @@ -2940,7 +2940,6 @@ public function afterValidate(): void * Normalizes a field’s validation rule. * * @param string $attribute - * @param mixed $rule * @param FieldInterface $field * @param callable $isEmpty * @return Validator @@ -3036,7 +3035,7 @@ public function isFieldEmpty(string $handle): bool */ public function addError($attribute, $error = ''): void { - if (strncmp($attribute, 'field:', 6) === 0) { + if (str_starts_with($attribute, 'field:')) { $attribute = substr($attribute, 6); } @@ -6588,7 +6587,7 @@ protected function fieldLayoutFields(bool $visibleOnly = false): array { try { $fieldLayout = $this->getFieldLayout(); - } catch (InvalidConfigException $e) { + } catch (InvalidConfigException) { return []; } @@ -6628,7 +6627,6 @@ public function getLanguage(): string /** * Returns an element right before/after this one, from a given set of criteria. * - * @param mixed $criteria * @param int $dir * @return ElementInterface|null */ diff --git a/src/base/ElementInterface.php b/src/base/ElementInterface.php index df88ab2fed1..0f6f1558b5b 100644 --- a/src/base/ElementInterface.php +++ b/src/base/ElementInterface.php @@ -1073,7 +1073,6 @@ public function getLocalized(): ElementQueryInterface|ElementCollection; /** * Returns the next element relative to this one, from a given set of criteria. * - * @param mixed $criteria * @return self|null */ public function getNext(mixed $criteria = false): ?self; @@ -1081,7 +1080,6 @@ public function getNext(mixed $criteria = false): ?self; /** * Returns the previous element relative to this one, from a given set of criteria. * - * @param mixed $criteria * @return self|null */ public function getPrev(mixed $criteria = false): ?self; diff --git a/src/base/Field.php b/src/base/Field.php index b9bd4d0d25d..92202ff1fb6 100644 --- a/src/base/Field.php +++ b/src/base/Field.php @@ -43,7 +43,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -abstract class Field extends SavableComponent implements FieldInterface, Iconic, Actionable +abstract class Field extends SavableComponent implements FieldInterface, Iconic, Actionable, \Stringable { use FieldTrait; diff --git a/src/base/MemoizableArray.php b/src/base/MemoizableArray.php index 0a1c5dc181d..0a12d5867e5 100644 --- a/src/base/MemoizableArray.php +++ b/src/base/MemoizableArray.php @@ -34,11 +34,6 @@ */ class MemoizableArray implements IteratorAggregate, Countable { - /** - * @var array Array elements - */ - private array $_elements; - /** * @var callable|null Normalizer method */ @@ -57,13 +52,12 @@ class MemoizableArray implements IteratorAggregate, Countable /** * Constructor * - * @param array $elements The items to be memoized + * @param array $_elements The items to be memoized * @param callable|null $normalizer A method that the items should be normalized with when first returned by * [[all()]] or [[firstWhere()]]. */ - public function __construct(array $elements, ?callable $normalizer = null) + public function __construct(private array $_elements, ?callable $normalizer = null) { - $this->_elements = $elements; $this->_normalizer = $normalizer; } @@ -179,7 +173,6 @@ public function firstWhere(string $key, mixed $value = true, bool $strict = fals * * @param string $method * @param string $key - * @param mixed $value * @param bool $strict * @return string */ diff --git a/src/base/NestedElementTrait.php b/src/base/NestedElementTrait.php index 8f8734e340a..e935bede9ec 100644 --- a/src/base/NestedElementTrait.php +++ b/src/base/NestedElementTrait.php @@ -371,16 +371,11 @@ public function addInvalidNestedElementIds(array $ids): void */ public function setEagerLoadedElements(string $handle, array $elements, EagerLoadPlan $plan): void { - switch ($plan->handle) { - case 'owner': - $this->setOwner(reset($elements) ?: null); - break; - case 'primaryOwner': - $this->setPrimaryOwner(reset($elements) ?: null); - break; - default: - parent::setEagerLoadedElements($handle, $elements, $plan); - } + match ($plan->handle) { + 'owner' => $this->setOwner(reset($elements) ?: null), + 'primaryOwner' => $this->setPrimaryOwner(reset($elements) ?: null), + default => parent::setEagerLoadedElements($handle, $elements, $plan), + }; } /** diff --git a/src/base/PreviewableFieldInterface.php b/src/base/PreviewableFieldInterface.php index 8c693caa076..42082f811ad 100644 --- a/src/base/PreviewableFieldInterface.php +++ b/src/base/PreviewableFieldInterface.php @@ -31,7 +31,6 @@ public function getPreviewHtml(mixed $value, ElementInterface $element): string; * Return the HTML that should be shown for the field in the card preview. * It can be used outside an element context, e.g. in a card view designer. * - * @param mixed $value * @param ElementInterface|null $element * @return string * @since 5.5.0 diff --git a/src/base/conditions/BaseCondition.php b/src/base/conditions/BaseCondition.php index 4fcab106d55..0f2dd6ac6d4 100644 --- a/src/base/conditions/BaseCondition.php +++ b/src/base/conditions/BaseCondition.php @@ -237,10 +237,10 @@ protected function validateConditionRule(ConditionRuleInterface $rule): bool return false; } - $ruleClass = get_class($rule); + $ruleClass = $rule::class; foreach ($this->getSelectableConditionRules() as $selectableRule) { - if ($ruleClass === get_class($selectableRule)) { + if ($ruleClass === $selectableRule::class) { return true; } } @@ -298,7 +298,7 @@ public function getBuilderInnerHtml(bool $autofocusAddButton = false): string ], ]); - $html .= Html::hiddenInput('class', get_class($this)); + $html .= Html::hiddenInput('class', static::class); $html .= Html::hiddenInput('config', Json::encode($this->getBuilderConfig())); foreach ($this->getConditionRules() as $rule) { @@ -311,7 +311,7 @@ public function getBuilderInnerHtml(bool $autofocusAddButton = false): string 'class' => 'visually-hidden', ]) . Html::hiddenInput('uid', $rule->uid) . - Html::hiddenInput('class', get_class($rule)); + Html::hiddenInput('class', $rule::class); if ($this->sortable) { $ruleHtml .= Html::tag('div', @@ -611,7 +611,7 @@ public function getBuilderConfig(): array public function getConfig(): array { return array_merge($this->config(), [ - 'class' => get_class($this), + 'class' => static::class, 'conditionRules' => $this->_conditionRules ->map(function(ConditionRuleInterface $rule) { try { diff --git a/src/base/conditions/BaseConditionRule.php b/src/base/conditions/BaseConditionRule.php index 90d1e12c06a..2285327b4eb 100644 --- a/src/base/conditions/BaseConditionRule.php +++ b/src/base/conditions/BaseConditionRule.php @@ -121,7 +121,7 @@ public function getGroupLabel(): ?string public function getConfig(): array { $config = [ - 'class' => get_class($this), + 'class' => static::class, 'uid' => $this->uid, ]; diff --git a/src/base/conditions/BaseDateRangeConditionRule.php b/src/base/conditions/BaseDateRangeConditionRule.php index 9e243be2995..393aaaa5cb0 100644 --- a/src/base/conditions/BaseDateRangeConditionRule.php +++ b/src/base/conditions/BaseDateRangeConditionRule.php @@ -86,9 +86,6 @@ public function getStartDate(): ?string return $this->_startDate; } - /** - * @param mixed $value - */ public function setStartDate(mixed $value): void { $this->_startDate = ($value ? DateTimeHelper::toIso8601($value) : null); @@ -102,9 +99,6 @@ public function getEndDate(): ?string return $this->_endDate; } - /** - * @param mixed $value - */ public function setEndDate(mixed $value): void { $this->_endDate = ($value ? DateTimeHelper::toIso8601($value) : null); diff --git a/src/base/conditions/BaseTextConditionRule.php b/src/base/conditions/BaseTextConditionRule.php index 66e95c677b3..f1f195dad4f 100644 --- a/src/base/conditions/BaseTextConditionRule.php +++ b/src/base/conditions/BaseTextConditionRule.php @@ -141,7 +141,6 @@ protected function paramValue(): ?string /** * Returns whether the condition rule matches the given value. * - * @param mixed $value * @return bool */ protected function matchValue(mixed $value): bool diff --git a/src/behaviors/FieldLayoutBehavior.php b/src/behaviors/FieldLayoutBehavior.php index 5d4416176b5..169d3e567c4 100644 --- a/src/behaviors/FieldLayoutBehavior.php +++ b/src/behaviors/FieldLayoutBehavior.php @@ -84,7 +84,7 @@ public function getFieldLayoutId(): int } if (!isset($id) || !is_numeric($id)) { - throw new InvalidConfigException('Unable to determine the field layout ID for ' . get_class($this->owner) . '.'); + throw new InvalidConfigException('Unable to determine the field layout ID for ' . $this->owner::class . '.'); } return $this->_fieldLayoutId = (int)$id; diff --git a/src/cache/ElementQueryTagDependency.php b/src/cache/ElementQueryTagDependency.php index e075dd01bd1..be2a8e19d77 100644 --- a/src/cache/ElementQueryTagDependency.php +++ b/src/cache/ElementQueryTagDependency.php @@ -18,20 +18,14 @@ */ class ElementQueryTagDependency extends TagDependency { - /** - * @var ElementQuery|null - */ - public ?ElementQuery $elementQuery = null; - /** * Constructor * * @param ElementQuery $elementQuery * @param array $config */ - public function __construct(ElementQuery $elementQuery, array $config = []) + public function __construct(public ?ElementQuery $elementQuery, array $config = []) { - $this->elementQuery = $elementQuery; parent::__construct($config); } diff --git a/src/config/GeneralConfig.php b/src/config/GeneralConfig.php index ffc94e4c6f9..1f91609503a 100644 --- a/src/config/GeneralConfig.php +++ b/src/config/GeneralConfig.php @@ -3481,7 +3481,6 @@ public function actionTrigger(string $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $activateAccountSuccessPath * @see getActivateAccountSuccessPath() @@ -3897,7 +3896,6 @@ public function buildId(?string $value): self * * @group System * @defaultAlt 1 day - * @param mixed $value * @return self * @see $cacheDuration * @since 4.2.0 @@ -3945,7 +3943,6 @@ public function convertFilenamesToAscii(bool $value = true): self * * @group Security * @defaultAlt 5 minutes - * @param mixed $value * @return self * @see $cooldownDuration * @since 4.2.0 @@ -4151,7 +4148,6 @@ public function defaultCpLocale(?string $value): self * ``` * * @group System - * @param mixed $value * @return self * @see $defaultDirMode * @since 4.2.0 @@ -4263,7 +4259,6 @@ public function defaultTemplateExtensions(array $value): self * * @group Security * @defaultAlt 1 day - * @param mixed $value * @return self * @see $defaultTokenDuration * @since 4.2.0 @@ -4593,7 +4588,6 @@ public function enableGql(bool $value = true): self * * @group Security * @defaultAlt 5 minutes - * @param mixed $value * @return self * @see $elevatedSessionDuration * @since 4.2.0 @@ -5000,7 +4994,6 @@ public function httpProxy(?string $value): self * ``` * * @group Image Handling - * @param mixed $value * @return self * @see $imageDriver * @since 4.2.0 @@ -5069,7 +5062,6 @@ public function indexTemplateFilenames(array $value): self * * @group Security * @defaultAlt 1 hour - * @param mixed $value * @return self * @see $invalidLoginWindowDuration * @since 4.2.0 @@ -5092,7 +5084,6 @@ public function invalidLoginWindowDuration(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $invalidUserTokenPath * @since 4.2.0 @@ -5220,7 +5211,6 @@ public function localeAliases(array $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $loginPath * @since 4.2.0 @@ -5243,7 +5233,6 @@ public function loginPath(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $logoutPath * @since 4.2.0 @@ -5670,7 +5659,6 @@ public function phpSessionName(string $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $postCpLoginRedirect * @since 4.2.0 @@ -5694,7 +5682,6 @@ public function postCpLoginRedirect(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $postLoginRedirect * @since 4.2.0 @@ -5715,7 +5702,6 @@ public function postLoginRedirect(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $postLogoutRedirect * @since 4.2.0 @@ -5901,7 +5887,6 @@ public function previewIframeResizerOptions(array $value): self * * @group Security * @defaultAlt 1 day - * @param mixed $value * @return self * @see $previewTokenDuration * @since 4.2.0 @@ -5953,7 +5938,6 @@ public function privateTemplateTrigger(string $value): self * ``` * * @group Garbage Collection - * @param mixed $value * @return self * @see $purgePendingUsersDuration * @since 4.2.0 @@ -5978,7 +5962,6 @@ public function purgePendingUsersDuration(mixed $value): self * * @group Garbage Collection * @defaultAlt 90 days - * @param mixed $value * @return self * @see $purgeStaleUserSessionDuration * @since 4.2.0 @@ -6002,7 +5985,6 @@ public function purgeStaleUserSessionDuration(mixed $value): self * * @group Garbage Collection * @defaultAlt 30 days - * @param mixed $value * @return self * @see $purgeUnsavedDraftsDuration * @since 4.2.0 @@ -6047,7 +6029,6 @@ public function rasterizeSvgThumbs(bool $value = true): self * * @group Session * @defaultAlt 1 year - * @param mixed $value * @return self * @see $rememberUsernameDuration * @since 4.2.0 @@ -6071,7 +6052,6 @@ public function rememberUsernameDuration(mixed $value): self * * @group Session * @defaultAlt 14 days - * @param mixed $value * @return self * @throws InvalidConfigException * @see $rememberedUserSessionDuration @@ -6438,7 +6418,6 @@ public function sendPoweredByHeader(bool $value = true): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $setPasswordPath * @since 4.2.0 @@ -6466,7 +6445,6 @@ public function setPasswordPath(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $setPasswordRequestPath * @since 4.2.0 @@ -6487,7 +6465,6 @@ public function setPasswordRequestPath(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $setPasswordSuccessPath * @since 4.2.0 @@ -6631,7 +6608,6 @@ public function showFirstAndLastNameFields(bool $value = true): self * * @group Garbage Collection * @defaultAlt 30 days - * @param mixed $value * @return self * @see $softDeleteDuration * @since 4.2.0 @@ -7008,7 +6984,6 @@ public function useSslOnTokenizedUrls(string|bool $value): self * * @group Session * @defaultAlt 1 hour - * @param mixed $value * @return self * @see $userSessionDuration * @since 4.2.0 @@ -7055,7 +7030,6 @@ public function useFileLocks(?bool $value): self * * @group Security * @defaultAlt 1 day - * @param mixed $value * @return self * @see $verificationCodeDuration * @since 4.2.0 @@ -7076,7 +7050,6 @@ public function verificationCodeDuration(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $verifyEmailPath * @see getVerifyEmailPath() @@ -7098,7 +7071,6 @@ public function verifyEmailPath(mixed $value): self * ``` * * @group Routing - * @param mixed $value * @return self * @see $verifyEmailSuccessPath * @see getVerifyEmailSuccessPath() diff --git a/src/console/controllers/MigrateController.php b/src/console/controllers/MigrateController.php index 77cf17bb727..cadb4c3d532 100644 --- a/src/console/controllers/MigrateController.php +++ b/src/console/controllers/MigrateController.php @@ -226,7 +226,7 @@ public function beforeAction($action): bool if (!$this->traitBeforeAction($action)) { return false; } - } catch (InvalidConfigException $e) { + } catch (InvalidConfigException) { // migrations folder not created, but we don't mind. } @@ -586,7 +586,7 @@ public function actionFresh(): int */ protected function truncateDatabase(): void { - throw new NotSupportedException('This command is not implemented in ' . get_class($this)); + throw new NotSupportedException('This command is not implemented in ' . static::class); } /** diff --git a/src/console/controllers/ProjectConfigController.php b/src/console/controllers/ProjectConfigController.php index d0f49ad983f..8c24472a7dd 100644 --- a/src/console/controllers/ProjectConfigController.php +++ b/src/console/controllers/ProjectConfigController.php @@ -167,7 +167,7 @@ public function actionSet(string $path, string $value): int { try { $parsedValue = Yaml::parse($value); - } catch (ParseException $e) { + } catch (ParseException) { $this->stderr('Input value must be valid YAML.' . PHP_EOL, Console::FG_RED); return ExitCode::USAGE; } @@ -244,17 +244,11 @@ public function actionDiff(): int foreach (explode("\n", $diff) as $line) { $firstChar = $line[0] ?? ''; - switch ($firstChar) { - case '-': - $this->stdout($line . PHP_EOL, Console::FG_RED); - break; - case '+': - $this->stdout($line . PHP_EOL, Console::FG_GREEN); - break; - default: - $this->stdout($line . PHP_EOL); - break; - } + match ($firstChar) { + '-' => $this->stdout($line . PHP_EOL, Console::FG_RED), + '+' => $this->stdout($line . PHP_EOL, Console::FG_GREEN), + default => $this->stdout($line . PHP_EOL), + }; } $this->stdout(PHP_EOL); diff --git a/src/console/controllers/SetupController.php b/src/console/controllers/SetupController.php index 97238318a4e..ccf3eaa7331 100644 --- a/src/console/controllers/SetupController.php +++ b/src/console/controllers/SetupController.php @@ -651,7 +651,6 @@ private function _outputCommand(string $command): void * Sets an environment variable value in the project’s `.env` file. * * @param string $name - * @param mixed $value * @return bool */ private function _setEnvVar(string $name, mixed $value): bool diff --git a/src/console/controllers/utils/RepairController.php b/src/console/controllers/utils/RepairController.php index 58548f5c924..3e68e5f4367 100644 --- a/src/console/controllers/utils/RepairController.php +++ b/src/console/controllers/utils/RepairController.php @@ -303,7 +303,6 @@ public function actionProjectConfig(): int * * @param ProjectConfig $projectConfigService * @param string $path - * @param mixed $value * @return mixed */ private function _repairProjectConfigItem(ProjectConfig $projectConfigService, string $path, mixed $value): mixed diff --git a/src/controllers/AppController.php b/src/controllers/AppController.php index 4c5e65e0ef4..7c4b01be49c 100644 --- a/src/controllers/AppController.php +++ b/src/controllers/AppController.php @@ -852,7 +852,7 @@ public function actionRenderComponents(): Response 'icon' => $component instanceof Iconic ? $component->getIcon() : null, 'attributes' => [ 'data' => [ - 'type' => get_class($component), + 'type' => $component::class, 'id' => $component->getId(), ], ], diff --git a/src/controllers/BaseUpdaterController.php b/src/controllers/BaseUpdaterController.php index 7648db8ae62..56f016f3e42 100644 --- a/src/controllers/BaseUpdaterController.php +++ b/src/controllers/BaseUpdaterController.php @@ -508,7 +508,7 @@ protected function runMigrations(array $handles, ?string $restoreAction = null): $previous = $e->getPrevious(); $migration = $e->migration; $output = $e->output; - $error = get_class($migration) . ' migration failed' . ($previous ? ': ' . $previous->getMessage() : '.'); + $error = $migration::class . ' migration failed' . ($previous ? ': ' . $previous->getMessage() : '.'); $e = $previous ?? $e; } else { $migration = $output = null; @@ -546,12 +546,12 @@ protected function runMigrations(array $handles, ?string $restoreAction = null): 'subject' => $ownerName . ' update failure', ]; - $eName = $e instanceof Exception ? $e->getName() : get_class($e); + $eName = $e instanceof Exception ? $e->getName() : $e::class; return $this->send([ 'error' => Craft::t('app', 'One of {name}’s migrations failed.', ['name' => $ownerName]), 'errorDetails' => $eName . ': ' . $e->getMessage() . - ($migration ? "\n\nMigration: " . get_class($migration) : '') . + ($migration ? "\n\nMigration: " . $migration::class : '') . ($output ? "\n\nOutput:\n\n" . $output : ''), 'options' => $options, ]); @@ -599,9 +599,9 @@ protected function installPlugin(string $handle, ?string $edition = null): array Craft::error('Plugin installation failed: ' . $e->getMessage(), __METHOD__); - $eName = $e instanceof YiiException ? $e->getName() : get_class($e); + $eName = $e instanceof YiiException ? $e->getName() : $e::class; $errorDetails = $eName . ': ' . $e->getMessage() . - ($migration ? "\n\nMigration: " . get_class($migration) : '') . + ($migration ? "\n\nMigration: " . $migration::class : '') . ($output ? "\n\nOutput:\n\n" . $output : ''); } @@ -644,7 +644,7 @@ private function _composerErrorDetails(Throwable $e, string $output): string } if (empty($details)) { - $details[] = 'Exception of class ' . get_class($e) . ' was thrown.'; + $details[] = 'Exception of class ' . $e::class . ' was thrown.'; } return implode("\n\n", $details); diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php index 55ef2cde8db..d5518a6b735 100644 --- a/src/controllers/DashboardController.php +++ b/src/controllers/DashboardController.php @@ -75,7 +75,7 @@ public function actionIndex(): Response $settingsHtml = $view->namespaceInputs(fn() => (string)$widget->getSettingsHtml(), '__NAMESPACE__'); $settingsJs = (string)$view->clearJsBuffer(false); - $class = get_class($widget); + $class = $widget::class; $widgetTypeInfo[$class] = [ 'iconSvg' => $this->_getWidgetIconSvg($widget), 'name' => $widget::displayName(), @@ -201,7 +201,7 @@ public function actionSaveWidgetSettings(): Response 'dateCreated' => $widget->dateCreated, 'dateUpdated' => $widget->dateUpdated, 'colspan' => $widget->colspan, - 'type' => get_class($widget), + 'type' => $widget::class, 'settings' => $settings, ]); @@ -480,7 +480,7 @@ private function _getWidgetInfo(WidgetInterface $widget): array|false return [ 'id' => $widget->id, - 'type' => get_class($widget), + 'type' => $widget::class, 'colspan' => $colspan, 'title' => $widget->getTitle(), 'subtitle' => $widget->getSubtitle(), diff --git a/src/controllers/ElementIndexesController.php b/src/controllers/ElementIndexesController.php index 9a589f4f62f..ee0f8d70140 100644 --- a/src/controllers/ElementIndexesController.php +++ b/src/controllers/ElementIndexesController.php @@ -229,7 +229,7 @@ public function actionPerformAction(): ?Response if (!empty($this->actions)) { /** @var ElementAction $availableAction */ foreach ($this->actions as $availableAction) { - if ($actionClass === get_class($availableAction)) { + if ($actionClass === $availableAction::class) { $action = clone $availableAction; break; } @@ -362,7 +362,7 @@ public function actionExport(): Response $export = $export(); } if (!is_iterable($export)) { - throw new InvalidValueException(get_class($exporter) . '::export() must return an array or generator function since isFormattable() returns true.'); + throw new InvalidValueException($exporter::class . '::export() must return an array or generator function since isFormattable() returns true.'); } $this->response->data = $export; @@ -410,7 +410,7 @@ private function _exporter(): ElementExporterInterface $exporterClass = $this->request->getBodyParam('type', Raw::class); if (!empty($this->exporters)) { foreach ($this->exporters as $exporter) { - if ($exporterClass === get_class($exporter)) { + if ($exporterClass === $exporter::class) { return $exporter; } } @@ -979,7 +979,7 @@ protected function exporterData(): ?array foreach ($this->exporters as $exporter) { $exporterData[] = [ - 'type' => get_class($exporter), + 'type' => $exporter::class, 'name' => $exporter::displayName(), 'formattable' => $exporter::isFormattable(), ]; diff --git a/src/controllers/ElementsController.php b/src/controllers/ElementsController.php index 43a5862b634..611f98e705e 100644 --- a/src/controllers/ElementsController.php +++ b/src/controllers/ElementsController.php @@ -150,7 +150,6 @@ public function beforeAction($action): bool /** * @param string $name - * @param mixed $default * @return mixed */ private function _param(string $name, mixed $default = null): mixed @@ -427,7 +426,7 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null): 'canonicalId' => $canonical->id, 'draftId' => $element->draftId, 'draftName' => $isDraft ? $element->draftName : null, - 'elementType' => get_class($element), + 'elementType' => $element::class, 'enablePreview' => $enablePreview, 'enabledForSite' => $element->enabled && $enabledForSite, 'hashedCpEditUrl' => $security->hashData('{cpEditUrl}'), diff --git a/src/controllers/FieldsController.php b/src/controllers/FieldsController.php index 973dc68a064..3c531bdad73 100644 --- a/src/controllers/FieldsController.php +++ b/src/controllers/FieldsController.php @@ -113,7 +113,7 @@ public function actionEditField(?int $fieldId = null, ?FieldInterface $field = n $allFieldTypes = $fieldsService->getAllFieldTypes(); foreach ($allFieldTypes as $class) { - if ($class === get_class($field) || $class::isSelectable()) { + if ($class === $field::class || $class::isSelectable()) { $supportedTranslationMethods[$class] = $class::supportedTranslationMethods(); } } @@ -135,7 +135,7 @@ public function actionEditField(?int $fieldId = null, ?FieldInterface $field = n $multiInstanceTypesOnly = (bool)$this->request->getParam('multiInstanceTypesOnly'); foreach ($allFieldTypes as $class) { - $isCurrent = $class === ($field instanceof MissingField ? $field->expectedType : get_class($field)); + $isCurrent = $class === ($field instanceof MissingField ? $field->expectedType : $field::class); $foundCurrent = $foundCurrent || $isCurrent; if ( @@ -530,7 +530,7 @@ public function actionApplyLayoutElementSettings(): Response $selectorHtml = Cp::layoutElementSelectorHtml($element); return $this->asJson([ - 'config' => ['type' => get_class($element)] + $element->toArray(), + 'config' => ['type' => $element::class] + $element->toArray(), 'selectorHtml' => $selectorHtml, ]); } diff --git a/src/controllers/QueueController.php b/src/controllers/QueueController.php index ae7711fd8f5..6662c7d6d25 100644 --- a/src/controllers/QueueController.php +++ b/src/controllers/QueueController.php @@ -63,7 +63,7 @@ public function init(): void $queue = Craft::$app->getQueue(); if (!$queue instanceof QueueInterface) { - throw new ServerErrorHttpException(sprintf('The queue class %s doesn’t support web-based runners.', get_class($queue))); + throw new ServerErrorHttpException(sprintf('The queue class %s doesn’t support web-based runners.', $queue::class)); } $this->queue = $queue; } diff --git a/src/controllers/SystemSettingsController.php b/src/controllers/SystemSettingsController.php index 9291dbbc3f5..0c30d951adf 100644 --- a/src/controllers/SystemSettingsController.php +++ b/src/controllers/SystemSettingsController.php @@ -135,8 +135,8 @@ public function actionEditEmailSettings(?MailSettings $settings = null, ?Transpo $allTransportAdapterTypes = MailerHelper::allMailerTransportTypes(); // Make sure the selected adapter class is in there - if (!in_array(get_class($adapter), $allTransportAdapterTypes, true)) { - $allTransportAdapterTypes[] = get_class($adapter); + if (!in_array($adapter::class, $allTransportAdapterTypes, true)) { + $allTransportAdapterTypes[] = $adapter::class; } $allTransportAdapters = []; @@ -144,7 +144,7 @@ public function actionEditEmailSettings(?MailSettings $settings = null, ?Transpo foreach ($allTransportAdapterTypes as $transportAdapterType) { /** @var class-string $transportAdapterType */ - if ($transportAdapterType === get_class($adapter) || $transportAdapterType::isSelectable()) { + if ($transportAdapterType === $adapter::class || $transportAdapterType::isSelectable()) { $allTransportAdapters[] = MailerHelper::createTransportAdapter($transportAdapterType); $transportTypeOptions[] = [ 'value' => $transportAdapterType, diff --git a/src/db/CoalesceColumnsExpression.php b/src/db/CoalesceColumnsExpression.php index 78066a29b11..31585f1da3c 100644 --- a/src/db/CoalesceColumnsExpression.php +++ b/src/db/CoalesceColumnsExpression.php @@ -17,20 +17,14 @@ */ class CoalesceColumnsExpression extends BaseObject implements ExpressionInterface { - /** - * @var string[] The columns that should be coalesced. - */ - public array $columns; - /** * Constructor * * @param string[] $columns The columns that should be coalesced. * @param array $config */ - public function __construct(array $columns = [], array $config = []) + public function __construct(public array $columns = [], array $config = []) { - $this->columns = $columns; parent::__construct($config); } diff --git a/src/db/FixedOrderExpression.php b/src/db/FixedOrderExpression.php index 5dacda8852d..7e3c0b187db 100644 --- a/src/db/FixedOrderExpression.php +++ b/src/db/FixedOrderExpression.php @@ -17,21 +17,6 @@ */ class FixedOrderExpression extends Expression { - /** - * @var string The column name that contains the values - */ - public string $column; - - /** - * @var array The column values, in the order in which the rows should be returned in - */ - public array $values; - - /** - * @var Connection The DB connection - */ - public Connection $db; - /** * Constructor * @@ -41,13 +26,9 @@ class FixedOrderExpression extends Expression * @param array $params Parameters * @param array $config Name-value pairs that will be used to initialize the object properties. */ - public function __construct(string $column, array $values, Connection $db, array $params = [], array $config = []) + public function __construct(public string $column, public array $values, public Connection $db, array $params = [], array $config = []) { - $this->column = $column; - $this->values = $values; - $this->db = $db; - - $expression = $db->getQueryBuilder()->fixedOrder($column, $values); + $expression = $this->db->getQueryBuilder()->fixedOrder($this->column, $this->values); parent::__construct($expression, $params, $config); } } diff --git a/src/db/MigrationManager.php b/src/db/MigrationManager.php index c6e9338aedb..a7567a88d33 100644 --- a/src/db/MigrationManager.php +++ b/src/db/MigrationManager.php @@ -436,7 +436,7 @@ private function _normalizeMigration(\yii\db\Migration|string|MigrationInterface $migrationName = $migration; $migration = $this->createMigration($migration); } else { - $classParts = explode('\\', get_class($migration)); + $classParts = explode('\\', $migration::class); $migrationName = array_pop($classParts); } diff --git a/src/db/Paginator.php b/src/db/Paginator.php index 0d0d695e964..f83bb453f4c 100644 --- a/src/db/Paginator.php +++ b/src/db/Paginator.php @@ -58,11 +58,6 @@ class Paginator extends BaseObject */ public int $pageSize = 100; - /** - * @var QueryInterface The query being paginated - */ - protected QueryInterface $query; - /** * @var int The total query count */ @@ -89,10 +84,8 @@ class Paginator extends BaseObject * @param QueryInterface $query The query that should be paginated * @param array $config */ - public function __construct(QueryInterface $query, array $config = []) + public function __construct(protected QueryInterface $query, array $config = []) { - $this->query = $query; - // Set the current page after everything else $currentPage = ArrayHelper::remove($config, 'currentPage'); diff --git a/src/db/Query.php b/src/db/Query.php index d4062318392..695620eba60 100644 --- a/src/db/Query.php +++ b/src/db/Query.php @@ -71,7 +71,6 @@ public function getIterator(): ArrayIterator /** * Required by the ArrayAccess interface. * - * @param mixed $offset * @return bool * @since 4.2.0 */ @@ -94,7 +93,6 @@ public function offsetExists(mixed $offset): bool /** * Required by the ArrayAccess interface. * - * @param mixed $offset * @return mixed * @throws UnknownPropertyException * @since 4.2.0 @@ -114,8 +112,6 @@ public function offsetGet(mixed $offset): mixed /** * Required by the ArrayAccess interface. * - * @param mixed $offset - * @param mixed $value * @throws NotSupportedException * @throws UnknownPropertyException * @since 4.2.0 @@ -132,7 +128,6 @@ public function offsetSet(mixed $offset, mixed $value): void /** * Required by the ArrayAccess interface. * - * @param mixed $offset * @return void * @throws NotSupportedException * @since 4.2.0 diff --git a/src/db/QueryParam.php b/src/db/QueryParam.php index 6068d9938cc..9b56c87c73d 100644 --- a/src/db/QueryParam.php +++ b/src/db/QueryParam.php @@ -25,7 +25,6 @@ final class QueryParam /** * Parses a given query param, separating it into an array of values and the logical operator (`and`, `or`, `not`). * - * @param mixed $value * @return self */ public static function parse(mixed $value): self diff --git a/src/debug/LogTarget.php b/src/debug/LogTarget.php index d851f7c1c24..a17369b49c8 100644 --- a/src/debug/LogTarget.php +++ b/src/debug/LogTarget.php @@ -169,7 +169,7 @@ private function _updateIndexFile(string $indexFile, array $summary): void { try { $manifest = unserialize($this->module->fs->read($indexFile)); - } catch (FsException $e) { + } catch (FsException) { $manifest = []; } diff --git a/src/debug/MailPanel.php b/src/debug/MailPanel.php index b2527e6479d..8e2eb8cfb35 100644 --- a/src/debug/MailPanel.php +++ b/src/debug/MailPanel.php @@ -63,7 +63,6 @@ public function init(): void } /** - * @param mixed $attr * @return string */ private function convertParams(mixed $attr): string diff --git a/src/elements/Address.php b/src/elements/Address.php index 51480cbbea7..14164d1e1e7 100644 --- a/src/elements/Address.php +++ b/src/elements/Address.php @@ -119,12 +119,10 @@ protected static function defineTableAttributes(): array */ protected function attributeHtml(string $attribute): string { - switch ($attribute) { - case 'country': - return $this->getCountry()->getName(); - default: - return parent::attributeHtml($attribute); - } + return match ($attribute) { + 'country' => $this->getCountry()->getName(), + default => parent::attributeHtml($attribute), + }; } /** diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 86820df2ad1..4451d0d566c 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -831,7 +831,7 @@ public static function indexElementCount(ElementQueryInterface $elementQuery, ?s if (self::_includeFoldersInIndexElements($elementQuery, $sourceKey, $queryFolder)) { try { $count += self::_createFolderQueryForIndex($elementQuery, $queryFolder)->count(); - } catch (QueryAbortedException $e) { + } catch (QueryAbortedException) { return 0; } } @@ -1232,7 +1232,7 @@ public function __isset($name): bool { return ( parent::__isset($name) || - strncmp($name, 'transform:', 10) === 0 || + str_starts_with($name, 'transform:') || Craft::$app->getImageTransforms()->getTransformByHandle($name) ); } @@ -1251,7 +1251,7 @@ public function __isset($name): bool */ public function __get($name) { - if (strncmp($name, 'transform:', 10) === 0) { + if (str_starts_with($name, 'transform:')) { return $this->copyWithTransform(substr($name, 10)); } @@ -2772,15 +2772,13 @@ public function getInlineAttributeInputHtml(string $attribute): string */ protected function inlineAttributeInputHtml(string $attribute): string { - switch ($attribute) { - case 'alt': - return Cp::textareaHtml([ - 'name' => 'alt', - 'value' => $this->alt, - ]); - default: - return parent::inlineAttributeInputHtml($attribute); - } + return match ($attribute) { + 'alt' => Cp::textareaHtml([ + 'name' => 'alt', + 'value' => $this->alt, + ]), + default => parent::inlineAttributeInputHtml($attribute), + }; } /** @@ -2806,34 +2804,26 @@ public function getPreviewHtml(): string ($userSession->getId() == $this->uploaderId || $userSession->checkPermission("editPeerImages:$volume->uid")) ); - switch ($this->kind) { - case Asset::KIND_VIDEO: - $previewInner = - Html::tag('video', Html::tag('source', '', [ - 'type' => $this->getMimeType(), - 'src' => $this->url, - ]), [ - 'class' => 'preview-thumb', - 'controls' => true, - 'preload' => 'metadata', - ]); - break; - case Asset::KIND_AUDIO: - $previewInner = - Html::tag('audio', Html::tag('source', '', [ - 'src' => $this->url, - 'type' => $this->getMimeType(), - ]), [ - 'controls' => true, - 'preload' => 'metadata', - ]); - break; - default: - $previewInner = - Html::tag('div', $this->getPreviewThumbImg(350, 190), [ - 'class' => 'preview-thumb', - ]); - } + $previewInner = match ($this->kind) { + Asset::KIND_VIDEO => Html::tag('video', Html::tag('source', '', [ + 'type' => $this->getMimeType(), + 'src' => $this->url, + ]), [ + 'class' => 'preview-thumb', + 'controls' => true, + 'preload' => 'metadata', + ]), + Asset::KIND_AUDIO => Html::tag('audio', Html::tag('source', '', [ + 'src' => $this->url, + 'type' => $this->getMimeType(), + ]), [ + 'controls' => true, + 'preload' => 'metadata', + ]), + default => Html::tag('div', $this->getPreviewThumbImg(350, 190), [ + 'class' => 'preview-thumb', + ]), + }; $previewThumbHtml = Html::beginTag('div', [ diff --git a/src/elements/Category.php b/src/elements/Category.php index 60802c66332..8268e44c9af 100644 --- a/src/elements/Category.php +++ b/src/elements/Category.php @@ -770,15 +770,13 @@ public function getGroup(): CategoryGroup */ protected function inlineAttributeInputHtml(string $attribute): string { - switch ($attribute) { - case 'slug': - return Cp::textHtml([ - 'name' => 'slug', - 'value' => $this->slug, - ]); - default: - return parent::inlineAttributeInputHtml($attribute); - } + return match ($attribute) { + 'slug' => Cp::textHtml([ + 'name' => 'slug', + 'value' => $this->slug, + ]), + default => parent::inlineAttributeInputHtml($attribute), + }; } /** diff --git a/src/elements/Entry.php b/src/elements/Entry.php index a1e4c9e0e18..0956d459264 100644 --- a/src/elements/Entry.php +++ b/src/elements/Entry.php @@ -2400,7 +2400,7 @@ public function showStatusField(): bool { try { $showStatusField = $this->getType()->showStatusField; - } catch (InvalidConfigException $e) { + } catch (InvalidConfigException) { $showStatusField = true; } diff --git a/src/elements/GlobalSet.php b/src/elements/GlobalSet.php index e7090afd93f..21215018aca 100644 --- a/src/elements/GlobalSet.php +++ b/src/elements/GlobalSet.php @@ -298,7 +298,7 @@ public function beforeDelete(): bool try { $fieldLayout = $this->getFieldLayout(); - } catch (InvalidConfigException $e) { + } catch (InvalidConfigException) { $fieldLayout = null; } diff --git a/src/elements/NestedElementManager.php b/src/elements/NestedElementManager.php index 8de674792d5..8d7db3fd37b 100644 --- a/src/elements/NestedElementManager.php +++ b/src/elements/NestedElementManager.php @@ -337,7 +337,7 @@ public function getSupportedSiteIds(ElementInterface $owner): array if (!isset($propagationKey)) { $include = true; } else { - $siteOwner = $elementsService->getElementById($owner->id, get_class($owner), $siteId); + $siteOwner = $elementsService->getElementById($owner->id, $owner::class, $siteId); $include = $siteOwner && $propagationKey === $view->renderObjectTemplate($this->propagationKeyFormat, $siteOwner); } break; diff --git a/src/elements/actions/ChangeSortOrder.php b/src/elements/actions/ChangeSortOrder.php index 42f370f5b78..17c53d2e118 100644 --- a/src/elements/actions/ChangeSortOrder.php +++ b/src/elements/actions/ChangeSortOrder.php @@ -110,7 +110,7 @@ public function getTriggerHtml(): ?string [ static::class, [ - 'ownerElementType' => get_class($this->owner), + 'ownerElementType' => $this->owner::class, 'ownerId' => $this->owner->id, 'ownerSiteId' => $this->owner->siteId, 'attribute' => $this->attribute, diff --git a/src/elements/db/ElementQuery.php b/src/elements/db/ElementQuery.php index b753208e8d4..5c6607f059f 100644 --- a/src/elements/db/ElementQuery.php +++ b/src/elements/db/ElementQuery.php @@ -110,14 +110,6 @@ class ElementQuery extends Query implements ElementQueryInterface */ public const EVENT_AFTER_POPULATE_ELEMENTS = 'afterPopulateElements'; - // Base config attributes - // ------------------------------------------------------------------------- - - /** - * @var class-string The name of the [[ElementInterface]] class. - */ - public string $elementType; - /** * @var Query|null The query object created by [[prepare()]] * @see prepare() @@ -597,10 +589,8 @@ class ElementQuery extends Query implements ElementQueryInterface * @param class-string $elementType The element type class associated with this query * @param array $config Configurations to be applied to the newly created query object */ - public function __construct(string $elementType, array $config = []) + public function __construct(public string $elementType, array $config = []) { - $this->elementType = $elementType; - // Use ** as a placeholder for "all the default columns" $config['select'] ??= ['**' => '**']; @@ -617,19 +607,16 @@ public function __construct(string $elementType, array $config = []) */ public function __set($name, $value) { - switch ($name) { - case 'site': - $this->site($value); - break; - default: - parent::__set($name, $value); - } + match ($name) { + 'site' => $this->site($value), + default => parent::__set($name, $value), + }; } /** * @inheritdoc */ - public function __toString() + public function __toString(): string { return self::class; } @@ -2622,7 +2609,6 @@ protected function normalizeOrderBy($columns): array /** * Combines the given condition with an alternative condition if there are any relevant placeholder elements. * - * @param mixed $condition * @return mixed */ private function _placeholderCondition(mixed $condition): mixed diff --git a/src/elements/db/ElementRelationParamParser.php b/src/elements/db/ElementRelationParamParser.php index d79f446f3bc..74db6923db4 100644 --- a/src/elements/db/ElementRelationParamParser.php +++ b/src/elements/db/ElementRelationParamParser.php @@ -128,7 +128,6 @@ public static function normalizeRelatedToParam(mixed $relatedToParam, array|int| /** * Normalizes an individual `relatedTo` criteria. * - * @param mixed $relCriteria * @param int|string|int[]|null $siteId * @return array * @throws InvalidArgumentException if the criteria contains an invalid site handle @@ -208,7 +207,6 @@ public static function normalizeRelatedToCriteria(mixed $relCriteria, array|int| * Parses a `relatedTo` element query param and returns the condition that should * be applied back on the element query, or `false` if there's an issue. * - * @param mixed $relatedToParam * @param int|string|int[]|null $siteId * @return array|false */ @@ -251,7 +249,6 @@ public function parse(mixed $relatedToParam, array|int|string|null $siteId = nul /** * Parses a part of a relatedTo element query param and returns the condition or `false` if there's an issue. * - * @param mixed $relCriteria * @return mixed */ private function _subparse(mixed $relCriteria): mixed @@ -506,7 +503,6 @@ private function _subparse(mixed $relCriteria): mixed /** * Returns a field model based on its handle or ID. * - * @param mixed $field * @param array|null $fieldHandleParts * @param bool $useElementQueryFields * @return FieldInterface|null diff --git a/src/elements/db/EntryQuery.php b/src/elements/db/EntryQuery.php index 760783dc7f2..22ef7b1c82e 100644 --- a/src/elements/db/EntryQuery.php +++ b/src/elements/db/EntryQuery.php @@ -233,19 +233,12 @@ public function __construct($elementType, array $config = []) */ public function __set($name, $value) { - switch ($name) { - case 'section': - $this->section($value); - break; - case 'type': - $this->type($value); - break; - case 'authorGroup': - $this->authorGroup($value); - break; - default: - $this->nestedTraitSet($name, $value); - } + match ($name) { + 'section' => $this->section($value), + 'type' => $this->type($value), + 'authorGroup' => $this->authorGroup($value), + default => $this->nestedTraitSet($name, $value), + }; } /** diff --git a/src/elements/db/NestedElementQueryTrait.php b/src/elements/db/NestedElementQueryTrait.php index fb44a86c08e..cc4e91adcfb 100644 --- a/src/elements/db/NestedElementQueryTrait.php +++ b/src/elements/db/NestedElementQueryTrait.php @@ -73,19 +73,12 @@ trait NestedElementQueryTrait */ public function __set($name, $value) { - switch ($name) { - case 'field': - $this->field($value); - break; - case 'owner': - $this->owner($value); - break; - case 'primaryOwner': - $this->primaryOwner($value); - break; - default: - parent::__set($name, $value); - } + match ($name) { + 'field' => $this->field($value), + 'owner' => $this->owner($value), + 'primaryOwner' => $this->primaryOwner($value), + default => parent::__set($name, $value), + }; } /** @@ -280,7 +273,6 @@ private function normalizeFieldId(): void /** * Normalizes the primaryOwnerId param to an array of IDs or null * - * @param mixed $value * @return int[]|null|false */ private function normalizeOwnerId(mixed $value): array|null|false diff --git a/src/errors/ElementException.php b/src/errors/ElementException.php index 3ba8bcaef51..fc764f42912 100644 --- a/src/errors/ElementException.php +++ b/src/errors/ElementException.php @@ -18,11 +18,6 @@ */ class ElementException extends Exception { - /** - * @var ElementInterface The element - */ - public ElementInterface $element; - /** * Constructor. * @@ -30,9 +25,8 @@ class ElementException extends Exception * @param string|null $message The error message * @param int $code The error code */ - public function __construct(ElementInterface $element, ?string $message = null, int $code = 0) + public function __construct(public ElementInterface $element, ?string $message = null, int $code = 0) { - $this->element = $element; parent::__construct($message, $code); } } diff --git a/src/errors/FieldNotFoundException.php b/src/errors/FieldNotFoundException.php index 11a6e39267b..7c396a740eb 100644 --- a/src/errors/FieldNotFoundException.php +++ b/src/errors/FieldNotFoundException.php @@ -18,11 +18,6 @@ */ class FieldNotFoundException extends Exception { - /** - * @var string The field’s UUID - */ - public string $fieldUid; - /** * Constructor * @@ -31,9 +26,8 @@ class FieldNotFoundException extends Exception * @param int $code * @param Throwable|null $previous */ - public function __construct(string $fieldUid, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(public string $fieldUid, string $message = '', int $code = 0, ?Throwable $previous = null) { - $this->fieldUid = $fieldUid; parent::__construct($message, $code, $previous); } diff --git a/src/errors/InvalidHtmlTagException.php b/src/errors/InvalidHtmlTagException.php index 89e4f96c6ff..376419d450f 100644 --- a/src/errors/InvalidHtmlTagException.php +++ b/src/errors/InvalidHtmlTagException.php @@ -17,26 +17,6 @@ */ class InvalidHtmlTagException extends InvalidArgumentException { - /** - * @var string|null The tag type - */ - public ?string $type = null; - - /** - * @var array|null The tag attributes - */ - public ?array $attributes = null; - - /** - * @var int|null The tag’s starting position - */ - public ?int $start = null; - - /** - * @var int|null The tag’s inner HTML starting position - */ - public ?int $htmlStart = null; - /** * Constructor. * @@ -46,13 +26,8 @@ class InvalidHtmlTagException extends InvalidArgumentException * @param int|null $start The tag’s starting position * @param int|null $htmlStart The tag’s inner HTML starting position */ - public function __construct(string $message, ?string $type = null, ?array $attributes = null, ?int $start = null, ?int $htmlStart = null) + public function __construct(string $message, public ?string $type = null, public ?array $attributes = null, public ?int $start = null, public ?int $htmlStart = null) { - $this->type = $type; - $this->attributes = $attributes; - $this->start = $start; - $this->htmlStart = $htmlStart; - parent::__construct($message); } diff --git a/src/errors/InvalidLicenseKeyException.php b/src/errors/InvalidLicenseKeyException.php index 4af21267ba5..a537befd14c 100644 --- a/src/errors/InvalidLicenseKeyException.php +++ b/src/errors/InvalidLicenseKeyException.php @@ -17,11 +17,6 @@ */ class InvalidLicenseKeyException extends Exception { - /** - * @var string The license key - */ - public string $licenseKey; - /** * Constructor. * @@ -29,12 +24,10 @@ class InvalidLicenseKeyException extends Exception * @param string|null $message The error message * @param int $code The error code */ - public function __construct(string $licenseKey, ?string $message = null, int $code = 0) + public function __construct(public string $licenseKey, ?string $message = null, int $code = 0) { - $this->licenseKey = $licenseKey; - if ($message === null) { - $message = "The license key “{$licenseKey}” is invalid."; + $message = "The license key “{$this->licenseKey}” is invalid."; } parent::__construct($message, $code); diff --git a/src/errors/InvalidPluginException.php b/src/errors/InvalidPluginException.php index d4b0cc4af14..bf4575b6654 100644 --- a/src/errors/InvalidPluginException.php +++ b/src/errors/InvalidPluginException.php @@ -17,11 +17,6 @@ */ class InvalidPluginException extends Exception { - /** - * @var string The invalid plugin handle - */ - public string $handle; - /** * Constructor. * @@ -29,12 +24,10 @@ class InvalidPluginException extends Exception * @param string|null $message The error message * @param int $code The error code */ - public function __construct(string $handle, ?string $message = null, int $code = 0) + public function __construct(public string $handle, ?string $message = null, int $code = 0) { - $this->handle = $handle; - if ($message === null) { - $message = "No plugin exists with the handle \"$handle\"."; + $message = "No plugin exists with the handle \"{$this->handle}\"."; } parent::__construct($message, $code); diff --git a/src/errors/InvalidSubpathException.php b/src/errors/InvalidSubpathException.php index da74102c8cb..585ca4cb781 100644 --- a/src/errors/InvalidSubpathException.php +++ b/src/errors/InvalidSubpathException.php @@ -18,11 +18,6 @@ */ class InvalidSubpathException extends Exception { - /** - * @var string The invalid subpath - */ - public string $subpath; - /** * Constructor. * @@ -31,12 +26,10 @@ class InvalidSubpathException extends Exception * @param int $code The error code * @param Throwable|null $previous The previous exception */ - public function __construct(string $subpath, ?string $message = null, int $code = 0, ?Throwable $previous = null) + public function __construct(public string $subpath, ?string $message = null, int $code = 0, ?Throwable $previous = null) { - $this->subpath = $subpath; - if ($message === null) { - $message = "Could not resolve the subpath “{$subpath}”."; + $message = "Could not resolve the subpath “{$this->subpath}”."; } parent::__construct($message, $code, $previous); diff --git a/src/errors/InvalidTypeException.php b/src/errors/InvalidTypeException.php index ff21687aa50..0b45a355644 100644 --- a/src/errors/InvalidTypeException.php +++ b/src/errors/InvalidTypeException.php @@ -17,16 +17,6 @@ */ class InvalidTypeException extends Exception { - /** - * @var class-string The invalid class name - */ - public string $class; - - /** - * @var class-string The base class or interface that [[$class]] was supposed to be - */ - public string $requiredType; - /** * Constructor. * @@ -35,13 +25,10 @@ class InvalidTypeException extends Exception * @param string|null $message The error message * @param int $code The error code */ - public function __construct(string $class, string $requiredType, ?string $message = null, int $code = 0) + public function __construct(public string $class, public string $requiredType, ?string $message = null, int $code = 0) { - $this->class = $class; - $this->requiredType = $requiredType; - if ($message === null) { - $message = "$class doesn’t exist or doesn’t extend/implement $requiredType"; + $message = "{$this->class} doesn’t exist or doesn’t extend/implement {$this->requiredType}"; } parent::__construct($message, $code); diff --git a/src/errors/MigrateException.php b/src/errors/MigrateException.php index a752a386463..54db704ccde 100644 --- a/src/errors/MigrateException.php +++ b/src/errors/MigrateException.php @@ -18,16 +18,6 @@ */ class MigrateException extends Exception { - /** - * @var string The name of the thing being updated - */ - public string $ownerName; - - /** - * @var string The handle of the thing being updated - */ - public string $ownerHandle; - /** * Constructor. * @@ -37,13 +27,10 @@ class MigrateException extends Exception * @param int $code The error code * @param Throwable|null $previous The previous exception */ - public function __construct(string $ownerName, string $ownerHandle, ?string $message = null, int $code = 0, Throwable $previous = null) + public function __construct(public string $ownerName, public string $ownerHandle, ?string $message = null, int $code = 0, Throwable $previous = null) { - $this->ownerName = $ownerName; - $this->ownerHandle = $ownerHandle; - if ($message === null) { - $message = 'An error occurred while migrating ' . $ownerName . '.'; + $message = 'An error occurred while migrating ' . $this->ownerName . '.'; } parent::__construct($message, $code, $previous); diff --git a/src/errors/MigrationException.php b/src/errors/MigrationException.php index a246adaec2a..3dad4da30d2 100644 --- a/src/errors/MigrationException.php +++ b/src/errors/MigrationException.php @@ -19,16 +19,6 @@ */ class MigrationException extends UserException { - /** - * @var Migration The migration being executed - */ - public Migration $migration; - - /** - * @var string|null The migration output - */ - public ?string $output = null; - /** * Constructor. * @@ -38,13 +28,10 @@ class MigrationException extends UserException * @param int $code The error code * @param Throwable|null $previous The previous exception */ - public function __construct(Migration $migration, ?string $output = null, ?string $message = null, int $code = 0, ?Throwable $previous = null) + public function __construct(public Migration $migration, public ?string $output = null, ?string $message = null, int $code = 0, ?Throwable $previous = null) { - $this->migration = $migration; - $this->output = $output; - if ($message === null) { - $message = 'An error occurred while executing the "' . get_class($migration) . ' migration' . ($previous ? ': ' . $previous->getMessage() : '.'); + $message = 'An error occurred while executing the "' . $this->migration::class . ' migration' . ($previous ? ': ' . $previous->getMessage() : '.'); } parent::__construct($message, $code, $previous); diff --git a/src/errors/MissingAssetException.php b/src/errors/MissingAssetException.php index 67a2ac03cda..61bd6d24ec6 100644 --- a/src/errors/MissingAssetException.php +++ b/src/errors/MissingAssetException.php @@ -21,26 +21,6 @@ */ class MissingAssetException extends Exception { - /** - * @var AssetIndexData - */ - public AssetIndexData $indexEntry; - - /** - * @var Volume - */ - public Volume $volume; - - /** - * @var VolumeFolder - */ - public VolumeFolder $folder; - - /** - * @var string - */ - public string $filename; - /** * Constructor * @@ -52,12 +32,8 @@ class MissingAssetException extends Exception * @param int $code * @param Throwable|null $previous */ - public function __construct(AssetIndexData $indexEntry, Volume $volume, VolumeFolder $folder, string $filename, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(public AssetIndexData $indexEntry, public Volume $volume, public VolumeFolder $folder, public string $filename, string $message = '', int $code = 0, ?Throwable $previous = null) { - $this->indexEntry = $indexEntry; - $this->volume = $volume; - $this->folder = $folder; - $this->filename = $filename; parent::__construct($message, $code, $previous); } diff --git a/src/errors/MissingVolumeFolderException.php b/src/errors/MissingVolumeFolderException.php index 8581d99e970..4e98a321c49 100644 --- a/src/errors/MissingVolumeFolderException.php +++ b/src/errors/MissingVolumeFolderException.php @@ -20,21 +20,6 @@ */ class MissingVolumeFolderException extends Exception { - /** - * @var AssetIndexData - */ - public AssetIndexData $indexEntry; - - /** - * @var Volume - */ - public Volume $volume; - - /** - * @var string - */ - public string $folderName; - /** * Constructor * @@ -45,11 +30,8 @@ class MissingVolumeFolderException extends Exception * @param int $code * @param Throwable|null $previous */ - public function __construct(AssetIndexData $indexEntry, Volume $volume, string $folderName, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(public AssetIndexData $indexEntry, public Volume $volume, public string $folderName, string $message = '', int $code = 0, ?Throwable $previous = null) { - $this->indexEntry = $indexEntry; - $this->volume = $volume; - $this->folderName = $folderName; parent::__construct($message, $code, $previous); } diff --git a/src/errors/ShellCommandException.php b/src/errors/ShellCommandException.php index 4391d5e4d99..d7acd84f13a 100644 --- a/src/errors/ShellCommandException.php +++ b/src/errors/ShellCommandException.php @@ -18,21 +18,6 @@ */ final class ShellCommandException extends Exception { - /** - * @var string The command that was executed - */ - public string $command; - - /** - * @var int The command’s exit code - */ - public int $exitCode; - - /** - * @var string|null The command’s error output - */ - public ?string $error = null; - /** * Creates a ShellCommandException from a [[Command]] object * @@ -59,14 +44,10 @@ public static function createFromCommand(Command $command): self|false * @param string|null $message The error message * @param int $code The error code */ - public function __construct(string $command, int $exitCode, ?string $error = null, ?string $message = null, int $code = 0) + public function __construct(public string $command, public int $exitCode, public ?string $error = null, ?string $message = null, int $code = 0) { - $this->command = $command; - $this->exitCode = $exitCode; - $this->error = $error; - if ($message === null) { - $message = "The shell command \"$command\" failed with exit code $exitCode" . ($error ? ": $error" : '.'); + $message = "The shell command \"{$this->command}\" failed with exit code {$this->exitCode}" . ($this->error ? ": {$this->error}" : '.'); } parent::__construct($message, $code); diff --git a/src/errors/SsoFailedException.php b/src/errors/SsoFailedException.php index 878459f0b1a..f08c1ede4f1 100644 --- a/src/errors/SsoFailedException.php +++ b/src/errors/SsoFailedException.php @@ -18,16 +18,6 @@ */ class SsoFailedException extends Exception { - /** - * @var ProviderInterface - */ - public ProviderInterface $provider; - - /** - * @var User|null - */ - public ?User $identity; - /** * Constructor * @@ -37,10 +27,8 @@ class SsoFailedException extends Exception * @param int $code * @param Throwable|null $previous */ - public function __construct(ProviderInterface $provider, ?User $identity = null, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(public ProviderInterface $provider, public ?User $identity = null, string $message = '', int $code = 0, ?Throwable $previous = null) { - $this->provider = $provider; - $this->identity = $identity; parent::__construct($message, $code, $previous); } diff --git a/src/errors/UnsupportedSiteException.php b/src/errors/UnsupportedSiteException.php index 575b03ca94e..7e6a0732328 100644 --- a/src/errors/UnsupportedSiteException.php +++ b/src/errors/UnsupportedSiteException.php @@ -17,11 +17,6 @@ */ class UnsupportedSiteException extends ElementException { - /** - * @var int The site ID that the element doesn’t support. - */ - public int $siteId; - /** * Constructor. * @@ -30,12 +25,10 @@ class UnsupportedSiteException extends ElementException * @param string|null $message The error message * @param int $code The error code */ - public function __construct(ElementInterface $element, int $siteId, ?string $message = null, int $code = 0) + public function __construct(ElementInterface $element, public int $siteId, ?string $message = null, int $code = 0) { - $this->siteId = $siteId; - if ($message === null) { - $message = "The element “{$element}” doesn’t support site $siteId."; + $message = "The element “{$element}” doesn’t support site {$this->siteId}."; } parent::__construct($element, $message, $code); diff --git a/src/errors/UploadFailedException.php b/src/errors/UploadFailedException.php index ff7beedde62..208999547a9 100644 --- a/src/errors/UploadFailedException.php +++ b/src/errors/UploadFailedException.php @@ -18,11 +18,6 @@ */ class UploadFailedException extends FileException { - /** - * @var int Error code - */ - public int $errorCode; - /** * Constructor * @@ -30,12 +25,10 @@ class UploadFailedException extends FileException * @param string|null $message * @param Throwable|null $previous */ - public function __construct(int $errorCode = 0, ?string $message = null, Throwable $previous = null) + public function __construct(public int $errorCode = 0, ?string $message = null, Throwable $previous = null) { - $this->errorCode = $errorCode; - if ($message === null) { - $message = match ($errorCode) { + $message = match ($this->errorCode) { UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE => Craft::t('app', 'The uploaded file exceeds the maximum allowed size.'), UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE => Craft::t('app', 'The file failed to upload to the server properly.'), UPLOAD_ERR_NO_TMP_DIR => Craft::t('app', 'Could not write to the temporary upload folder.'), diff --git a/src/errors/UserLockedException.php b/src/errors/UserLockedException.php index e6b6288dcba..df1bef3c64e 100644 --- a/src/errors/UserLockedException.php +++ b/src/errors/UserLockedException.php @@ -19,11 +19,6 @@ */ class UserLockedException extends Exception { - /** - * @var User The user that's locked. - */ - public User $user; - /** * Constructor * @@ -32,9 +27,8 @@ class UserLockedException extends Exception * @param int $code * @param Throwable|null $previous */ - public function __construct(User $user, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(public User $user, string $message = '', int $code = 0, ?Throwable $previous = null) { - $this->user = $user; parent::__construct($message, $code, $previous); } diff --git a/src/events/AuthorizationCheckEvent.php b/src/events/AuthorizationCheckEvent.php index bfc690bb036..3d522514b78 100644 --- a/src/events/AuthorizationCheckEvent.php +++ b/src/events/AuthorizationCheckEvent.php @@ -25,9 +25,8 @@ class AuthorizationCheckEvent extends Event * @param User $user * @param array $config */ - public function __construct(User $user, array $config = []) + public function __construct(public User $user, array $config = []) { - $this->user = $user; parent::__construct($config); } @@ -40,11 +39,6 @@ public function __construct(User $user, array $config = []) */ public ?ElementInterface $element = null; - /** - * @var User The user to be authorized. - */ - public User $user; - /** * @var bool|null Whether the user is authorized. */ diff --git a/src/events/CreateElementCheckEvent.php b/src/events/CreateElementCheckEvent.php index 756186ad16f..3c61dfa7d0f 100644 --- a/src/events/CreateElementCheckEvent.php +++ b/src/events/CreateElementCheckEvent.php @@ -24,14 +24,8 @@ class CreateElementCheckEvent extends AuthorizationCheckEvent * @param array $attributes * @param array $config */ - public function __construct(User $user, array $attributes, array $config = []) + public function __construct(User $user, public array $attributes, array $config = []) { - $this->attributes = $attributes; parent::__construct($user, $config); } - - /** - * @var array The attributes the new element would be created with. - */ - public array $attributes; } diff --git a/src/events/FsEvent.php b/src/events/FsEvent.php index f6b214b05a5..63f9d77d3fa 100644 --- a/src/events/FsEvent.php +++ b/src/events/FsEvent.php @@ -24,14 +24,8 @@ class FsEvent extends Event * @param FsInterface $fs * @param array $config */ - public function __construct(FsInterface $fs, array $config = []) + public function __construct(public FsInterface $fs, array $config = []) { - $this->fs = $fs; parent::__construct($config); } - - /** - * @var FsInterface The filesystem - */ - public FsInterface $fs; } diff --git a/src/fieldlayoutelements/BaseField.php b/src/fieldlayoutelements/BaseField.php index a9beadd5c6d..7489130cb9a 100644 --- a/src/fieldlayoutelements/BaseField.php +++ b/src/fieldlayoutelements/BaseField.php @@ -843,7 +843,6 @@ protected function actionMenuItems(?ElementInterface $element = null, bool $stat * Return the HTML that should be shown for the native field in the card preview. * It can be used outside an element context, e.g. in a card view designer. * - * @param mixed $value * @param ElementInterface|null $element * @return string * @since 5.5.0 diff --git a/src/fieldlayoutelements/CustomField.php b/src/fieldlayoutelements/CustomField.php index b521cb6eeaf..fc7b155e7ad 100644 --- a/src/fieldlayoutelements/CustomField.php +++ b/src/fieldlayoutelements/CustomField.php @@ -254,7 +254,7 @@ protected function containerAttributes(?ElementInterface $element = null, bool $ return ArrayHelper::merge(parent::containerAttributes($element, $static), [ 'id' => "{$this->_field->handle}-field", 'data' => [ - 'type' => get_class($field), + 'type' => $field::class, ], ]); } diff --git a/src/fieldlayoutelements/Html.php b/src/fieldlayoutelements/Html.php index 9128d461c22..3cfc022db56 100644 --- a/src/fieldlayoutelements/Html.php +++ b/src/fieldlayoutelements/Html.php @@ -20,14 +20,11 @@ */ class Html extends FieldLayoutElement { - private string $html; - /** * Constructor */ - public function __construct(string $html, array $config = []) + public function __construct(private string $html, array $config = []) { - $this->html = $html; parent::__construct($config); } diff --git a/src/fields/BaseOptionsField.php b/src/fields/BaseOptionsField.php index 3b41be8c798..3f2fec37e5e 100644 --- a/src/fields/BaseOptionsField.php +++ b/src/fields/BaseOptionsField.php @@ -372,7 +372,6 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed * Check if given option should be marked as selected. * * @param array $option - * @param mixed $value * @param array $selectedValues * @param bool $selectedBlankOption * @return bool diff --git a/src/fields/Lightswitch.php b/src/fields/Lightswitch.php index de51dfabd08..c57e4307f31 100644 --- a/src/fields/Lightswitch.php +++ b/src/fields/Lightswitch.php @@ -174,7 +174,6 @@ public function getStaticHtml(mixed $value, ?ElementInterface $element = null): /** * Render html for both static and interactive lightswitch field * - * @param mixed $value * @param ElementInterface|null $element * @param bool $static * @return string diff --git a/src/fields/Money.php b/src/fields/Money.php index 9ba5e09c170..f7728caa0c9 100644 --- a/src/fields/Money.php +++ b/src/fields/Money.php @@ -264,7 +264,6 @@ public function serializeValue(mixed $value, ElementInterface $element = null): } /** - * @param mixed $value * @param string|null $currency * @return string|null */ diff --git a/src/fields/Number.php b/src/fields/Number.php index 13a29870ac2..10b9947f149 100644 --- a/src/fields/Number.php +++ b/src/fields/Number.php @@ -230,7 +230,6 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed } /** - * @param mixed $value * @return int|float|null */ private function _normalizeNumber(mixed $value): float|int|null @@ -274,7 +273,7 @@ protected function inputHtml(mixed $value, ?ElementInterface $element, bool $inl try { $formatNumber = !$this->step && !$formatter->willBeMisrepresented($value); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { $formatNumber = false; } diff --git a/src/fields/Range.php b/src/fields/Range.php index 03cc437a3e4..e3a4dbc5ab9 100644 --- a/src/fields/Range.php +++ b/src/fields/Range.php @@ -178,7 +178,6 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed } /** - * @param mixed $value * @return int|float|null */ private function _normalizeNumber(mixed $value): int|float|null diff --git a/src/fields/Table.php b/src/fields/Table.php index da4f1b6b3b5..0d1d52c0d68 100644 --- a/src/fields/Table.php +++ b/src/fields/Table.php @@ -696,7 +696,6 @@ private function _validateCellValue(string $type, mixed $value, ?string &$error /** * Returns the field's input HTML. * - * @param mixed $value * @param ElementInterface|null $element * @param bool $static * @return string diff --git a/src/fields/data/ColorData.php b/src/fields/data/ColorData.php index e625daaa0ca..0e67f0393be 100644 --- a/src/fields/data/ColorData.php +++ b/src/fields/data/ColorData.php @@ -26,13 +26,8 @@ * @author Top Shelf Craft * @since 3.0.0 */ -class ColorData extends BaseObject implements Serializable +class ColorData extends BaseObject implements Serializable, \Stringable { - /** - * @var string The color’s hex value - */ - private string $_hex; - /** * @var array * @see _hsl() @@ -42,12 +37,11 @@ class ColorData extends BaseObject implements Serializable /** * Constructor. * - * @param string $hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.) + * @param string $_hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.) * @param array $config name-value pairs that will be used to initialize the object properties */ - public function __construct(string $hex, array $config = []) + public function __construct(private string $_hex, array $config = []) { - $this->_hex = $hex; parent::__construct($config); } diff --git a/src/fields/data/LinkData.php b/src/fields/data/LinkData.php index 7ba229cd267..aea8c2b6a4d 100644 --- a/src/fields/data/LinkData.php +++ b/src/fields/data/LinkData.php @@ -30,7 +30,7 @@ * @author Pixel & Tonic, Inc. * @since 5.3.0 */ -class LinkData extends BaseObject implements Serializable +class LinkData extends BaseObject implements Serializable, \Stringable { /** * @var string|null The link’s URL suffix value. diff --git a/src/fields/data/MultiOptionsFieldData.php b/src/fields/data/MultiOptionsFieldData.php index ae7ddd1ce6e..9f4a205b1d0 100644 --- a/src/fields/data/MultiOptionsFieldData.php +++ b/src/fields/data/MultiOptionsFieldData.php @@ -43,7 +43,6 @@ public function setOptions(array $options): void } /** - * @param mixed $value * @return bool */ public function contains(mixed $value): bool diff --git a/src/fields/data/OptionData.php b/src/fields/data/OptionData.php index a9ae7ad1872..e0d01e6f617 100644 --- a/src/fields/data/OptionData.php +++ b/src/fields/data/OptionData.php @@ -15,29 +15,8 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class OptionData implements Serializable +class OptionData implements Serializable, \Stringable { - /** - * @var string|null - */ - public ?string $label = null; - - /** - * @var string|null - */ - public ?string $value = null; - - /** - * @var bool - */ - public bool $selected; - - /** - * @var bool - * @since 3.5.10 - */ - public bool $valid; - /** * Constructor * @@ -46,12 +25,15 @@ class OptionData implements Serializable * @param bool $selected * @param bool $valid */ - public function __construct(?string $label, ?string $value, bool $selected, bool $valid = true) - { - $this->label = $label; - $this->value = $value; - $this->selected = $selected; - $this->valid = $valid; + public function __construct( + public ?string $label, + public ?string $value, + public bool $selected, + /** + * @since 3.5.10 + */ + public bool $valid = true, + ) { } /** diff --git a/src/fields/linktypes/Url.php b/src/fields/linktypes/Url.php index d87e4d4bf20..891e5823c8b 100644 --- a/src/fields/linktypes/Url.php +++ b/src/fields/linktypes/Url.php @@ -80,7 +80,7 @@ public function validateValue(string $value, ?string &$error = null): bool // Leveraging Uri package to convert domains to punycode $value = Uri::new($value); return parent::validateValue($value, $error); - } catch (\Exception $e) { + } catch (\Exception) { return false; } } diff --git a/src/gql/ElementQueryConditionBuilder.php b/src/gql/ElementQueryConditionBuilder.php index b985133838b..e4d8e66d281 100644 --- a/src/gql/ElementQueryConditionBuilder.php +++ b/src/gql/ElementQueryConditionBuilder.php @@ -236,7 +236,6 @@ private function _extractArgumentValue(Node $argumentNode): mixed * Figure out whether a node in the parentfield is a special eager-loadable field. * * @param string $nodeName - * @param mixed $parentField * @return bool */ private function _isAdditionalEagerLoadableNode(string $nodeName, mixed $parentField): bool diff --git a/src/gql/GqlEntityRegistry.php b/src/gql/GqlEntityRegistry.php index dc775971a2d..e06b5407ae0 100644 --- a/src/gql/GqlEntityRegistry.php +++ b/src/gql/GqlEntityRegistry.php @@ -92,7 +92,6 @@ public static function getEntity(string $entityName): mixed * Create an entity registry entry. * * @param string $entityName - * @param mixed $entity * @return mixed */ public static function createEntity(string $entityName, mixed $entity): mixed diff --git a/src/gql/base/ArgumentHandler.php b/src/gql/base/ArgumentHandler.php index c4fea513fc0..252cf554788 100644 --- a/src/gql/base/ArgumentHandler.php +++ b/src/gql/base/ArgumentHandler.php @@ -34,7 +34,6 @@ public function setArgumentManager(ArgumentManager $argumentManager): void /** * Handle a single argument value * - * @param mixed $argumentValue * @return mixed */ abstract protected function handleArgument(mixed $argumentValue): mixed; diff --git a/src/gql/base/ElementResolver.php b/src/gql/base/ElementResolver.php index f5455d2e4d1..b405d9cb78f 100644 --- a/src/gql/base/ElementResolver.php +++ b/src/gql/base/ElementResolver.php @@ -29,9 +29,7 @@ abstract class ElementResolver extends Resolver /** * Resolve an element query to a single result. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return mixed */ @@ -55,7 +53,6 @@ public static function resolve(mixed $source, array $arguments, mixed $context, /** * Resolve an element query to a total count of elements. * - * @param mixed $source * @param array $arguments * @param array|null $context * @param ResolveInfo $resolveInfo @@ -70,7 +67,6 @@ public static function resolveCount(mixed $source, array $arguments, ?array $con /** * Prepare an element query for given resolution argument set. * - * @param mixed $source * @param array $arguments * @param array|null $context * @param ResolveInfo $resolveInfo diff --git a/src/gql/base/Generator.php b/src/gql/base/Generator.php index 2f112951f5d..31641f73a44 100644 --- a/src/gql/base/Generator.php +++ b/src/gql/base/Generator.php @@ -23,7 +23,6 @@ abstract class Generator /** * Get content fields for a given context. * - * @param mixed $context * @return array */ protected static function getContentFields(mixed $context): array diff --git a/src/gql/base/MutationResolver.php b/src/gql/base/MutationResolver.php index 3ee1a642002..5496e5d32c6 100644 --- a/src/gql/base/MutationResolver.php +++ b/src/gql/base/MutationResolver.php @@ -20,27 +20,15 @@ */ abstract class MutationResolver extends Component { - /** - * @var array Data that might be useful during mutation resolution. - */ - private array $_resolutionData; - - /** - * @var callable[] Value normalizers stored by argument name - */ - private array $_valueNormalizers = []; - /** * Construct a mutation resolver and store the resolution data as well as normalizers, if any provided. * - * @param array $data Resolver data - * @param array $valueNormalizers Data normalizers + * @param array $_resolutionData Resolver data + * @param array $_valueNormalizers Data normalizers * @param array $config */ - public function __construct(array $data = [], array $valueNormalizers = [], array $config = []) + public function __construct(private array $_resolutionData = [], private array $_valueNormalizers = [], array $config = []) { - $this->_resolutionData = $data; - $this->_valueNormalizers = $valueNormalizers; parent::__construct($config); } @@ -48,7 +36,6 @@ public function __construct(array $data = [], array $valueNormalizers = [], arra * Set a piece of data to be used by the resolver when resolving. * * @param string $key - * @param mixed $value */ public function setResolutionData(string $key, mixed $value): void { @@ -85,7 +72,6 @@ public function getResolutionData(string $key): mixed * Normalize a value according to stored normalizers. * * @param string $argument - * @param mixed $value * @return mixed */ protected function normalizeValue(string $argument, mixed $value): mixed diff --git a/src/gql/resolvers/mutations/Asset.php b/src/gql/resolvers/mutations/Asset.php index bbdfa5323bf..d0d2dd018bb 100644 --- a/src/gql/resolvers/mutations/Asset.php +++ b/src/gql/resolvers/mutations/Asset.php @@ -39,9 +39,7 @@ class Asset extends ElementMutationResolver /** * Save an asset using the passed arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return AssetElement * @throws Throwable if reasons. @@ -109,9 +107,7 @@ public function saveAsset(mixed $source, array $arguments, mixed $context, Resol /** * Delete an asset identified by the arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Category.php b/src/gql/resolvers/mutations/Category.php index a42e3b3015e..8e4866cdeda 100644 --- a/src/gql/resolvers/mutations/Category.php +++ b/src/gql/resolvers/mutations/Category.php @@ -34,9 +34,7 @@ class Category extends ElementMutationResolver /** * Save a category using the passed arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return CategoryElement * @throws Throwable if reasons. @@ -80,9 +78,7 @@ public function saveCategory(mixed $source, array $arguments, mixed $context, Re /** * Delete a category identified by the arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Entry.php b/src/gql/resolvers/mutations/Entry.php index 67f42261895..554435eee54 100644 --- a/src/gql/resolvers/mutations/Entry.php +++ b/src/gql/resolvers/mutations/Entry.php @@ -39,9 +39,7 @@ class Entry extends ElementMutationResolver /** * Save an entry or draft using the passed arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return EntryElement * @throws Throwable if reasons. @@ -115,9 +113,7 @@ public function saveEntry(mixed $source, array $arguments, mixed $context, Resol /** * Delete an entry identified by the passed arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. @@ -144,9 +140,7 @@ public function deleteEntry(mixed $source, array $arguments, mixed $context, Res /** * Create a new draft for the entry ID identified by the arguments * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return mixed * @throws Throwable if reasons. @@ -187,9 +181,7 @@ public function createDraft(mixed $source, array $arguments, mixed $context, Res /** * Publish a draft identified by the arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return int * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/GlobalSet.php b/src/gql/resolvers/mutations/GlobalSet.php index ac065853892..e62ae471535 100644 --- a/src/gql/resolvers/mutations/GlobalSet.php +++ b/src/gql/resolvers/mutations/GlobalSet.php @@ -24,9 +24,7 @@ class GlobalSet extends ElementMutationResolver /** * Save the global set identified by resolver data. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return GlobalSetElement * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Tag.php b/src/gql/resolvers/mutations/Tag.php index 01cfd16a136..d44fc91d752 100644 --- a/src/gql/resolvers/mutations/Tag.php +++ b/src/gql/resolvers/mutations/Tag.php @@ -31,9 +31,7 @@ class Tag extends ElementMutationResolver /** * Save a tag using the passed arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return TagElement * @throws Throwable if reasons. @@ -74,9 +72,7 @@ public function saveTag(mixed $source, array $arguments, mixed $context, Resolve /** * Delete a tag identified by the arguments. * - * @param mixed $source * @param array $arguments - * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/types/input/Addresses.php b/src/gql/types/input/Addresses.php index 296d8f2b716..c73f76be57f 100644 --- a/src/gql/types/input/Addresses.php +++ b/src/gql/types/input/Addresses.php @@ -141,7 +141,6 @@ public static function getType(): mixed /** * Normalize Matrix GraphQL input data to what Craft expects. * - * @param mixed $value * @return mixed */ public static function normalizeValue(mixed $value): mixed diff --git a/src/gql/types/input/Matrix.php b/src/gql/types/input/Matrix.php index 343f07b50fc..e9b59fa10a0 100644 --- a/src/gql/types/input/Matrix.php +++ b/src/gql/types/input/Matrix.php @@ -99,7 +99,6 @@ public static function getType(MatrixField $context): mixed /** * Normalize Matrix GraphQL input data to what Craft expects. * - * @param mixed $value * @return mixed */ public static function normalizeValue(mixed $value): mixed diff --git a/src/helpers/App.php b/src/helpers/App.php index 2880adb394c..26423eb817d 100644 --- a/src/helpers/App.php +++ b/src/helpers/App.php @@ -240,7 +240,6 @@ public static function parseEnv(?string $value): bool|string|null * $status = App::parseBooleanEnv('$SYSTEM_STATUS') ?? false; * ``` * - * @param mixed $value * @return bool|null * @since 3.7.29 */ @@ -440,7 +439,6 @@ public static function extensionVersion(string $name): string * - `'false'` → `false` * - Numeric string → integer or float * - * @param mixed $value * @return mixed * @since 4.0.0 */ @@ -1432,7 +1430,7 @@ public static function licensingIssues(bool $withUnresolvables = true, bool $fet // If the license key path starts with the root project path, trim the project path off $rootPath = Craft::getAlias('@root'); - if (strpos($keyPath, $rootPath . '/') === 0) { + if (str_starts_with($keyPath, $rootPath . '/')) { $keyPath = substr($keyPath, strlen($rootPath) + 1); } diff --git a/src/helpers/ArrayHelper.php b/src/helpers/ArrayHelper.php index e023b516bf1..6c928ab01bf 100644 --- a/src/helpers/ArrayHelper.php +++ b/src/helpers/ArrayHelper.php @@ -68,7 +68,7 @@ public static function toArray($object, $properties = [], $recursive = true): ar * @since 3.4.0 * @deprecated in 4.0.0. `array_unshift()` should be used instead. */ - public static function prepend(array &$array, ...$values): void + public static function prepend(array &$array, mixed ...$values): void { array_unshift($array, ...$values); } @@ -86,7 +86,7 @@ public static function prepend(array &$array, ...$values): void * @since 3.4.0 * @deprecated in 4.0.0. `array_push()` should be used instead. */ - public static function append(array &$array, ...$values): void + public static function append(array &$array, mixed ...$values): void { array_push($array, ...$values); } @@ -416,7 +416,6 @@ public static function without(array $array, string $key): array * Returns a copy of an array without items matching the given value. * * @param array $array - * @param mixed $value * @return array */ public static function withoutValue(array $array, mixed $value): array diff --git a/src/helpers/Assets.php b/src/helpers/Assets.php index 0e78935621c..6f524204473 100644 --- a/src/helpers/Assets.php +++ b/src/helpers/Assets.php @@ -831,7 +831,6 @@ public static function scaledDimensions(int $realWidth, int $realHeight, int $ma /** * Parses a srcset size (e.g. `100w` or `2x`). * - * @param mixed $size * @return array An array of the size value and unit (`w` or `x`) * @throws InvalidArgumentException if the size can’t be parsed * @since 3.5.0 diff --git a/src/helpers/ConfigHelper.php b/src/helpers/ConfigHelper.php index b1793aa480c..71ba52007dc 100644 --- a/src/helpers/ConfigHelper.php +++ b/src/helpers/ConfigHelper.php @@ -28,7 +28,6 @@ class ConfigHelper * - DateInterval object * - an empty value (represents 0 seconds) * - * @param mixed $value * @return int The time duration in seconds * @throws InvalidConfigException if the duration can't be determined */ diff --git a/src/helpers/Cp.php b/src/helpers/Cp.php index 5865fe3bce4..19e1b85cb52 100644 --- a/src/helpers/Cp.php +++ b/src/helpers/Cp.php @@ -241,7 +241,7 @@ public static function alerts(?string $path = null, bool $fetch = false): array while (true) { try { $tagInfo = Html::parseTag($alert['content'], $offset); - } catch (InvalidHtmlTagException $e) { + } catch (InvalidHtmlTagException) { break; } @@ -370,7 +370,7 @@ public static function chipHtml(Chippable $component, array $config = []): strin '--custom-sel-bg-color' => $color?->cssVar(900), ]), 'data' => array_filter([ - 'type' => get_class($component), + 'type' => $component::class, 'id' => $component->getId(), 'settings' => $config['autoReload'] ? [ 'selectable' => $config['selectable'], @@ -924,7 +924,7 @@ private static function baseElementAttributes(ElementInterface $element, array $ ($config['context'] === 'field' && $element->hasErrors()) ? 'error' : null, ]), 'data' => array_filter([ - 'type' => get_class($element), + 'type' => $element::class, 'id' => $element->isProvisionalDraft ? $element->getCanonicalId() : $element->id, 'draft-id' => $element->isProvisionalDraft ? null : $element->draftId, 'revision-id' => $element->revisionId, @@ -2966,7 +2966,7 @@ public static function layoutElementSelectorHtml( ]), 'data' => [ 'uid' => !$forLibrary ? $element->uid : false, - 'config' => $forLibrary ? ['type' => get_class($element)] + $element->toArray() : false, + 'config' => $forLibrary ? ['type' => $element::class] + $element->toArray() : false, 'ui-label' => $forLibrary && $element instanceof CustomField ? $element->getField()->getUiLabel() : false, 'is-multi-instance' => $element->isMultiInstance(), 'has-custom-width' => $element->hasCustomWidth(), diff --git a/src/helpers/DateTimeHelper.php b/src/helpers/DateTimeHelper.php index 9d4277fe154..50885db651e 100644 --- a/src/helpers/DateTimeHelper.php +++ b/src/helpers/DateTimeHelper.php @@ -547,7 +547,6 @@ public static function secondsToHumanTimeDuration(int $seconds, bool $showSecond } /** - * @param mixed $timestamp * @return bool */ public static function isValidTimeStamp(mixed $timestamp): bool diff --git a/src/helpers/Db.php b/src/helpers/Db.php index b6c4995c411..8b92569f60a 100644 --- a/src/helpers/Db.php +++ b/src/helpers/Db.php @@ -929,7 +929,7 @@ public static function parseTimestampParam( * @return bool Whether the value was normalized * @since 3.7.40 */ - public static function normalizeParam(&$value, callable $resolver): bool + public static function normalizeParam(mixed &$value, callable $resolver): bool { if ($value === null) { return true; diff --git a/src/helpers/Diff.php b/src/helpers/Diff.php index c33e5b84416..bc7a92d3de5 100644 --- a/src/helpers/Diff.php +++ b/src/helpers/Diff.php @@ -20,8 +20,6 @@ class Diff /** * Generates a diff for two values, represented as YAML. * - * @param mixed $from - * @param mixed $to * @param int $indent The indent size that nested values should have * @param int $contextLines The number of lines to show before and after changes * @return string @@ -76,8 +74,6 @@ public static function diff(mixed $from, mixed $to, int $indent = 2, int $contex } /** - * @param mixed$from - * @param mixed $to * @param int $indent * @param int $level * @return array[] @@ -151,8 +147,6 @@ private static function _buildLine(string $line, int $indent, int $level, ?strin * * If the values are both arrays, they will be compared recursively. * - * @param mixed $a - * @param mixed $b * @param bool $strict Whether strict comparisons should be used * @return bool * @since 3.6.0 diff --git a/src/helpers/ElementHelper.php b/src/helpers/ElementHelper.php index de05cdae13a..86e8611b3dd 100644 --- a/src/helpers/ElementHelper.php +++ b/src/helpers/ElementHelper.php @@ -319,7 +319,7 @@ public static function supportedSitesForElement(ElementInterface $element, bool ]; } else { if (!isset($site['siteId'])) { - throw new Exception('Missing "siteId" key in ' . get_class($element) . '::getSupportedSites()'); + throw new Exception('Missing "siteId" key in ' . $element::class . '::getSupportedSites()'); } $site['siteId'] = (int)$site['siteId']; } diff --git a/src/helpers/FileHelper.php b/src/helpers/FileHelper.php index 85f1dacc070..d51432a6279 100644 --- a/src/helpers/FileHelper.php +++ b/src/helpers/FileHelper.php @@ -274,7 +274,7 @@ public static function sanitizeFilename(string $filename, array $options = []): // Always use the primary site language, so file paths/names are normalized // to ASCII consistently regardless of who is logged in. $language = Craft::$app->getSites()->getPrimarySite()->language; - } catch (SiteNotFoundException $e) { + } catch (SiteNotFoundException) { $language = Craft::$app->language; } @@ -579,7 +579,7 @@ public static function clearDirectory(string $dir, array $options = []): void static::removeDirectory($path, $options); } catch (UnexpectedValueException $e) { // Ignore if the folder has already been removed. - if (strpos($e->getMessage(), 'No such file or directory') === false) { + if (!str_contains($e->getMessage(), 'No such file or directory')) { Craft::warning("Tried to remove " . $path . ", but it doesn't exist."); throw $e; } diff --git a/src/helpers/Gql.php b/src/helpers/Gql.php index 535ae058129..71522f59e52 100644 --- a/src/helpers/Gql.php +++ b/src/helpers/Gql.php @@ -289,7 +289,6 @@ public static function getUnionType(string $typeName, array $includedTypes, ?cal /** * Wrap a GQL object type in a NonNull type. * - * @param mixed $type * @return mixed */ public static function wrapInNonNull(mixed $type): mixed @@ -343,9 +342,7 @@ public static function createFullAccessSchema(): GqlSchema /** * Apply directives (if any) to a resolved value according to source and resolve info. * - * @param mixed $source * @param ResolveInfo $resolveInfo - * @param mixed $value * @return mixed */ public static function applyDirectives(mixed $source, ResolveInfo $resolveInfo, mixed $value): mixed @@ -450,7 +447,6 @@ public static function getAllowedSites(?GqlSchema $schema = null): array } /** - * @param mixed $value * @param array $variableValues * @return mixed */ @@ -471,7 +467,6 @@ private static function _convertArgumentValue(mixed $value, array $variableValue * Looking at the resolve information and the source queried, return the field name or it's alias, if used. * * @param ResolveInfo $resolveInfo - * @param mixed $source * @param array|null $context * @return string */ diff --git a/src/helpers/Html.php b/src/helpers/Html.php index b1e7a921001..bc5a7826c54 100644 --- a/src/helpers/Html.php +++ b/src/helpers/Html.php @@ -557,7 +557,6 @@ public static function normalizeTagAttributes(array $attributes): array /** * Explodes a `class` attribute into an array. * - * @param mixed $value * @return string[] * @since 3.5.0 */ @@ -578,7 +577,6 @@ public static function explodeClass(mixed $value): array /** * Explodes a `style` attribute into an array of property/value pairs. * - * @param mixed $value * @return string[] * @since 3.5.0 */ diff --git a/src/helpers/ImageTransforms.php b/src/helpers/ImageTransforms.php index 8b54a4a31e6..fddaa1980b2 100644 --- a/src/helpers/ImageTransforms.php +++ b/src/helpers/ImageTransforms.php @@ -263,7 +263,6 @@ public static function parseTransformString(string $str): array /** * Normalize a transform from handle or a set of properties to an ImageTransform. * - * @param mixed $transform * @return ImageTransform|null * @throws ImageTransformException if $transform is an invalid transform handle */ diff --git a/src/helpers/MailerHelper.php b/src/helpers/MailerHelper.php index 0d9cab898a0..db720e55911 100644 --- a/src/helpers/MailerHelper.php +++ b/src/helpers/MailerHelper.php @@ -144,7 +144,7 @@ public static function normalizeEmails(mixed $emails): array */ public static function settingsReport(Mailer $mailer, ?TransportAdapterInterface $transportAdapter = null): string { - $transportType = $transportAdapter ? get_class($transportAdapter) : App::mailSettings()->transportType; + $transportType = $transportAdapter ? $transportAdapter::class : App::mailSettings()->transportType; $settings = [ Craft::t('app', 'From') => self::_emailList($mailer->from), Craft::t('app', 'Reply To') => self::_emailList($mailer->replyTo), @@ -186,7 +186,6 @@ public static function settingsReport(Mailer $mailer, ?TransportAdapterInterface /** * Normalizes a list of emails and returns them in a comma-separated list. * - * @param mixed $emails * @return string */ private static function _emailList(mixed $emails): string diff --git a/src/helpers/MoneyHelper.php b/src/helpers/MoneyHelper.php index 871cc316c16..5cd4fa98cbe 100644 --- a/src/helpers/MoneyHelper.php +++ b/src/helpers/MoneyHelper.php @@ -31,7 +31,6 @@ class MoneyHelper private static ISOCurrencies $_isoCurrencies; /** - * @param mixed $value * @return Money|false */ public static function toMoney(mixed $value): Money|false @@ -57,7 +56,6 @@ public static function toMoney(mixed $value): Money|false /** * Convert money object to standard decimal string. * - * @param mixed $value * @return string|false */ public static function toDecimal(mixed $value): string|false @@ -72,7 +70,6 @@ public static function toDecimal(mixed $value): string|false /** * Convert money object to localized currency string. * - * @param mixed $value * @param string|null $formatLocale * @return string|false */ @@ -95,7 +92,6 @@ public static function toString(mixed $value, ?string $formatLocale = null): str /** * Convert money object to localized decimal string. * - * @param mixed $value * @param string|null $formatLocale * @return string|false */ diff --git a/src/helpers/Number.php b/src/helpers/Number.php index 5fe7db93751..14b9e9d602f 100644 --- a/src/helpers/Number.php +++ b/src/helpers/Number.php @@ -131,7 +131,6 @@ public static function lowerRoman(int $num): string * If the variable is an object with a __toString() method, the numeric value of its string representation will be * returned. * - * @param mixed $var * @return float|int|string */ public static function makeNumeric(mixed $var): float|int|string @@ -150,7 +149,6 @@ public static function makeNumeric(mixed $var): float|int|string /** * Returns whether the given value is an int or float, or a string that represents an int or float. * - * @param mixed $value * @return bool * @since 4.0.5 */ diff --git a/src/helpers/ProjectConfig.php b/src/helpers/ProjectConfig.php index 8474e40901c..565012c6bc6 100644 --- a/src/helpers/ProjectConfig.php +++ b/src/helpers/ProjectConfig.php @@ -26,7 +26,6 @@ class ProjectConfig /** * Returns a project config compatible value encoded for storage. * - * @param mixed $value * @return string * @since 4.0.0 */ @@ -282,7 +281,6 @@ public static function cleanupConfig(array $config): array /** * Cleans a config value. * - * @param mixed $value * @return mixed * @throws InvalidConfigException */ diff --git a/src/helpers/Session.php b/src/helpers/Session.php index cc804767dc1..20b76e45e0e 100644 --- a/src/helpers/Session.php +++ b/src/helpers/Session.php @@ -204,7 +204,7 @@ public static function hasFlash(string $key): bool * @see YiiSession::addFlash() * @since 5.5.0 */ - public static function addFlash($key, $value = true, $removeAfterAccess = true): void + public static function addFlash($key, mixed $value = true, $removeAfterAccess = true): void { self::session()?->addFlash($key, $value, $removeAfterAccess); } diff --git a/src/helpers/StringHelper.php b/src/helpers/StringHelper.php index f1207339cce..7bc3454553c 100644 --- a/src/helpers/StringHelper.php +++ b/src/helpers/StringHelper.php @@ -413,11 +413,11 @@ public static function dasherize(string $str): string */ public static function decdec(string $str): string { - if (strncmp($str, 'base64:', 7) === 0) { + if (str_starts_with($str, 'base64:')) { $str = base64_decode(substr($str, 7)); } - if (strncmp($str, 'crypt:', 6) === 0) { + if (str_starts_with($str, 'crypt:')) { $str = Craft::$app->getSecurity()->decryptByKey(substr($str, 6)); } diff --git a/src/helpers/Template.php b/src/helpers/Template.php index 8f3151d9e8f..301856643bc 100644 --- a/src/helpers/Template.php +++ b/src/helpers/Template.php @@ -139,7 +139,7 @@ public static function attribute( // Convert any \Twig\Markup arguments back to strings (unless the class *extends* \Twig\Markup) foreach ($arguments as $key => $value) { - if (is_object($value) && get_class($value) === Markup::class) { + if (is_object($value) && $value::class === Markup::class) { $arguments[$key] = (string)$value; } } diff --git a/src/i18n/Formatter.php b/src/i18n/Formatter.php index a4affc8aa2b..87182cd5c14 100644 --- a/src/i18n/Formatter.php +++ b/src/i18n/Formatter.php @@ -80,7 +80,7 @@ public function asDate($value, $format = null): string $format = $this->dateTimeFormats[$format]['date']; } - if (strncmp($format, 'php:', 4) === 0) { + if (str_starts_with($format, 'php:')) { return $this->_formatDateTimeValueWithPhpFormat($value, substr($format, 4), 'date'); } @@ -105,7 +105,7 @@ public function asTime($value, $format = null): string $format = $this->dateTimeFormats[$format]['time']; } - if (strncmp($format, 'php:', 4) === 0) { + if (str_starts_with($format, 'php:')) { return $this->_formatDateTimeValueWithPhpFormat($value, substr($format, 4), 'time'); } @@ -130,7 +130,7 @@ public function asDatetime($value, $format = null): string $format = $this->dateTimeFormats[$format]['datetime']; } - if (strncmp($format, 'php:', 4) === 0) { + if (str_starts_with($format, 'php:')) { return $this->_formatDateTimeValueWithPhpFormat($value, substr($format, 4), 'datetime'); } diff --git a/src/i18n/Locale.php b/src/i18n/Locale.php index e9f57c6b393..4521ddaf7bb 100644 --- a/src/i18n/Locale.php +++ b/src/i18n/Locale.php @@ -22,7 +22,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class Locale extends BaseObject +class Locale extends BaseObject implements \Stringable { /** * @var int Positive prefix. @@ -493,18 +493,11 @@ public function getMonthName(int $month, ?string $length = null, bool $standAlon $formatter = new IntlDateFormatter($this->aliasOf ?? $this->id, IntlDateFormatter::NONE, IntlDateFormatter::NONE); - switch ($length) { - case self::LENGTH_ABBREVIATED: - $formatter->setPattern($standAlone ? 'LLLLL' : 'MMMMM'); - break; // S - case self::LENGTH_SHORT: - case self::LENGTH_MEDIUM: - $formatter->setPattern($standAlone ? 'LLL' : 'MMM'); - break; // Sep - default: - $formatter->setPattern($standAlone ? 'LLLL' : 'MMMM'); - break; // September - } + match ($length) { + self::LENGTH_ABBREVIATED => $formatter->setPattern($standAlone ? 'LLLLL' : 'MMMMM'), + self::LENGTH_SHORT, self::LENGTH_MEDIUM => $formatter->setPattern($standAlone ? 'LLL' : 'MMM'), + default => $formatter->setPattern($standAlone ? 'LLLL' : 'MMMM'), + }; return $formatter->format(new DateTime('1970-' . sprintf('%02d', $month) . '-01')); } @@ -543,24 +536,12 @@ public function getWeekDayName(int $day, ?string $length = null, bool $standAlon $formatter = new IntlDateFormatter($this->aliasOf ?? $this->id, IntlDateFormatter::NONE, IntlDateFormatter::NONE); - switch ($length) { - case self::LENGTH_ABBREVIATED: - // T - $formatter->setPattern($standAlone ? 'ccccc' : 'eeeee'); - break; - case self::LENGTH_SHORT: - // Tu - $formatter->setPattern($standAlone ? 'cccccc' : 'eeeeee'); - break; - case self::LENGTH_MEDIUM: - // Tue - $formatter->setPattern($standAlone ? 'ccc' : 'eee'); - break; - default: - // Tuesday - $formatter->setPattern($standAlone ? 'cccc' : 'eeee'); - break; - } + match ($length) { + self::LENGTH_ABBREVIATED => $formatter->setPattern($standAlone ? 'ccccc' : 'eeeee'), + self::LENGTH_SHORT => $formatter->setPattern($standAlone ? 'cccccc' : 'eeeeee'), + self::LENGTH_MEDIUM => $formatter->setPattern($standAlone ? 'ccc' : 'eee'), + default => $formatter->setPattern($standAlone ? 'cccc' : 'eeee'), + }; // 1970-01-04 => Sunday (0 + 4) // 1970-01-05 => Monday (1 + 4) diff --git a/src/migrations/BaseContentRefactorMigration.php b/src/migrations/BaseContentRefactorMigration.php index 5f2907a162c..8ce35b16666 100644 --- a/src/migrations/BaseContentRefactorMigration.php +++ b/src/migrations/BaseContentRefactorMigration.php @@ -309,27 +309,12 @@ private function decodeValue(mixed $value, string|array|null $dbType, ColumnSche return ['date' => $value]; } } - - switch ($dbType) { - case Schema::TYPE_TINYINT: - case Schema::TYPE_SMALLINT: - case Schema::TYPE_INTEGER: - case Schema::TYPE_BIGINT: - return (int)$value; - - case Schema::TYPE_FLOAT: - case Schema::TYPE_DOUBLE: - case Schema::TYPE_DECIMAL: - case Schema::TYPE_MONEY: - return (float)$value; - - case Schema::TYPE_BOOLEAN: - return (bool)$value; - - case Schema::TYPE_JSON: - return Json::decodeIfJson($value); - } - - return $value; + return match ($dbType) { + Schema::TYPE_TINYINT, Schema::TYPE_SMALLINT, Schema::TYPE_INTEGER, Schema::TYPE_BIGINT => (int)$value, + Schema::TYPE_FLOAT, Schema::TYPE_DOUBLE, Schema::TYPE_DECIMAL, Schema::TYPE_MONEY => (float)$value, + Schema::TYPE_BOOLEAN => (bool)$value, + Schema::TYPE_JSON => Json::decodeIfJson($value), + default => $value, + }; } } diff --git a/src/models/AssetIndexData.php b/src/models/AssetIndexData.php index 146cfb280f7..2391089abfd 100644 --- a/src/models/AssetIndexData.php +++ b/src/models/AssetIndexData.php @@ -16,7 +16,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class AssetIndexData extends Model +class AssetIndexData extends Model implements \Stringable { /** * @var int|null ID diff --git a/src/models/CategoryGroup.php b/src/models/CategoryGroup.php index 81c65f96883..dbddc08bb90 100644 --- a/src/models/CategoryGroup.php +++ b/src/models/CategoryGroup.php @@ -35,7 +35,8 @@ class CategoryGroup extends Model implements Chippable, CpEditable, - FieldLayoutProviderInterface + FieldLayoutProviderInterface, + \Stringable { /** @since 3.7.0 */ public const DEFAULT_PLACEMENT_BEGINNING = 'beginning'; diff --git a/src/models/EntryType.php b/src/models/EntryType.php index 7c32a6b5c01..e6bf8013047 100644 --- a/src/models/EntryType.php +++ b/src/models/EntryType.php @@ -43,7 +43,8 @@ class EntryType extends Model implements Iconic, Indicative, Colorable, - Actionable + Actionable, + \Stringable { /** * @inheritdoc diff --git a/src/models/FieldLayoutTab.php b/src/models/FieldLayoutTab.php index 3ce2fdbf257..9867ce68cc1 100644 --- a/src/models/FieldLayoutTab.php +++ b/src/models/FieldLayoutTab.php @@ -215,7 +215,7 @@ public function getElementConfigs(): array if (!isset($layoutElement->uid)) { $layoutElement->uid = StringHelper::UUID(); } - $elementConfig = ['type' => get_class($layoutElement)] + $layoutElement->toArray(); + $elementConfig = ['type' => $layoutElement::class] + $layoutElement->toArray(); if (!isset($elementConfig['dateAdded'])) { // Default `dateAdded` to a minute ago, so there’s no chance that an element that predated 5.3 would get // the same timestamp as a newly-added element, if the layout was saved within a minute of being edited, diff --git a/src/models/GqlSchema.php b/src/models/GqlSchema.php index 865ddd842a2..4a723d3b9a6 100644 --- a/src/models/GqlSchema.php +++ b/src/models/GqlSchema.php @@ -18,7 +18,7 @@ * @author Pixel & Tonic, Inc. * @since 3.3.0 */ -class GqlSchema extends Model +class GqlSchema extends Model implements \Stringable { /** * @var int|null ID @@ -74,7 +74,7 @@ protected function defineRules(): array */ public function __toString(): string { - return $this->name; + return (string) $this->name; } /** diff --git a/src/models/GqlToken.php b/src/models/GqlToken.php index c67d20acb22..c29694a8a21 100644 --- a/src/models/GqlToken.php +++ b/src/models/GqlToken.php @@ -21,7 +21,7 @@ * @author Pixel & Tonic, Inc. * @since 3.4.0 */ -class GqlToken extends Model +class GqlToken extends Model implements \Stringable { /** * The public access token value. @@ -126,7 +126,7 @@ protected function defineRules(): array */ public function __toString(): string { - return $this->name; + return (string) $this->name; } /** diff --git a/src/models/ImageTransform.php b/src/models/ImageTransform.php index 15ef718faca..67d57d498f1 100644 --- a/src/models/ImageTransform.php +++ b/src/models/ImageTransform.php @@ -25,7 +25,7 @@ * @author Pixel & Tonic, Inc. * @since 4.0.0 */ -class ImageTransform extends Model +class ImageTransform extends Model implements \Stringable { /** * @var string The default image transformer diff --git a/src/models/ImageTransformIndex.php b/src/models/ImageTransformIndex.php index 46891be8100..dd481b26c40 100644 --- a/src/models/ImageTransformIndex.php +++ b/src/models/ImageTransformIndex.php @@ -22,7 +22,7 @@ * @author Pixel & Tonic, Inc. * @since 4.0.0 */ -class ImageTransformIndex extends Model +class ImageTransformIndex extends Model implements \Stringable { /** * @var int|null ID diff --git a/src/models/ProjectConfigData.php b/src/models/ProjectConfigData.php index 0b814a157d3..d929c823c72 100644 --- a/src/models/ProjectConfigData.php +++ b/src/models/ProjectConfigData.php @@ -46,8 +46,6 @@ public function getHasPathBeenModified(string $path): bool /** * Commit changes by firing the appropriate events and updating the appropriate storages. * - * @param mixed $oldValue - * @param mixed $newValue * @param string $path * @param bool $triggerUpdate * @param string|null $message @@ -111,7 +109,6 @@ public function commitChanges(mixed $oldValue, mixed $newValue, string $path, bo * Update the internal data storage. * * @param string|string[] $path - * @param mixed $value */ protected function setInternal(string|array $path, mixed $value): void { diff --git a/src/models/ReadOnlyProjectConfigData.php b/src/models/ReadOnlyProjectConfigData.php index 83744acb582..fcfdc66277c 100644 --- a/src/models/ReadOnlyProjectConfigData.php +++ b/src/models/ReadOnlyProjectConfigData.php @@ -20,14 +20,11 @@ */ class ReadOnlyProjectConfigData extends Model { - protected array $data; - /** @since 4.4.17 */ protected ProjectConfig $projectConfig; - public function __construct(array $data = [], ?ProjectConfig $projectConfig = null, array $config = []) + public function __construct(protected array $data = [], ?ProjectConfig $projectConfig = null, array $config = []) { - $this->data = $data; $this->projectConfig = $projectConfig ?? Craft::$app->getProjectConfig(); parent::__construct($config); diff --git a/src/models/Section.php b/src/models/Section.php index 558b0b7b159..d9e0197a57e 100644 --- a/src/models/Section.php +++ b/src/models/Section.php @@ -34,7 +34,7 @@ * @property EntryType[] $entryTypes Entry types * @property bool $hasMultiSiteEntries Whether entries in this section support multiple sites */ -class Section extends Model implements Chippable, CpEditable, Iconic +class Section extends Model implements Chippable, CpEditable, Iconic, \Stringable { public const TYPE_SINGLE = 'single'; public const TYPE_CHANNEL = 'channel'; diff --git a/src/models/Site.php b/src/models/Site.php index 4e60f4f1968..953940914e9 100644 --- a/src/models/Site.php +++ b/src/models/Site.php @@ -30,7 +30,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class Site extends Model implements Chippable +class Site extends Model implements Chippable, \Stringable { public static function get(int|string $id): ?static { diff --git a/src/models/SiteGroup.php b/src/models/SiteGroup.php index 5d63df812b2..cce61b63d8c 100644 --- a/src/models/SiteGroup.php +++ b/src/models/SiteGroup.php @@ -20,7 +20,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class SiteGroup extends Model +class SiteGroup extends Model implements \Stringable { /** * @var int|null ID diff --git a/src/models/TagGroup.php b/src/models/TagGroup.php index 23d1eee4b20..98ae8716db0 100644 --- a/src/models/TagGroup.php +++ b/src/models/TagGroup.php @@ -24,7 +24,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class TagGroup extends Model implements FieldLayoutProviderInterface +class TagGroup extends Model implements FieldLayoutProviderInterface, \Stringable { /** * @var int|null ID diff --git a/src/models/UserGroup.php b/src/models/UserGroup.php index 2cca1fb27fd..2dc22cf09f2 100644 --- a/src/models/UserGroup.php +++ b/src/models/UserGroup.php @@ -19,7 +19,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class UserGroup extends Model +class UserGroup extends Model implements \Stringable { /** * @var int|null ID diff --git a/src/models/VolumeFolder.php b/src/models/VolumeFolder.php index 6e6cb263cb8..e2474f05351 100644 --- a/src/models/VolumeFolder.php +++ b/src/models/VolumeFolder.php @@ -22,7 +22,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class VolumeFolder extends Model +class VolumeFolder extends Model implements \Stringable { /** * @var int|null ID diff --git a/src/queue/BaseBatchedJob.php b/src/queue/BaseBatchedJob.php index 077f7b84b0c..bbec1cd3d91 100644 --- a/src/queue/BaseBatchedJob.php +++ b/src/queue/BaseBatchedJob.php @@ -167,8 +167,6 @@ public function execute($queue): void /** * Processes an item. - * - * @param mixed $item */ abstract protected function processItem(mixed $item): void; diff --git a/src/queue/jobs/ApplyNewPropagationMethod.php b/src/queue/jobs/ApplyNewPropagationMethod.php index d24b10dbae2..99767e88811 100644 --- a/src/queue/jobs/ApplyNewPropagationMethod.php +++ b/src/queue/jobs/ApplyNewPropagationMethod.php @@ -131,7 +131,7 @@ protected function processItem(mixed $item): void // Just log it and move along Craft::warning(sprintf( "Unable to duplicate “%s” to site %d: %s", - get_class($otherSiteElement), + $otherSiteElement::class, $otherSiteElement->siteId, $e->getMessage() )); diff --git a/src/queue/jobs/PropagateElements.php b/src/queue/jobs/PropagateElements.php index ef52d544fd6..37debf4390e 100644 --- a/src/queue/jobs/PropagateElements.php +++ b/src/queue/jobs/PropagateElements.php @@ -88,7 +88,7 @@ protected function processItem(mixed $item): void foreach ($elementSiteIds as $siteId) { if ($siteId !== $item->siteId) { // Make sure the site element wasn't updated more recently than the main one - $siteElement = $elementsService->getElementById($item->id, get_class($item), $siteId); + $siteElement = $elementsService->getElementById($item->id, $item::class, $siteId); if ($siteElement === null || $siteElement->dateUpdated < $item->dateUpdated) { $elementsService->propagateElement($item, $siteId, $siteElement ?? false); } diff --git a/src/search/SearchQuery.php b/src/search/SearchQuery.php index 4352cb72a1f..251c02a2236 100644 --- a/src/search/SearchQuery.php +++ b/src/search/SearchQuery.php @@ -17,11 +17,6 @@ */ class SearchQuery { - /** - * @var string - */ - private string $_query; - /** * @var array * @phpstan-var array{subLeft:bool,subRight:bool,exclude:bool,exact:bool} @@ -36,13 +31,12 @@ class SearchQuery /** * Constructor * - * @param string $query + * @param string $_query * @param array $defaultTermOptions * @phpstan-param array{subLeft?:bool,subRight?:bool,exclude?:bool,exact?:bool} $defaultTermOptions */ - public function __construct(string $query, array $defaultTermOptions = []) + public function __construct(private string $_query, array $defaultTermOptions = []) { - $this->_query = $query; $this->_defaultTermOptions = $defaultTermOptions + [ 'subLeft' => false, 'subRight' => true, diff --git a/src/search/SearchQueryTermGroup.php b/src/search/SearchQueryTermGroup.php index 9af28c0f566..c1e0933332a 100644 --- a/src/search/SearchQueryTermGroup.php +++ b/src/search/SearchQueryTermGroup.php @@ -16,18 +16,12 @@ */ class SearchQueryTermGroup { - /** - * @var SearchQueryTerm[] - */ - public array $terms; - /** * Constructor * * @param SearchQueryTerm[] $terms */ - public function __construct(array $terms = []) + public function __construct(public array $terms = []) { - $this->terms = $terms; } } diff --git a/src/services/Assets.php b/src/services/Assets.php index 70d2f1a38b7..9bf8fce4d82 100644 --- a/src/services/Assets.php +++ b/src/services/Assets.php @@ -123,7 +123,6 @@ public function getAssetById(int $assetId, ?int $siteId = null): ?Asset /** * Gets the total number of assets that match a given criteria. * - * @param mixed $criteria * @return int */ public function getTotalAssets(mixed $criteria = null): int @@ -443,7 +442,6 @@ public function getFolderByUid(string $folderUid): ?VolumeFolder /** * Finds folders that match a given criteria. * - * @param mixed $criteria * @return VolumeFolder[] */ public function findFolders(mixed $criteria = []): array @@ -533,7 +531,6 @@ public function getAllDescendantFolders( /** * Finds the first folder that matches a given criteria. * - * @param mixed $criteria * @return VolumeFolder|null */ public function findFolder(mixed $criteria = []): ?VolumeFolder @@ -590,7 +587,6 @@ public function getRootFolderByVolumeId(int $volumeId): ?VolumeFolder /** * Gets the total number of folders that match a given criteria. * - * @param mixed $criteria * @return int */ public function getTotalFolders(mixed $criteria): int @@ -610,11 +606,10 @@ public function getTotalFolders(mixed $criteria): int /** * Returns whether any folders exist which match a given criteria. * - * @param mixed $criteria * @return bool * @since 4.4.0 */ - public function foldersExist($criteria = null): bool + public function foldersExist(mixed $criteria = null): bool { if (!($criteria instanceof FolderCriteria)) { $criteria = new FolderCriteria($criteria); diff --git a/src/services/Auth.php b/src/services/Auth.php index a84a52e8e87..45c6193fae1 100644 --- a/src/services/Auth.php +++ b/src/services/Auth.php @@ -338,7 +338,7 @@ public function getActiveMethods(?User $user = null): array public function getMethod(string $class, ?User $user = null): AuthMethodInterface { foreach ($this->getAllMethods($user) as $method) { - if (get_class($method) === $class) { + if ($method::class === $class) { return $method; } } diff --git a/src/services/Dashboard.php b/src/services/Dashboard.php index 351295a4d3b..27340fd2ec4 100644 --- a/src/services/Dashboard.php +++ b/src/services/Dashboard.php @@ -221,7 +221,7 @@ public function saveWidget(WidgetInterface $widget, bool $runValidation = true): try { $widgetRecord = $this->_getUserWidgetRecordById($widget->id); - $widgetRecord->type = get_class($widget); + $widgetRecord->type = $widget::class; $widgetRecord->settings = $widget->getSettings(); if ($isNewWidget) { diff --git a/src/services/Deprecator.php b/src/services/Deprecator.php index a0ef1df1ea0..5ae7fbf3991 100644 --- a/src/services/Deprecator.php +++ b/src/services/Deprecator.php @@ -384,7 +384,7 @@ private function _processStackTrace(array $traces): array } $logTraces[] = [ - 'objectClass' => !empty($trace['object']) ? get_class($trace['object']) : null, + 'objectClass' => !empty($trace['object']) ? $trace['object']::class : null, 'file' => $file, 'line' => $line, 'class' => !empty($trace['class']) ? $trace['class'] : null, @@ -442,7 +442,7 @@ private function _argsToString(array $args): string } if (is_object($value)) { - $strValue = get_class($value); + $strValue = $value::class; } elseif (is_bool($value)) { $strValue = $value ? 'true' : 'false'; } elseif (is_string($value)) { diff --git a/src/services/Elements.php b/src/services/Elements.php index abeada17014..d51e9082f17 100644 --- a/src/services/Elements.php +++ b/src/services/Elements.php @@ -697,7 +697,7 @@ public function collectCacheInfoForElement(ElementInterface $element): void return; } - $class = get_class($element); + $class = $element::class; $this->collectCacheTags([ 'element', "element::$class", @@ -1350,7 +1350,7 @@ public function mergeCanonicalChanges(ElementInterface $element): void } if (!$element::trackChanges()) { - throw new InvalidArgumentException(get_class($element) . ' elements don’t track their changes'); + throw new InvalidArgumentException($element::class . ' elements don’t track their changes'); } // Make sure the derivative element actually supports its own site ID @@ -1676,7 +1676,7 @@ public function propagateElements(ElementQueryInterface $query, array|int $siteI $supportedSites = ArrayHelper::index(ElementHelper::supportedSitesForElement($element), 'siteId'); $supportedSiteIds = array_keys($supportedSites); $elementSiteIds = $siteIds !== null ? array_intersect($siteIds, $supportedSiteIds) : $supportedSiteIds; - $elementType = get_class($element); + $elementType = $element::class; $e = null; try { @@ -2033,7 +2033,7 @@ public function updateElementSlugAndUri(ElementInterface $element, bool $updateO if ($queue) { Queue::push(new UpdateElementSlugsAndUris([ 'elementId' => $element->id, - 'elementType' => get_class($element), + 'elementType' => $element::class, 'siteId' => $element->siteId, 'updateOtherSites' => $updateOtherSites, 'updateDescendants' => $updateDescendants, @@ -2111,7 +2111,7 @@ public function updateElementSlugAndUriInOtherSites(ElementInterface $element): */ public function updateDescendantSlugsAndUris(ElementInterface $element, bool $updateOtherSites = true, bool $queue = false): void { - $query = $this->createElementQuery(get_class($element)) + $query = $this->createElementQuery($element::class) ->descendantOf($element) ->descendantDist(1) ->status(null) @@ -2123,7 +2123,7 @@ public function updateDescendantSlugsAndUris(ElementInterface $element, bool $up if (!empty($childIds)) { Queue::push(new UpdateElementSlugsAndUris([ 'elementId' => $childIds, - 'elementType' => get_class($element), + 'elementType' => $element::class, 'siteId' => $element->siteId, 'updateOtherSites' => $updateOtherSites, 'updateDescendants' => true, @@ -2443,10 +2443,10 @@ public function deleteElementsForSite(array $elements): void // Make sure each element has the same type and site ID $firstElement = reset($elements); - $elementType = get_class($firstElement); + $elementType = $firstElement::class; foreach ($elements as $element) { - if (get_class($element) !== $elementType || $element->siteId !== $firstElement->siteId) { + if ($element::class !== $elementType || $element->siteId !== $firstElement->siteId) { throw new InvalidArgumentException('All elements must have the same type and site ID.'); } } @@ -3627,7 +3627,7 @@ private function _saveElementInternal( } } else { $elementRecord = new ElementRecord(); - $elementRecord->type = get_class($element); + $elementRecord->type = $element::class; } // Set the attributes @@ -3950,7 +3950,7 @@ private function updateSearchIndex( Craft::$app->getSearch()->indexElementAttributes($element, $searchableDirtyFields); } else { Queue::push(new UpdateSearchIndex([ - 'elementType' => get_class($element), + 'elementType' => $element::class, 'elementId' => $element->id, 'siteId' => $element->siteId, 'fieldHandles' => $searchableDirtyFields, @@ -4008,7 +4008,7 @@ private function _propagateElement( // Try to fetch the element in this site if ($siteElement === null && $element->id) { - $siteElement = $this->getElementById($element->id, get_class($element), $siteInfo['siteId']); + $siteElement = $this->getElementById($element->id, $element::class, $siteInfo['siteId']); } elseif (!$siteElement) { $siteElement = null; } @@ -4257,7 +4257,7 @@ private function _getRefTokenReplacement(?ElementInterface $element, ?string $at $value = $element->$attribute; if (is_object($value) && !method_exists($value, '__toString')) { - throw new Exception('Object of class ' . get_class($value) . ' could not be converted to string'); + throw new Exception('Object of class ' . $value::class . ' could not be converted to string'); } return $this->parseRefs((string)$value); diff --git a/src/services/Fields.php b/src/services/Fields.php index bfbc4a2c083..42913c19ce2 100644 --- a/src/services/Fields.php +++ b/src/services/Fields.php @@ -303,8 +303,8 @@ public function getCompatibleFieldTypes(FieldInterface $field, bool $includeCurr // Make sure the current field class is in there if it's supposed to be /** @var FieldInterface $field */ - if ($includeCurrent && !in_array(get_class($field), $types, true)) { - $types[] = get_class($field); + if ($includeCurrent && !in_array($field::class, $types, true)) { + $types[] = $field::class; } // Fire a 'defineCompatibleFieldTypes' event @@ -587,7 +587,7 @@ public function createFieldConfig(FieldInterface $field): array 'searchable' => $field->searchable, 'translationMethod' => $field->translationMethod, 'translationKeyFormat' => $field->translationKeyFormat, - 'type' => get_class($field), + 'type' => $field::class, 'settings' => ProjectConfigHelper::packAssociativeArrays($field->getSettings()), ]; } diff --git a/src/services/Fs.php b/src/services/Fs.php index a9e92beccb1..e1645390208 100644 --- a/src/services/Fs.php +++ b/src/services/Fs.php @@ -72,7 +72,7 @@ public function createFilesystemConfig(FsInterface $fs): array { $config = [ 'name' => $fs->name, - 'type' => get_class($fs), + 'type' => $fs::class, 'settings' => ProjectConfigHelper::packAssociativeArrays($fs->getSettings()), ]; diff --git a/src/services/Gql.php b/src/services/Gql.php index e3fc18f38eb..370250ac228 100644 --- a/src/services/Gql.php +++ b/src/services/Gql.php @@ -1337,7 +1337,6 @@ public function prepareFieldDefinitions(array $fields, string $typeName): array * * @param GqlSchema $schema * @param string $query - * @param mixed $rootValue * @param array|null $variables * @param string|null $operationName * @return string|null diff --git a/src/services/ProjectConfig.php b/src/services/ProjectConfig.php index c4ed8a9885a..1d682def1b0 100644 --- a/src/services/ProjectConfig.php +++ b/src/services/ProjectConfig.php @@ -1645,7 +1645,7 @@ public function writeYamlFiles(bool $force = false): void FileHelper::clearDirectory($basePath, [ 'except' => ['.*', '.*/'], ]); - } catch (Throwable $e) { + } catch (Throwable) { // oh well } } @@ -1705,8 +1705,6 @@ public function getHadFileWriteIssues(): bool * is null, it will be removed instead. * * @param string $path - * @param mixed $oldValue - * @param mixed $newValue * @param string|null $message message describing the changes made. * @since 4.0.0 */ diff --git a/src/services/Revisions.php b/src/services/Revisions.php index 2fc64202225..2bf4f6d8152 100644 --- a/src/services/Revisions.php +++ b/src/services/Revisions.php @@ -199,7 +199,7 @@ public function createRevision( // Prune any excess revisions if (Craft::$app->getConfig()->getGeneral()->maxRevisions) { Queue::push(new PruneRevisions([ - 'elementType' => get_class($canonical), + 'elementType' => $canonical::class, 'canonicalId' => $canonical->id, 'siteId' => $canonical->siteId, ]), 2049); diff --git a/src/services/Security.php b/src/services/Security.php index 672b330dc61..b850c3ccbd1 100644 --- a/src/services/Security.php +++ b/src/services/Security.php @@ -182,7 +182,6 @@ public function isSensitive(string $key): bool * Checks the given key to see if it looks like it contains sensitive info, and if so, redacts the given value. * * @param string $key - * @param mixed $value * @return mixed The possibly-redacted value */ public function redactIfSensitive(string $key, mixed $value): mixed diff --git a/src/services/Sso.php b/src/services/Sso.php index 6b92b65ab9c..12d0d2890ca 100644 --- a/src/services/Sso.php +++ b/src/services/Sso.php @@ -145,7 +145,6 @@ private function initProviders(array $configs = []): MemoizableArray /** * Creates an auth provider from a given config. * - * @param mixed $config * @return ProviderInterface * @throws InvalidConfigException */ diff --git a/src/test/Craft.php b/src/test/Craft.php index b287738b424..04649b1a63f 100644 --- a/src/test/Craft.php +++ b/src/test/Craft.php @@ -313,7 +313,6 @@ public static function getCodeceptionName(): string } /** - * @param mixed $path * @return string|false */ public static function normalizePathSeparators(mixed $path): string|false @@ -497,7 +496,7 @@ public function mockMethods(Module $module, string $component, array $params = [ { $componentInstance = $module->get($component); - $module->set($component, Stub::construct(get_class($componentInstance), $constructorParams, $params)); + $module->set($component, Stub::construct($componentInstance::class, $constructorParams, $params)); } /** diff --git a/src/test/CraftConnector.php b/src/test/CraftConnector.php index fa70537836c..64434ecb738 100644 --- a/src/test/CraftConnector.php +++ b/src/test/CraftConnector.php @@ -91,7 +91,7 @@ protected function resetRequest(Application $app): void /** @var Module $module */ foreach (Craft::$app->getModules(true) as $module) { - $moduleClass = get_class($module); + $moduleClass = $module::class; $moduleId = $module->id; if ($module instanceof PluginInterface) { diff --git a/src/test/TestCase.php b/src/test/TestCase.php index 7cb8cea6169..0af3ad62653 100644 --- a/src/test/TestCase.php +++ b/src/test/TestCase.php @@ -41,7 +41,7 @@ public function _fixtures(): array public function assertObjectIsInstanceOfClassCallback(string $class): callable { return function($object) use ($class) { - $this->assertSame($class, get_class($object)); + $this->assertSame($class, $object::class); }; } @@ -50,7 +50,6 @@ public function assertObjectIsInstanceOfClassCallback(string $class): callable * * @param object|string $object * @param string $propertyName - * @param mixed $value * @param bool $revoke whether to make property inaccessible after setting * @throws ReflectionException * @credit https://github.com/yiisoft/yii2/blob/master/tests/TestCase.php#L155 diff --git a/src/test/console/CommandTest.php b/src/test/console/CommandTest.php index 2e9d9691eaf..a499f67a03d 100644 --- a/src/test/console/CommandTest.php +++ b/src/test/console/CommandTest.php @@ -29,26 +29,6 @@ class CommandTest public const SELECT = 'select'; public const OUTPUT_COMMAND = 'outputCommand'; - /** - * @var ConsoleTest - */ - protected ConsoleTest $test; - - /** - * @var string - */ - protected string $command; - - /** - * @var array - */ - protected array $parameters; - - /** - * @var bool - */ - protected bool $ignoreStdout = false; - /** * @var int */ @@ -92,18 +72,14 @@ class CommandTest /** * CommandTest constructor. * - * @param ConsoleTest $consoleTest + * @param ConsoleTest $test * @param string $command * @param array $parameters - * @param bool $ignoreStdOut + * @param bool $ignoreStdout * @throws InvalidConfigException */ - public function __construct(ConsoleTest $consoleTest, string $command, array $parameters = [], bool $ignoreStdOut = false) + public function __construct(protected ConsoleTest $test, protected string $command, protected array $parameters = [], protected bool $ignoreStdout = false) { - $this->command = $command; - $this->parameters = $parameters; - $this->ignoreStdout = $ignoreStdOut; - $this->test = $consoleTest; $this->setupController(); } @@ -171,7 +147,6 @@ public function stderr(iterable|string $desiredOutput): CommandTest /** * @param string $prompt - * @param mixed $returnValue * @param array $options * @return CommandTest */ @@ -187,7 +162,6 @@ public function prompt(string $prompt, mixed $returnValue, array $options = []): /** * @param string $message - * @param mixed $returnValue * @param bool $default * @return CommandTest */ @@ -203,7 +177,6 @@ public function confirm(string $message, mixed $returnValue, bool $default = fal /** * @param string $prompt - * @param mixed $returnValue * @param array $options * @return CommandTest */ @@ -236,7 +209,7 @@ protected function setupController(): void $actionId = $controllerArray[1]; - $stubController = Stub::construct(get_class($controller), [$controller->id, Craft::$app], [ + $stubController = Stub::construct($controller::class, [$controller->id, Craft::$app], [ 'stdOut' => $this->stdoutHandler(), 'stderr' => $this->stderrHandler(), 'prompt' => $this->promptHandler(), diff --git a/src/test/mockclasses/ToString.php b/src/test/mockclasses/ToString.php index a6db48c3c8f..7d874e6e14b 100644 --- a/src/test/mockclasses/ToString.php +++ b/src/test/mockclasses/ToString.php @@ -14,21 +14,15 @@ * @author Global Network Group | Giel Tettelaar * @since 3.2 */ -class ToString +class ToString implements \Stringable { - /** - * @var string - */ - private string $_string; - /** * ToString constructor. * - * @param string $string + * @param string $_string */ - public function __construct(string $string) + public function __construct(private string $_string) { - $this->_string = $string; } /** diff --git a/src/utilities/SystemReport.php b/src/utilities/SystemReport.php index 3589cadd5d1..bd21f840db7 100644 --- a/src/utilities/SystemReport.php +++ b/src/utilities/SystemReport.php @@ -61,7 +61,7 @@ public static function contentHtml(): string continue; } if ($module instanceof Module) { - $modules[$id] = get_class($module); + $modules[$id] = $module::class; } elseif (is_string($module)) { $modules[$id] = $module; } elseif (is_array($module) && isset($module['class'])) { diff --git a/src/validators/UrlValidator.php b/src/validators/UrlValidator.php index 464a8226680..942ee80afd2 100644 --- a/src/validators/UrlValidator.php +++ b/src/validators/UrlValidator.php @@ -53,7 +53,7 @@ public function __construct(array $config = []) */ public function validateValue($value): ?array { - if ($this->allowAlias && strncmp($value, '@', 1) === 0) { + if ($this->allowAlias && str_starts_with($value, '@')) { $value = Craft::getAlias($value); // Prevent validateAttribute() from prepending a default scheme if the alias is missing one diff --git a/src/web/Controller.php b/src/web/Controller.php index 5b90c3f84f5..f735caa5273 100644 --- a/src/web/Controller.php +++ b/src/web/Controller.php @@ -426,7 +426,7 @@ public function asModelSuccess( ): YiiResponse { $data += array_filter([ 'modelName' => $modelName, - 'modelClass' => get_class($model), + 'modelClass' => $model::class, ($modelName ?? 'model') => $model->toArray(), ]); diff --git a/src/web/ErrorHandler.php b/src/web/ErrorHandler.php index 2684f42c618..7b6b6da396b 100644 --- a/src/web/ErrorHandler.php +++ b/src/web/ErrorHandler.php @@ -236,7 +236,7 @@ protected function renderException($exception): void public function exceptionAsArray(Throwable $e) { $array = [ - 'exception' => get_class($e), + 'exception' => $e::class, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/web/Request.php b/src/web/Request.php index 8371304308b..65835a5a233 100644 --- a/src/web/Request.php +++ b/src/web/Request.php @@ -579,7 +579,7 @@ public function hasValidSiteToken(): bool { try { return $this->_validateSiteToken() !== null; - } catch (BadRequestHttpException $e) { + } catch (BadRequestHttpException) { return false; } } @@ -1804,7 +1804,6 @@ private function _utf8AllTheThings(array $things): array } /** - * @param mixed $value * @return mixed */ private function _utf8Value(mixed $value): mixed @@ -1826,7 +1825,6 @@ private function _utf8Value(mixed $value): mixed * The name may include dots, to specify the path to a nested param. * * @param string|null $name - * @param mixed $defaultValue * @param array $params * @return mixed */ diff --git a/src/web/UrlManager.php b/src/web/UrlManager.php index 225c7b7ac1b..546b8fff43f 100644 --- a/src/web/UrlManager.php +++ b/src/web/UrlManager.php @@ -444,7 +444,7 @@ private function _getMatchedUrlRoute(Request $request): array|false if (App::devMode()) { Craft::debug([ - 'rule' => 'URL Rule: ' . (method_exists($rule, '__toString') ? $rule->__toString() : get_class($rule)), + 'rule' => 'URL Rule: ' . (method_exists($rule, '__toString') ? $rule->__toString() : $rule::class), 'match' => $route !== false, 'parent' => null, ], __METHOD__); diff --git a/src/web/UrlRule.php b/src/web/UrlRule.php index 648a91a3659..17abdda69c9 100644 --- a/src/web/UrlRule.php +++ b/src/web/UrlRule.php @@ -36,7 +36,7 @@ public static function regexTokens(): array return [ '{handle}' => sprintf('(?:%s)', HandleValidator::$handlePattern), // Reference: http://www.regular-expressions.info/unicode.html - '{slug}' => sprintf('(?:[\p{L}\p{N}\p{M}%s]+)', preg_quote(implode($slugChars), '/')), + '{slug}' => sprintf('(?:[\p{L}\p{N}\p{M}%s]+)', preg_quote(implode('', $slugChars), '/')), '{uid}' => sprintf('(?:%s)', StringHelper::UUID_PATTERN), ]; } diff --git a/src/web/View.php b/src/web/View.php index 7c0b9d7437a..5e9fb224009 100644 --- a/src/web/View.php +++ b/src/web/View.php @@ -490,7 +490,7 @@ public function registerTwigExtension(ExtensionInterface $extension): void public function registerCpTwigExtension(ExtensionInterface $extension): void { // Make sure this extension isn't already registered - $class = get_class($extension); + $class = $extension::class; if (isset($this->_cpTwigExtensions[$class])) { return; } @@ -515,7 +515,7 @@ public function registerCpTwigExtension(ExtensionInterface $extension): void public function registerSiteTwigExtension(ExtensionInterface $extension): void { // Make sure this extension isn't already registered - $class = get_class($extension); + $class = $extension::class; if (isset($this->_siteTwigExtensions[$class])) { return; } @@ -1680,7 +1680,6 @@ public function getInitialDeltaValues(): array * Sets the initial value of a delta input name. * * @param string $inputName - * @param mixed $value * @see getInitialDeltaValues() * @since 3.4.6 */ diff --git a/src/web/twig/Extension.php b/src/web/twig/Extension.php index 0fc8f01acc3..9bf453c2e24 100644 --- a/src/web/twig/Extension.php +++ b/src/web/twig/Extension.php @@ -129,26 +129,14 @@ private static function checkArrowFunction(mixed $arrow, string $thing, string $ } } - /** - * @var View|null - */ - protected ?View $view = null; - - /** - * @var TwigEnvironment|null - */ - protected ?TwigEnvironment $environment = null; - /** * Constructor * * @param View $view * @param TwigEnvironment $environment */ - public function __construct(View $view, TwigEnvironment $environment) + public function __construct(protected ?View $view, protected ?TwigEnvironment $environment) { - $this->view = $view; - $this->environment = $environment; } /** @@ -536,9 +524,6 @@ public function sortFilter(TwigEnvironment $env, iterable $array, string|callabl * Reduces an array. * * @param TwigEnvironment $env - * @param mixed $array - * @param mixed $arrow - * @param mixed $initial * @return mixed * @throws RuntimeError * @since 4.4.16 @@ -553,8 +538,6 @@ public function reduceFilter(TwigEnvironment $env, mixed $array, mixed $arrow, m * Maps an array. * * @param TwigEnvironment $env - * @param mixed $array - * @param mixed $arrow * @return array * @throws RuntimeError * @since 4.4.16 @@ -569,7 +552,6 @@ public function mapFilter(TwigEnvironment $env, mixed $array, mixed $arrow = nul /** * Formats the value as a currency number. * - * @param mixed $value * @param string|null $currency * @param array $options * @param array $textOptions @@ -593,7 +575,6 @@ public function currencyFilter(mixed $value, ?string $currency = null, array $op /** * Formats the value in bytes as a size in human-readable form, for example `12 kB`. * - * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -616,7 +597,6 @@ public function filesizeFilter(mixed $value, ?int $decimals = null, array $optio /** * Formats the value as a decimal number. * - * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -639,7 +619,6 @@ public function numberFilter(mixed $value, ?int $decimals = null, array $options /** * Formats the value as a percent number with "%" sign. * - * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -662,7 +641,6 @@ public function percentageFilter(mixed $value, ?int $decimals = null, array $opt /** * Formats the value as a human-readable timestamp. * - * @param mixed $value * @param string|null $format * @param bool $withPreposition * @return string @@ -737,8 +715,6 @@ public function widontFilter(string $string): string /** * Returns an array without certain values. * - * @param mixed $arr - * @param mixed $exclude * @param bool $strict * @return array */ @@ -760,7 +736,6 @@ public function withoutFilter(mixed $arr, mixed $exclude, bool $strict = false): /** * Returns an array without a certain key. * - * @param mixed $arr * @param string|string[] $key * @return array * @since 3.2.0 @@ -801,7 +776,6 @@ public function parseAttrFilter(string $tag): array /** * Parses a string for reference tags. * - * @param mixed $str * @param int|null $siteId * @return string */ @@ -923,9 +897,6 @@ public function removeClassFilter(string $tag, array|string $class): string * Replaces Twig's |replace filter, adding support for passing in separate * search and replace arrays. * - * @param mixed $str - * @param mixed $search - * @param mixed $replace * @param bool|null $regex * @return mixed */ @@ -1226,8 +1197,6 @@ public function httpdateFilter(TwigEnvironment $env, mixed $date, mixed $timezon /** * Returns the index of an item in a string or array, or -1 if it cannot be found. * - * @param mixed $haystack - * @param mixed $needle * @param int|null $default * @return int|null */ @@ -1439,7 +1408,6 @@ public function getFunctions(): array /** * Returns a clone of the given variable. * - * @param mixed $var * @return mixed */ public function cloneFunction(mixed $var): mixed @@ -1450,7 +1418,6 @@ public function cloneFunction(mixed $var): mixed /** * Returns a new collection. * - * @param mixed $var * @return Collection * @since 4.0.0 */ @@ -1551,7 +1518,6 @@ public function entryTypeFunction(string $handle): EntryType } /** - * @param mixed $expression * @param array $params * @param array $config * @return Expression @@ -1623,7 +1589,6 @@ public function seqFunction(string $name, ?int $length = null, bool $next = true /** * @param string $template - * @param mixed $object * @return string */ public function renderObjectTemplate(string $template, mixed $object): string diff --git a/src/web/twig/TemplateLoader.php b/src/web/twig/TemplateLoader.php index 36a179be54c..062c9978aa8 100644 --- a/src/web/twig/TemplateLoader.php +++ b/src/web/twig/TemplateLoader.php @@ -20,19 +20,13 @@ */ class TemplateLoader implements LoaderInterface { - /** - * @var View|null - */ - protected ?View $view = null; - /** * Constructor * * @param View $view */ - public function __construct(View $view) + public function __construct(protected ?View $view) { - $this->view = $view; } /** diff --git a/src/web/twig/TemplateLoaderException.php b/src/web/twig/TemplateLoaderException.php index 45f18e3df2a..2179aca933b 100644 --- a/src/web/twig/TemplateLoaderException.php +++ b/src/web/twig/TemplateLoaderException.php @@ -17,18 +17,12 @@ */ class TemplateLoaderException extends LoaderError { - /** - * @var string|null - */ - public ?string $template = null; - /** * @param string $template The requested template * @param string $message The exception message */ - public function __construct(string $template, string $message) + public function __construct(public ?string $template, string $message) { - $this->template = $template; parent::__construct($message); } } diff --git a/src/web/twig/nodevisitors/GetAttrAdjuster.php b/src/web/twig/nodevisitors/GetAttrAdjuster.php index 412f260b2e8..717819e838f 100644 --- a/src/web/twig/nodevisitors/GetAttrAdjuster.php +++ b/src/web/twig/nodevisitors/GetAttrAdjuster.php @@ -27,7 +27,7 @@ class GetAttrAdjuster implements NodeVisitorInterface public function enterNode(Node $node, Environment $env): Node { // Make sure this is a GetAttrExpression (and not a subclass) - if (get_class($node) !== GetAttrExpression::class) { + if ($node::class !== GetAttrExpression::class) { return $node; } diff --git a/src/web/twig/tokenparsers/RegisterResourceTokenParser.php b/src/web/twig/tokenparsers/RegisterResourceTokenParser.php index 1e7e397466b..85b5a90a20f 100644 --- a/src/web/twig/tokenparsers/RegisterResourceTokenParser.php +++ b/src/web/twig/tokenparsers/RegisterResourceTokenParser.php @@ -21,16 +21,6 @@ */ class RegisterResourceTokenParser extends AbstractTokenParser { - /** - * @var string The tag name - */ - public string $tag; - - /** - * @var string The View method the tag represents - */ - public string $method; - /** * @var bool Whether the tag supports a tag pair mode for capturing the JS/CSS */ @@ -62,11 +52,8 @@ class RegisterResourceTokenParser extends AbstractTokenParser * @param string $method the View method the tag represents * @param array $config name-value pairs that will be used to initialize the object properties */ - public function __construct(string $tag, string $method, array $config = []) + public function __construct(public string $tag, public string $method, array $config = []) { - $this->tag = $tag; - $this->method = $method; - if (!empty($config)) { Craft::configure($this, $config); } diff --git a/src/web/twig/variables/Image.php b/src/web/twig/variables/Image.php index 4b2737ad5be..ed0b17bdc06 100644 --- a/src/web/twig/variables/Image.php +++ b/src/web/twig/variables/Image.php @@ -19,16 +19,6 @@ */ class Image { - /** - * @var string|null - */ - protected ?string $path = null; - - /** - * @var string|null - */ - protected ?string $url = null; - /** * @var array|null */ @@ -40,10 +30,8 @@ class Image * @param string $path * @param string $url */ - public function __construct(string $path, string $url = '') + public function __construct(protected ?string $path, protected ?string $url = '') { - $this->path = $path; - $this->url = $url; } /** diff --git a/tests/unit/config/GeneralConfigTest.php b/tests/unit/config/GeneralConfigTest.php index 65762d08232..808800061e3 100644 --- a/tests/unit/config/GeneralConfigTest.php +++ b/tests/unit/config/GeneralConfigTest.php @@ -25,7 +25,6 @@ class GeneralConfigTest extends Unit * * @param string $oldProperty * @param string $newProperty - * @param mixed $value */ public function testRenamedSetting(string $oldProperty, string $newProperty, mixed $value): void { diff --git a/tests/unit/db/QueryParamTest.php b/tests/unit/db/QueryParamTest.php index 9c8b1caa593..4cc767b7931 100644 --- a/tests/unit/db/QueryParamTest.php +++ b/tests/unit/db/QueryParamTest.php @@ -23,7 +23,6 @@ class QueryParamTest extends TestCase * @dataProvider toArrayDataProvider * * @param array $expected - * @param mixed $value */ public function testToArray(array $expected, mixed $value): void { diff --git a/tests/unit/elements/ElementCollectionTest.php b/tests/unit/elements/ElementCollectionTest.php index 58cf76ad9fb..1f4d04c8623 100644 --- a/tests/unit/elements/ElementCollectionTest.php +++ b/tests/unit/elements/ElementCollectionTest.php @@ -187,12 +187,12 @@ public function testBaseMethods(): void { $collection = Entry::find()->collect(); self::assertInstanceOf(ElementCollection::class, $collection); - self::assertSame(Collection::class, get_class($collection->countBy(fn(Entry $entry) => $entry->sectionId))); - self::assertSame(Collection::class, get_class($collection->collapse())); - self::assertSame(Collection::class, get_class($collection->flatten(1))); - self::assertSame(Collection::class, get_class($collection->keys())); - self::assertSame(Collection::class, get_class($collection->pad(100, null))); - self::assertSame(Collection::class, get_class($collection->pluck('title'))); - self::assertSame(Collection::class, get_class($collection->zip($collection->ids()))); + self::assertSame(Collection::class, $collection->countBy(fn(Entry $entry) => $entry->sectionId)::class); + self::assertSame(Collection::class, $collection->collapse()::class); + self::assertSame(Collection::class, $collection->flatten(1)::class); + self::assertSame(Collection::class, $collection->keys()::class); + self::assertSame(Collection::class, $collection->pad(100, null)::class); + self::assertSame(Collection::class, $collection->pluck('title')::class); + self::assertSame(Collection::class, $collection->zip($collection->ids())::class); } } diff --git a/tests/unit/elements/db/ElementQueryTest.php b/tests/unit/elements/db/ElementQueryTest.php index 4eb2c232f5d..698b6bccddd 100644 --- a/tests/unit/elements/db/ElementQueryTest.php +++ b/tests/unit/elements/db/ElementQueryTest.php @@ -22,8 +22,6 @@ class ElementQueryTest extends TestCase /** * @dataProvider relatedToDataProvider * @param array|false $expected - * @param mixed $relatedToParam - * @param mixed $andRelatedToParam */ public function testAndRelatedTo(array|false $expected, mixed $relatedToParam, mixed $andRelatedToParam): void { @@ -41,7 +39,6 @@ public function testAndRelatedTo(array|false $expected, mixed $relatedToParam, m /** * @dataProvider normalizeOrderByDataProvider * @param array $expected - * @param mixed $columns * @return void */ public function testNormalizeOrderBy(array $expected, mixed $columns): void diff --git a/tests/unit/elements/db/ElementRelationParamParserTest.php b/tests/unit/elements/db/ElementRelationParamParserTest.php index 9bb2d3f93bf..1efe150c571 100644 --- a/tests/unit/elements/db/ElementRelationParamParserTest.php +++ b/tests/unit/elements/db/ElementRelationParamParserTest.php @@ -22,7 +22,6 @@ class ElementRelationParamParserTest extends TestCase /** * @dataProvider normalizeRelatedToParamDataProvider * @param array $expected - * @param mixed $param */ public function testNormalizeRelatedToParam(array $expected, mixed $param): void { @@ -48,7 +47,6 @@ public static function normalizeRelatedToParamDataProvider(): array /** * @dataProvider normalizeRelatedToCriteriaDataProvider * @param array|false $expected - * @param mixed $param */ public function testNormalizeRelatedToCriteria(array|false $expected, mixed $param): void { diff --git a/tests/unit/fields/MoneyTest.php b/tests/unit/fields/MoneyTest.php index 63840fcf190..db0b92a0825 100644 --- a/tests/unit/fields/MoneyTest.php +++ b/tests/unit/fields/MoneyTest.php @@ -53,7 +53,6 @@ public function testConstruct(array $config, array $expected): void /** * @dataProvider normalizeValueDataProvider - * @param mixed $money * @param string $value * @param string|null $defaultValue * @param ElementInterface|null $element @@ -69,7 +68,6 @@ public function testNormalizeValue(mixed $money, string $value, ?string $default /** * @dataProvider getTableAttributeHtmlDataProvider - * @param mixed $value * @param string $expected * @param string|null $locale * @return void diff --git a/tests/unit/gql/DirectiveTest.php b/tests/unit/gql/DirectiveTest.php index 0ef4cf7042a..30bf2d16e60 100644 --- a/tests/unit/gql/DirectiveTest.php +++ b/tests/unit/gql/DirectiveTest.php @@ -45,7 +45,6 @@ protected function _after(): void * * @dataProvider directiveDataProvider * @param mixed $in input - * @param mixed $directiveClass * @param array $directives an array of directive data as expected by GQL * @param string $result expected result */ diff --git a/tests/unit/gql/ElementFieldResolverTest.php b/tests/unit/gql/ElementFieldResolverTest.php index 5b37d85b735..b68c689afdb 100644 --- a/tests/unit/gql/ElementFieldResolverTest.php +++ b/tests/unit/gql/ElementFieldResolverTest.php @@ -261,7 +261,6 @@ public function testUserFieldResolving(string $gqlTypeClass, string $propertyNam * Test whether url transform properties are correctly passed on when transforming * * @param array $fieldArguments - * @param mixed $expectedArguments * @dataProvider assetTransformDataProvider */ public function testAssetUrlTransform(array $fieldArguments, mixed $expectedArguments): void @@ -299,7 +298,6 @@ public function testAssetUrlTransform(array $fieldArguments, mixed $expectedArgu /** * Run the test on an element for a type class with the property name. * - * @param mixed $element * @param string $gqlTypeClass The Gql type class * @phpstan-param class-string $gqlTypeClass * @param string $propertyName The property being tested diff --git a/tests/unit/gql/ScalarTypesTest.php b/tests/unit/gql/ScalarTypesTest.php index f46e460b369..0d61a7dc889 100644 --- a/tests/unit/gql/ScalarTypesTest.php +++ b/tests/unit/gql/ScalarTypesTest.php @@ -37,8 +37,6 @@ class ScalarTypesTest extends TestCase * * @dataProvider serializationDataProvider * @param ScalarType $type - * @param mixed $testValue - * @param mixed $match * @throws Error */ public function testSerialization(ScalarType $type, mixed $testValue, mixed $match): void @@ -51,8 +49,6 @@ public function testSerialization(ScalarType $type, mixed $testValue, mixed $mat * * @dataProvider parsingValueDataProvider * @param ScalarType $type - * @param mixed $testValue - * @param mixed $match * @param string|null $exceptionThrown * @throws Error */ @@ -85,7 +81,6 @@ public function testDateTimeParseValueAndLiteral(): void * @dataProvider parsingLiteralDataProvider * @param ScalarType $type * @param ValueNode $testValue - * @param mixed $match * @param string|null $exceptionThrown * @throws Exception */ diff --git a/tests/unit/helpers/AppHelperTest.php b/tests/unit/helpers/AppHelperTest.php index 79253bc5e12..c70cc31353a 100644 --- a/tests/unit/helpers/AppHelperTest.php +++ b/tests/unit/helpers/AppHelperTest.php @@ -60,10 +60,8 @@ public function testEnv(): void /** * @dataProvider envConfigDataProvider * - * @param mixed $expected * @param string $paramName * @param string $overrideName - * @param mixed $overrideValue */ public function testEnvConfig(mixed $expected, string $paramName, string $overrideName, mixed $overrideValue): void { @@ -103,7 +101,6 @@ public function testParseEnv(): void /** * @dataProvider parseBooleanEnvDataProvider * @param bool|null $expected - * @param mixed $value */ public function testParseBooleanEnv(?bool $expected, mixed $value): void { @@ -209,7 +206,6 @@ public function testEditionIdByHandle(int|false $expected, string $handle): void /** * @dataProvider validEditionsDataProvider * @param bool $expected - * @param mixed $edition */ public function testIsValidEdition(bool $expected, mixed $edition): void { diff --git a/tests/unit/helpers/ArrayHelperTest.php b/tests/unit/helpers/ArrayHelperTest.php index d50c26c79cc..dd5caf2b690 100644 --- a/tests/unit/helpers/ArrayHelperTest.php +++ b/tests/unit/helpers/ArrayHelperTest.php @@ -24,7 +24,6 @@ class ArrayHelperTest extends TestCase /** * @dataProvider toArrayDataProvider * @param array $expected - * @param mixed $object */ public function testToArray(array $expected, mixed $object): void { @@ -59,7 +58,6 @@ public function testAppend(array $expected, array $array, array $values): void * @dataProvider prependOrAppendDataProvider * @param array $expected * @param array $array - * @param mixed $appendable * @param bool $prepend */ public function testPrependOrAppend(array $expected, array $array, mixed $appendable, bool $prepend): void @@ -328,7 +326,6 @@ public function testWhereMultiple(): void * @param bool $expected * @param array $array * @param callable|string $key - * @param mixed $value * @param bool $strict */ public function testContains(bool $expected, array $array, callable|string $key, mixed $value = true, bool $strict = false): void @@ -342,7 +339,6 @@ public function testContains(bool $expected, array $array, callable|string $key, * @param bool $expected * @param array $array * @param callable|string $key - * @param mixed $value * @param bool $strict */ public function testOnlyContains(bool $expected, array $array, callable|string $key, mixed $value = true, bool $strict = false): void @@ -371,7 +367,6 @@ public function testFirstKey(): void /** * @dataProvider firstValueDataProvider - * @param mixed $expected * @param array $array */ public function testFirstValue(mixed $expected, array $array): void @@ -385,7 +380,6 @@ public function testFirstValue(mixed $expected, array $array): void * @param array $array * @param string $oldKey * @param string $newKey - * @param mixed $default */ public function testRename(array $expected, array $array, string $oldKey, string $newKey, mixed $default = null): void { @@ -408,7 +402,6 @@ public function testWithout(array $expected, array $array, string $key): void * @dataProvider withoutValueDataProvider * @param array $expected * @param array $array - * @param mixed $value */ public function testWithoutValue(array $expected, array $array, mixed $value): void { @@ -461,7 +454,6 @@ public function testGetValue(string $expected, array $array, string $key): void * @dataProvider removeValueDataProvider * @param array $expected * @param array $array - * @param mixed $value * @param bool $strict */ public function testRemoveValue(array $expected, array $array, mixed $value, bool $strict = false) diff --git a/tests/unit/helpers/AssetsHelperTest.php b/tests/unit/helpers/AssetsHelperTest.php index 2daeaa18c33..c49b5e2b00f 100644 --- a/tests/unit/helpers/AssetsHelperTest.php +++ b/tests/unit/helpers/AssetsHelperTest.php @@ -173,7 +173,6 @@ public function testMaxUploadSize(): void /** * @dataProvider parseSrcsetSizeDataProvider * @param array|false $expected - * @param mixed $size */ public function testParseSrcsetSize(array|false $expected, mixed $size): void { diff --git a/tests/unit/helpers/ConfigHelperTest.php b/tests/unit/helpers/ConfigHelperTest.php index 2ded976c320..8a39c698c9e 100644 --- a/tests/unit/helpers/ConfigHelperTest.php +++ b/tests/unit/helpers/ConfigHelperTest.php @@ -41,7 +41,6 @@ public function testSizeInBytes(int|float $expected, int|string $value): void /** * @dataProvider durationInSecondsDataProvider * @param int $expected - * @param mixed $value * @throws InvalidConfigException */ public function testDurationInSeconds(int $expected, mixed $value): void @@ -81,8 +80,6 @@ public function testDurationSecondsException(): void /** * @dataProvider localizedValueDataProvider - * @param mixed $expected - * @param mixed $value * @param string|null $siteHandle */ public function testLocalizedValue(mixed $expected, mixed $value, ?string $siteHandle = null): void diff --git a/tests/unit/helpers/DateTimeHelperTest.php b/tests/unit/helpers/DateTimeHelperTest.php index a444a40d3c8..78458ede550 100644 --- a/tests/unit/helpers/DateTimeHelperTest.php +++ b/tests/unit/helpers/DateTimeHelperTest.php @@ -268,7 +268,6 @@ public function testCurrentUtcDateTimeStamp(): void * toDateTime must start the DateTime from Asia/Tokyo instead of UTC(The default starting point) and then convert it to the system timezone. * * @dataProvider formatsWithTimezoneDataProvider - * @param mixed $value * @param callable $expectedResult * @throws Exception */ @@ -292,7 +291,6 @@ public function testUtcIgnorance(mixed $value, callable $expectedResult): void /** * @dataProvider toDateTimeDataProvider * @param callable|DateTime|false $expected - * @param mixed $value * @throws Exception */ public function testToDateTime(callable|DateTime|false $expected, mixed $value): void @@ -319,7 +317,6 @@ public function testToDateTime(callable|DateTime|false $expected, mixed $value): * Test that if we set the $setToSystemTimezone value to false that toDateTime creates a tz in UTC. * * @dataProvider simpleDateTimeFormatsDataProvider - * @param mixed $value * @throws Exception */ public function testUtcDefault(mixed $value): void @@ -332,7 +329,6 @@ public function testUtcDefault(mixed $value): void * Test that dateTime is created with the passed in timezone IF $setSystemTimezone is set to false. * * @dataProvider toDateTimeWithTzFormatsDataProvider - * @param mixed $value * @param DateTime $expectedResult * @param DateTimeZone $expectedTimezone * @throws Exception @@ -349,7 +345,6 @@ public function testToDateTimeRespectsTz(mixed $value, DateTime $expectedResult, /** * @dataProvider toDateTimeFormatsDataProvider - * @param mixed $value * @param callable $expectedResult * @param string|null $closureParam * @throws Exception @@ -391,7 +386,6 @@ public function testNormalizeTimeZone(string|false $expected, string $timeZone): /** * @dataProvider isIsIso8601DataProvider * @param bool $expected - * @param mixed $value */ public function testIsIso8601(bool $expected, mixed $value): void { @@ -586,7 +580,6 @@ public function testIntervalToSeconds(int $expected, string $duration): void /** * @dataProvider toIso8601DataProvider * @param string|false $expected - * @param mixed $date */ public function testToIso8601(string|false $expected, mixed $date): void { @@ -596,7 +589,6 @@ public function testToIso8601(string|false $expected, mixed $date): void /** * @dataProvider isValidTimeStampDataProvider * @param bool $expected - * @param mixed $timestamp */ public function testIsValidTimeStamp(bool $expected, mixed $timestamp): void { diff --git a/tests/unit/helpers/DiffHelperTest.php b/tests/unit/helpers/DiffHelperTest.php index 43a8f7f7e5d..9ad2986cf60 100644 --- a/tests/unit/helpers/DiffHelperTest.php +++ b/tests/unit/helpers/DiffHelperTest.php @@ -22,8 +22,6 @@ class DiffHelperTest extends TestCase /** * @dataProvider compareDataProvider * @param bool $expected - * @param mixed $a - * @param mixed $b * @param bool $strict */ public function testCompare(bool $expected, mixed $a, mixed $b, bool $strict): void @@ -34,8 +32,6 @@ public function testCompare(bool $expected, mixed $a, mixed $b, bool $strict): v /** * @dataProvider diffDataProvider * @param string $expected - * @param mixed $from - * @param mixed $to * @param int $indent * @param int $contextLines */ diff --git a/tests/unit/helpers/GqlHelperTest.php b/tests/unit/helpers/GqlHelperTest.php index 917c1ba5c25..e70d04c37c2 100644 --- a/tests/unit/helpers/GqlHelperTest.php +++ b/tests/unit/helpers/GqlHelperTest.php @@ -137,8 +137,6 @@ public function testEntityActionExtraction(array $scope, string $entity, array $ /** * Test GQL types correctly wrapped in NonNull type. * - * @param mixed $input - * @param mixed $expected * @dataProvider wrapInNonNullProvider */ public function testWrapInNonNull(mixed $input, mixed $expected): void diff --git a/tests/unit/helpers/JsonHelperTest.php b/tests/unit/helpers/JsonHelperTest.php index 6d0f05e4523..c02ca908099 100644 --- a/tests/unit/helpers/JsonHelperTest.php +++ b/tests/unit/helpers/JsonHelperTest.php @@ -22,7 +22,6 @@ class JsonHelperTest extends TestCase { /** * @dataProvider decodeIfJsonDataProvider - * @param mixed $expected * @param string $str */ public function testDecodeIfJson(mixed $expected, string $str): void diff --git a/tests/unit/helpers/LocalizationHelperTest.php b/tests/unit/helpers/LocalizationHelperTest.php index a4cde6af0ff..4506354f56a 100644 --- a/tests/unit/helpers/LocalizationHelperTest.php +++ b/tests/unit/helpers/LocalizationHelperTest.php @@ -51,8 +51,6 @@ public function testLanguageNormalizationExceptions(): void /** * @dataProvider normalizeNumberDataProvider - * @param mixed $expected - * @param mixed $number * @param string|null $localeId */ public function testNormalizeNumber(mixed $expected, mixed $number, ?string $localeId): void diff --git a/tests/unit/helpers/MoneyHelperTest.php b/tests/unit/helpers/MoneyHelperTest.php index f661b4bd4a7..262205f3d4d 100644 --- a/tests/unit/helpers/MoneyHelperTest.php +++ b/tests/unit/helpers/MoneyHelperTest.php @@ -24,7 +24,6 @@ class MoneyHelperTest extends TestCase { /** * @dataProvider toMoneyDataProvider - * @param mixed $value * @param Money|false $expected */ public function testToMoney(mixed $value, Money|false $expected): void @@ -34,8 +33,6 @@ public function testToMoney(mixed $value, Money|false $expected): void /** * @dataProvider toDecimalDataProvider - * @param mixed $value - * @param mixed $expected * @return void */ public function testToDecimal(mixed $value, mixed $expected): void @@ -45,8 +42,6 @@ public function testToDecimal(mixed $value, mixed $expected): void /** * @dataProvider toNumberDataProvider - * @param mixed $value - * @param mixed $expected * @param string|null $locale * @return void */ @@ -66,8 +61,6 @@ public function testToNumber(mixed $value, mixed $expected, ?string $locale = nu /** * @dataProvider toStringDataProvider - * @param mixed $value - * @param mixed $expected * @param string|null $locale * @return void */ diff --git a/tests/unit/helpers/NumberHelperTest.php b/tests/unit/helpers/NumberHelperTest.php index bc223bc42b2..37a749709f5 100644 --- a/tests/unit/helpers/NumberHelperTest.php +++ b/tests/unit/helpers/NumberHelperTest.php @@ -72,8 +72,6 @@ public function testLowerRoman(string $expected, int $num): void /** * @dataProvider makeNumericDataProvider - * @param mixed $expected - * @param mixed $var */ public function testMakeNumeric(mixed $expected, mixed $var): void { @@ -83,7 +81,6 @@ public function testMakeNumeric(mixed $expected, mixed $var): void /** * @dataProvider isIntOrFloatDataProvider * @param bool $expected - * @param mixed $value */ public function testIsIntOrFloat(bool $expected, mixed $value): void { diff --git a/tests/unit/helpers/ProjectConfigHelperTest.php b/tests/unit/helpers/ProjectConfigHelperTest.php index 84fbb37ddd8..797fbcf01d7 100644 --- a/tests/unit/helpers/ProjectConfigHelperTest.php +++ b/tests/unit/helpers/ProjectConfigHelperTest.php @@ -81,7 +81,6 @@ public function testTouch(string $input, string $expected): void } /** - * @param mixed $incomingData * @param string $expectedResult * @dataProvider encodeTestDataProvider */ diff --git a/tests/unit/helpers/StringHelperTest.php b/tests/unit/helpers/StringHelperTest.php index 8002688f329..0a0215fa67b 100644 --- a/tests/unit/helpers/StringHelperTest.php +++ b/tests/unit/helpers/StringHelperTest.php @@ -1401,7 +1401,6 @@ public function testToSpaces(string $expected, string $string, int $tabLength = /** * @dataProvider toStringDataProvider * @param string $expected - * @param mixed $object * @param string $glue */ public function testToString(string $expected, mixed $object, string $glue = ','): void diff --git a/tests/unit/helpers/TypecastHelperTest.php b/tests/unit/helpers/TypecastHelperTest.php index 35aa81fd0f0..3f90411a8c6 100644 --- a/tests/unit/helpers/TypecastHelperTest.php +++ b/tests/unit/helpers/TypecastHelperTest.php @@ -28,8 +28,6 @@ class TypecastHelperTest extends TestCase * * @param string $class * @param string $property - * @param mixed $expected - * @param mixed $value */ public function testScalarProperties(string $class, string $property, mixed $expected, mixed $value): void { diff --git a/tests/unit/helpers/dbhelper/DbHelperTest.php b/tests/unit/helpers/dbhelper/DbHelperTest.php index c770663c0a7..ff3af2f0244 100644 --- a/tests/unit/helpers/dbhelper/DbHelperTest.php +++ b/tests/unit/helpers/dbhelper/DbHelperTest.php @@ -75,7 +75,6 @@ class DbHelperTest extends TestCase * @dataProvider parseParamDataProvider * @param array|null $expected * @param string $column - * @param mixed $value * @param string $defaultOperator * @param bool $caseInsensitive * @param string|null $columnType @@ -219,8 +218,6 @@ public function testDeleteIfExistsException(): void /** * @dataProvider prepareValueForDbDataProvider - * @param mixed $expected - * @param mixed $value */ public function testPrepareValueForDb(mixed $expected, mixed $value): void { @@ -323,7 +320,6 @@ public function testGetMinAllowedValueForNumericColumn(int|false $expected, stri /** * @dataProvider prepareValuesForDbDataProvider * @param array $expected - * @param mixed $values */ public function testPrepareValuesForDb(array $expected, mixed $values): void { diff --git a/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php b/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php index eca7cb532f7..a7cd5d84e24 100644 --- a/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php +++ b/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php @@ -60,7 +60,6 @@ public static function getTextualColumnStorageCapacityDataProvider(): array /** * @dataProvider parseParamDataProvider - * @param mixed $expected * @param string $column * @param string|int|array $value * @param string $defaultOperator diff --git a/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php b/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php index 0721cc38ae7..fa02067b9ce 100644 --- a/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php +++ b/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php @@ -51,7 +51,6 @@ public function testGetTextualColumnStorageCapacity(int|null|false $expected, st * @dataProvider parseParamDataProvider * @param string|array $expected * @param string $column - * @param mixed $value * @param string $defaultOperator * @param bool $caseInsensitive */ diff --git a/tests/unit/i18n/FormatterTest.php b/tests/unit/i18n/FormatterTest.php index 0fa62e11ac9..fe9e5b92181 100644 --- a/tests/unit/i18n/FormatterTest.php +++ b/tests/unit/i18n/FormatterTest.php @@ -21,7 +21,6 @@ class FormatterTest extends TestCase { /** * @param string $expected - * @param mixed $value * @param int|null $decimals * @dataProvider asPercentDataProvider */ diff --git a/tests/unit/services/ProjectConfigTest.php b/tests/unit/services/ProjectConfigTest.php index d35f95b1e4a..2fbd0dcd89e 100644 --- a/tests/unit/services/ProjectConfigTest.php +++ b/tests/unit/services/ProjectConfigTest.php @@ -120,7 +120,6 @@ public function testRebuildIgnoresReadOnly(): void /** * @param string|null $path * @param bool $useExternal - * @param mixed $expectedValue * @throws Exception * @dataProvider getValueDataProvider */ @@ -132,7 +131,6 @@ public function testGettingValue(?string $path, bool $useExternal, mixed $expect /** * @param string $path - * @param mixed $value * @dataProvider setValueDataProvider */ public function testSettingValue(string $path, mixed $value): void diff --git a/tests/unit/services/SearchTest.php b/tests/unit/services/SearchTest.php index e4be5fc9348..fd0557e8bfc 100644 --- a/tests/unit/services/SearchTest.php +++ b/tests/unit/services/SearchTest.php @@ -133,7 +133,6 @@ protected function _before(): void } /** - * @param mixed $attributeName * @param iterable $searchIndex * @return string */ diff --git a/tests/unit/services/SecurityTest.php b/tests/unit/services/SecurityTest.php index e8f3ab03ce4..c6c73a9014d 100644 --- a/tests/unit/services/SecurityTest.php +++ b/tests/unit/services/SecurityTest.php @@ -21,9 +21,7 @@ class SecurityTest extends TestCase { /** * @dataProvider redactIfSensitiveDataProvider - * @param mixed $expected * @param string $name - * @param mixed $value * @param string[] $sensitiveKeywords */ public function testRedactIfSensitive(mixed $expected, string $name, mixed $value, array $sensitiveKeywords): void diff --git a/tests/unit/validators/ArrayValidatorTest.php b/tests/unit/validators/ArrayValidatorTest.php index 36315b0e755..2d81b01cf3d 100644 --- a/tests/unit/validators/ArrayValidatorTest.php +++ b/tests/unit/validators/ArrayValidatorTest.php @@ -63,7 +63,6 @@ public function testCountArrayInputValue(): void /** * @dataProvider arrayValidatorValuesDataProvider - * @param mixed $inputValue * @param bool $mustValidate */ public function testValidation(mixed $inputValue, bool $mustValidate): void diff --git a/tests/unit/validators/PasswordValidatorTest.php b/tests/unit/validators/PasswordValidatorTest.php index 4ed06cac36e..16618bb2941 100644 --- a/tests/unit/validators/PasswordValidatorTest.php +++ b/tests/unit/validators/PasswordValidatorTest.php @@ -63,7 +63,6 @@ public function testValidation(string $inputValue, bool $mustValidate, string $c /** * @dataProvider customConfigDataProvider - * @param mixed $input * @param bool $mustValidate * @param int $min * @param int $max diff --git a/tests/unit/validators/UriValidatorTest.php b/tests/unit/validators/UriValidatorTest.php index 32f616f0eb7..56ea454d40d 100644 --- a/tests/unit/validators/UriValidatorTest.php +++ b/tests/unit/validators/UriValidatorTest.php @@ -33,7 +33,6 @@ class UriValidatorTest extends TestCase /** * @dataProvider validateValueDataProvider * @param bool $mustValidate - * @param mixed $input * @param string|null $pattern */ public function testValidateValue(bool $mustValidate, mixed $input, string $pattern = null): void diff --git a/tests/unit/web/RequestTest.php b/tests/unit/web/RequestTest.php index 9cf490c1f76..7de5e4b9d34 100644 --- a/tests/unit/web/RequestTest.php +++ b/tests/unit/web/RequestTest.php @@ -363,8 +363,6 @@ public function testCsrfTokenValidFailure(): void /** * @dataProvider getParamDataProvider - * @param mixed $expected - * @param mixed $defaultValue * @param array $params * @param string|null $name * @throws ReflectionException @@ -528,7 +526,6 @@ protected function _before(): void /** * @param string|null $name - * @param mixed $defaultValue * @param array $params * @return mixed * @throws ReflectionException diff --git a/tests/unit/web/ResponseTest.php b/tests/unit/web/ResponseTest.php index 10e3d7e71e7..a69d1887d0b 100644 --- a/tests/unit/web/ResponseTest.php +++ b/tests/unit/web/ResponseTest.php @@ -76,7 +76,6 @@ public function testSetLastModifiedHeader(): void /** * @param string $expected - * @param mixed $url * @dataProvider testRedirectDataProvider */ public function testRedirect(string $expected, mixed $url): void diff --git a/tests/unit/web/ViewTest.php b/tests/unit/web/ViewTest.php index f25bb586c8c..1cbfe1eee90 100644 --- a/tests/unit/web/ViewTest.php +++ b/tests/unit/web/ViewTest.php @@ -174,7 +174,6 @@ public function testRenderString(): void * @dataProvider renderObjectTemplateDataProvider * @param string $expected * @param string $template - * @param mixed $object * @param array $variables * @throws Exception * @throws Throwable @@ -624,7 +623,6 @@ protected function _before(): void } /** - * @param mixed $category * @param array $messages * @return string */ @@ -642,8 +640,6 @@ private function _generateTranslationJs(mixed $category, array $messages): strin } /** - * @param mixed $desiredJs - * @param mixed $desiredPosition * @throws \Exception */ private function _assertRegisterJsInputValues(mixed $desiredJs, mixed $desiredPosition) From 637f74033807fe0b40be368c053d216de001ffa7 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 20 Feb 2025 18:09:21 +0700 Subject: [PATCH 2/9] skip mixed type change --- .../src/SoftDeleteQueryBehavior.php | 2 +- rector.php | 3 ++ src/Craft.php | 1 + src/auth/sso/BaseExternalProvider.php | 1 + src/auth/sso/mapper/SetUserValueTrait.php | 1 + src/auth/sso/mapper/UserMapInterface.php | 1 + src/base/Element.php | 2 ++ src/base/ElementInterface.php | 2 ++ src/base/MemoizableArray.php | 1 + src/base/PreviewableFieldInterface.php | 1 + .../conditions/BaseDateRangeConditionRule.php | 6 ++++ src/base/conditions/BaseTextConditionRule.php | 1 + src/config/GeneralConfig.php | 28 +++++++++++++++++++ src/console/controllers/SetupController.php | 1 + .../controllers/utils/RepairController.php | 1 + src/controllers/ElementsController.php | 1 + src/db/Query.php | 5 ++++ src/db/QueryParam.php | 1 + src/debug/MailPanel.php | 1 + src/elements/db/ElementQuery.php | 1 + .../db/ElementRelationParamParser.php | 4 +++ src/elements/db/NestedElementQueryTrait.php | 1 + src/fieldlayoutelements/BaseField.php | 1 + src/fields/BaseOptionsField.php | 1 + src/fields/Lightswitch.php | 1 + src/fields/Money.php | 1 + src/fields/Number.php | 1 + src/fields/Range.php | 1 + src/fields/Table.php | 1 + src/fields/data/MultiOptionsFieldData.php | 1 + src/fields/data/OptionData.php | 5 ++-- src/gql/ElementQueryConditionBuilder.php | 1 + src/gql/GqlEntityRegistry.php | 1 + src/gql/base/ArgumentHandler.php | 1 + src/gql/base/ElementResolver.php | 4 +++ src/gql/base/Generator.php | 1 + src/gql/base/MutationResolver.php | 2 ++ src/gql/resolvers/mutations/Asset.php | 4 +++ src/gql/resolvers/mutations/Category.php | 4 +++ src/gql/resolvers/mutations/Entry.php | 8 ++++++ src/gql/resolvers/mutations/GlobalSet.php | 2 ++ src/gql/resolvers/mutations/Tag.php | 4 +++ src/gql/types/input/Addresses.php | 1 + src/gql/types/input/Matrix.php | 1 + src/helpers/App.php | 2 ++ src/helpers/ArrayHelper.php | 5 ++-- src/helpers/Assets.php | 1 + src/helpers/ConfigHelper.php | 1 + src/helpers/DateTimeHelper.php | 1 + src/helpers/Db.php | 2 +- src/helpers/Diff.php | 6 ++++ src/helpers/Gql.php | 5 ++++ src/helpers/Html.php | 2 ++ src/helpers/ImageTransforms.php | 1 + src/helpers/MailerHelper.php | 1 + src/helpers/MoneyHelper.php | 4 +++ src/helpers/Number.php | 2 ++ src/helpers/ProjectConfig.php | 2 ++ src/helpers/Session.php | 2 +- src/models/ProjectConfigData.php | 3 ++ src/queue/BaseBatchedJob.php | 2 ++ src/services/Assets.php | 7 ++++- src/services/Gql.php | 1 + src/services/ProjectConfig.php | 2 ++ src/services/Security.php | 1 + src/services/Sso.php | 1 + src/test/Craft.php | 1 + src/test/TestCase.php | 1 + src/test/console/CommandTest.php | 3 ++ src/web/Request.php | 2 ++ src/web/View.php | 1 + src/web/twig/Extension.php | 23 +++++++++++++++ tests/unit/config/GeneralConfigTest.php | 1 + tests/unit/db/QueryParamTest.php | 1 + tests/unit/elements/db/ElementQueryTest.php | 3 ++ .../db/ElementRelationParamParserTest.php | 2 ++ tests/unit/fields/MoneyTest.php | 2 ++ tests/unit/gql/DirectiveTest.php | 1 + tests/unit/gql/ElementFieldResolverTest.php | 2 ++ tests/unit/gql/ScalarTypesTest.php | 5 ++++ tests/unit/helpers/AppHelperTest.php | 4 +++ tests/unit/helpers/ArrayHelperTest.php | 8 ++++++ tests/unit/helpers/AssetsHelperTest.php | 1 + tests/unit/helpers/ConfigHelperTest.php | 3 ++ tests/unit/helpers/DateTimeHelperTest.php | 8 ++++++ tests/unit/helpers/DiffHelperTest.php | 4 +++ tests/unit/helpers/GqlHelperTest.php | 2 ++ tests/unit/helpers/JsonHelperTest.php | 1 + tests/unit/helpers/LocalizationHelperTest.php | 2 ++ tests/unit/helpers/MoneyHelperTest.php | 7 +++++ tests/unit/helpers/NumberHelperTest.php | 3 ++ .../unit/helpers/ProjectConfigHelperTest.php | 1 + tests/unit/helpers/StringHelperTest.php | 1 + tests/unit/helpers/TypecastHelperTest.php | 2 ++ tests/unit/helpers/dbhelper/DbHelperTest.php | 4 +++ .../helpers/dbhelper/MysqlDbHelperTest.php | 1 + .../helpers/dbhelper/PgsqlDbHelperTest.php | 1 + tests/unit/i18n/FormatterTest.php | 1 + tests/unit/services/ProjectConfigTest.php | 2 ++ tests/unit/services/SearchTest.php | 1 + tests/unit/services/SecurityTest.php | 2 ++ tests/unit/validators/ArrayValidatorTest.php | 1 + .../unit/validators/PasswordValidatorTest.php | 1 + tests/unit/validators/UriValidatorTest.php | 1 + tests/unit/web/RequestTest.php | 3 ++ tests/unit/web/ResponseTest.php | 1 + tests/unit/web/ViewTest.php | 4 +++ 107 files changed, 277 insertions(+), 8 deletions(-) diff --git a/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php b/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php index 0c51f2e2ce5..9c570acd88d 100644 --- a/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php +++ b/lib/ar-softdelete/src/SoftDeleteQueryBehavior.php @@ -183,7 +183,7 @@ public function notDeleted() * @param mixed $deleted filter value. * @return \yii\db\ActiveQueryInterface|static */ - public function filterDeleted(mixed $deleted) + public function filterDeleted($deleted) { if ($deleted === '' || $deleted === null || $deleted === []) { return $this->notDeleted(); diff --git a/rector.php b/rector.php index eac11cc86d2..a9a2f3f3f8c 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; +use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; return RectorConfig::configure() @@ -37,5 +38,7 @@ ChangeSwitchToMatchRector::class => [ __DIR__ . '/src/elements/Entry.php', ], + + MixedTypeRector::class, ]) ->withPhpSets(php80: true); diff --git a/src/Craft.php b/src/Craft.php index 9025dd58b9b..02dd30114df 100644 --- a/src/Craft.php +++ b/src/Craft.php @@ -106,6 +106,7 @@ public static function parseEnv(?string $str = null): string|null|false * $status = Craft::parseBooleanEnv('$SYSTEM_STATUS') ?? false; * ``` * + * @param mixed $value * @return bool|null * @since 3.7.22 * @deprecated in 3.7.29. [[App::parseBooleanEnv()]] should be used instead. diff --git a/src/auth/sso/BaseExternalProvider.php b/src/auth/sso/BaseExternalProvider.php index 152e7c47af8..1c0d12d29b9 100644 --- a/src/auth/sso/BaseExternalProvider.php +++ b/src/auth/sso/BaseExternalProvider.php @@ -334,6 +334,7 @@ protected function populateUser(User $user, array $data): User /** * Normalize a callback * + * @param mixed $callback * @param string|null $defaultClass * @return callable|null * @throws \yii\base\InvalidConfigException diff --git a/src/auth/sso/mapper/SetUserValueTrait.php b/src/auth/sso/mapper/SetUserValueTrait.php index 7a56fa87691..4cd254ca5fb 100644 --- a/src/auth/sso/mapper/SetUserValueTrait.php +++ b/src/auth/sso/mapper/SetUserValueTrait.php @@ -28,6 +28,7 @@ trait SetUserValueTrait * Set a value on a user; determine if we're setting a field value or property * * @param User $user + * @param mixed $value * @return void */ protected function setValue(User $user, mixed $value): void diff --git a/src/auth/sso/mapper/UserMapInterface.php b/src/auth/sso/mapper/UserMapInterface.php index 81bcfe00eb7..8515391a842 100644 --- a/src/auth/sso/mapper/UserMapInterface.php +++ b/src/auth/sso/mapper/UserMapInterface.php @@ -18,6 +18,7 @@ interface UserMapInterface { /** * @param User $user + * @param mixed $data * @return User */ public function __invoke(User $user, mixed $data): User; diff --git a/src/base/Element.php b/src/base/Element.php index 3c430d1b645..438709603df 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -2940,6 +2940,7 @@ public function afterValidate(): void * Normalizes a field’s validation rule. * * @param string $attribute + * @param mixed $rule * @param FieldInterface $field * @param callable $isEmpty * @return Validator @@ -6627,6 +6628,7 @@ public function getLanguage(): string /** * Returns an element right before/after this one, from a given set of criteria. * + * @param mixed $criteria * @param int $dir * @return ElementInterface|null */ diff --git a/src/base/ElementInterface.php b/src/base/ElementInterface.php index 0f6f1558b5b..df88ab2fed1 100644 --- a/src/base/ElementInterface.php +++ b/src/base/ElementInterface.php @@ -1073,6 +1073,7 @@ public function getLocalized(): ElementQueryInterface|ElementCollection; /** * Returns the next element relative to this one, from a given set of criteria. * + * @param mixed $criteria * @return self|null */ public function getNext(mixed $criteria = false): ?self; @@ -1080,6 +1081,7 @@ public function getNext(mixed $criteria = false): ?self; /** * Returns the previous element relative to this one, from a given set of criteria. * + * @param mixed $criteria * @return self|null */ public function getPrev(mixed $criteria = false): ?self; diff --git a/src/base/MemoizableArray.php b/src/base/MemoizableArray.php index 0a12d5867e5..9ae8d453bc1 100644 --- a/src/base/MemoizableArray.php +++ b/src/base/MemoizableArray.php @@ -173,6 +173,7 @@ public function firstWhere(string $key, mixed $value = true, bool $strict = fals * * @param string $method * @param string $key + * @param mixed $value * @param bool $strict * @return string */ diff --git a/src/base/PreviewableFieldInterface.php b/src/base/PreviewableFieldInterface.php index 42082f811ad..8c693caa076 100644 --- a/src/base/PreviewableFieldInterface.php +++ b/src/base/PreviewableFieldInterface.php @@ -31,6 +31,7 @@ public function getPreviewHtml(mixed $value, ElementInterface $element): string; * Return the HTML that should be shown for the field in the card preview. * It can be used outside an element context, e.g. in a card view designer. * + * @param mixed $value * @param ElementInterface|null $element * @return string * @since 5.5.0 diff --git a/src/base/conditions/BaseDateRangeConditionRule.php b/src/base/conditions/BaseDateRangeConditionRule.php index 393aaaa5cb0..9e243be2995 100644 --- a/src/base/conditions/BaseDateRangeConditionRule.php +++ b/src/base/conditions/BaseDateRangeConditionRule.php @@ -86,6 +86,9 @@ public function getStartDate(): ?string return $this->_startDate; } + /** + * @param mixed $value + */ public function setStartDate(mixed $value): void { $this->_startDate = ($value ? DateTimeHelper::toIso8601($value) : null); @@ -99,6 +102,9 @@ public function getEndDate(): ?string return $this->_endDate; } + /** + * @param mixed $value + */ public function setEndDate(mixed $value): void { $this->_endDate = ($value ? DateTimeHelper::toIso8601($value) : null); diff --git a/src/base/conditions/BaseTextConditionRule.php b/src/base/conditions/BaseTextConditionRule.php index f1f195dad4f..66e95c677b3 100644 --- a/src/base/conditions/BaseTextConditionRule.php +++ b/src/base/conditions/BaseTextConditionRule.php @@ -141,6 +141,7 @@ protected function paramValue(): ?string /** * Returns whether the condition rule matches the given value. * + * @param mixed $value * @return bool */ protected function matchValue(mixed $value): bool diff --git a/src/config/GeneralConfig.php b/src/config/GeneralConfig.php index 1f91609503a..ffc94e4c6f9 100644 --- a/src/config/GeneralConfig.php +++ b/src/config/GeneralConfig.php @@ -3481,6 +3481,7 @@ public function actionTrigger(string $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $activateAccountSuccessPath * @see getActivateAccountSuccessPath() @@ -3896,6 +3897,7 @@ public function buildId(?string $value): self * * @group System * @defaultAlt 1 day + * @param mixed $value * @return self * @see $cacheDuration * @since 4.2.0 @@ -3943,6 +3945,7 @@ public function convertFilenamesToAscii(bool $value = true): self * * @group Security * @defaultAlt 5 minutes + * @param mixed $value * @return self * @see $cooldownDuration * @since 4.2.0 @@ -4148,6 +4151,7 @@ public function defaultCpLocale(?string $value): self * ``` * * @group System + * @param mixed $value * @return self * @see $defaultDirMode * @since 4.2.0 @@ -4259,6 +4263,7 @@ public function defaultTemplateExtensions(array $value): self * * @group Security * @defaultAlt 1 day + * @param mixed $value * @return self * @see $defaultTokenDuration * @since 4.2.0 @@ -4588,6 +4593,7 @@ public function enableGql(bool $value = true): self * * @group Security * @defaultAlt 5 minutes + * @param mixed $value * @return self * @see $elevatedSessionDuration * @since 4.2.0 @@ -4994,6 +5000,7 @@ public function httpProxy(?string $value): self * ``` * * @group Image Handling + * @param mixed $value * @return self * @see $imageDriver * @since 4.2.0 @@ -5062,6 +5069,7 @@ public function indexTemplateFilenames(array $value): self * * @group Security * @defaultAlt 1 hour + * @param mixed $value * @return self * @see $invalidLoginWindowDuration * @since 4.2.0 @@ -5084,6 +5092,7 @@ public function invalidLoginWindowDuration(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $invalidUserTokenPath * @since 4.2.0 @@ -5211,6 +5220,7 @@ public function localeAliases(array $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $loginPath * @since 4.2.0 @@ -5233,6 +5243,7 @@ public function loginPath(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $logoutPath * @since 4.2.0 @@ -5659,6 +5670,7 @@ public function phpSessionName(string $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $postCpLoginRedirect * @since 4.2.0 @@ -5682,6 +5694,7 @@ public function postCpLoginRedirect(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $postLoginRedirect * @since 4.2.0 @@ -5702,6 +5715,7 @@ public function postLoginRedirect(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $postLogoutRedirect * @since 4.2.0 @@ -5887,6 +5901,7 @@ public function previewIframeResizerOptions(array $value): self * * @group Security * @defaultAlt 1 day + * @param mixed $value * @return self * @see $previewTokenDuration * @since 4.2.0 @@ -5938,6 +5953,7 @@ public function privateTemplateTrigger(string $value): self * ``` * * @group Garbage Collection + * @param mixed $value * @return self * @see $purgePendingUsersDuration * @since 4.2.0 @@ -5962,6 +5978,7 @@ public function purgePendingUsersDuration(mixed $value): self * * @group Garbage Collection * @defaultAlt 90 days + * @param mixed $value * @return self * @see $purgeStaleUserSessionDuration * @since 4.2.0 @@ -5985,6 +6002,7 @@ public function purgeStaleUserSessionDuration(mixed $value): self * * @group Garbage Collection * @defaultAlt 30 days + * @param mixed $value * @return self * @see $purgeUnsavedDraftsDuration * @since 4.2.0 @@ -6029,6 +6047,7 @@ public function rasterizeSvgThumbs(bool $value = true): self * * @group Session * @defaultAlt 1 year + * @param mixed $value * @return self * @see $rememberUsernameDuration * @since 4.2.0 @@ -6052,6 +6071,7 @@ public function rememberUsernameDuration(mixed $value): self * * @group Session * @defaultAlt 14 days + * @param mixed $value * @return self * @throws InvalidConfigException * @see $rememberedUserSessionDuration @@ -6418,6 +6438,7 @@ public function sendPoweredByHeader(bool $value = true): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $setPasswordPath * @since 4.2.0 @@ -6445,6 +6466,7 @@ public function setPasswordPath(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $setPasswordRequestPath * @since 4.2.0 @@ -6465,6 +6487,7 @@ public function setPasswordRequestPath(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $setPasswordSuccessPath * @since 4.2.0 @@ -6608,6 +6631,7 @@ public function showFirstAndLastNameFields(bool $value = true): self * * @group Garbage Collection * @defaultAlt 30 days + * @param mixed $value * @return self * @see $softDeleteDuration * @since 4.2.0 @@ -6984,6 +7008,7 @@ public function useSslOnTokenizedUrls(string|bool $value): self * * @group Session * @defaultAlt 1 hour + * @param mixed $value * @return self * @see $userSessionDuration * @since 4.2.0 @@ -7030,6 +7055,7 @@ public function useFileLocks(?bool $value): self * * @group Security * @defaultAlt 1 day + * @param mixed $value * @return self * @see $verificationCodeDuration * @since 4.2.0 @@ -7050,6 +7076,7 @@ public function verificationCodeDuration(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $verifyEmailPath * @see getVerifyEmailPath() @@ -7071,6 +7098,7 @@ public function verifyEmailPath(mixed $value): self * ``` * * @group Routing + * @param mixed $value * @return self * @see $verifyEmailSuccessPath * @see getVerifyEmailSuccessPath() diff --git a/src/console/controllers/SetupController.php b/src/console/controllers/SetupController.php index ccf3eaa7331..97238318a4e 100644 --- a/src/console/controllers/SetupController.php +++ b/src/console/controllers/SetupController.php @@ -651,6 +651,7 @@ private function _outputCommand(string $command): void * Sets an environment variable value in the project’s `.env` file. * * @param string $name + * @param mixed $value * @return bool */ private function _setEnvVar(string $name, mixed $value): bool diff --git a/src/console/controllers/utils/RepairController.php b/src/console/controllers/utils/RepairController.php index 3e68e5f4367..58548f5c924 100644 --- a/src/console/controllers/utils/RepairController.php +++ b/src/console/controllers/utils/RepairController.php @@ -303,6 +303,7 @@ public function actionProjectConfig(): int * * @param ProjectConfig $projectConfigService * @param string $path + * @param mixed $value * @return mixed */ private function _repairProjectConfigItem(ProjectConfig $projectConfigService, string $path, mixed $value): mixed diff --git a/src/controllers/ElementsController.php b/src/controllers/ElementsController.php index 611f98e705e..95edc091f98 100644 --- a/src/controllers/ElementsController.php +++ b/src/controllers/ElementsController.php @@ -150,6 +150,7 @@ public function beforeAction($action): bool /** * @param string $name + * @param mixed $default * @return mixed */ private function _param(string $name, mixed $default = null): mixed diff --git a/src/db/Query.php b/src/db/Query.php index 695620eba60..d4062318392 100644 --- a/src/db/Query.php +++ b/src/db/Query.php @@ -71,6 +71,7 @@ public function getIterator(): ArrayIterator /** * Required by the ArrayAccess interface. * + * @param mixed $offset * @return bool * @since 4.2.0 */ @@ -93,6 +94,7 @@ public function offsetExists(mixed $offset): bool /** * Required by the ArrayAccess interface. * + * @param mixed $offset * @return mixed * @throws UnknownPropertyException * @since 4.2.0 @@ -112,6 +114,8 @@ public function offsetGet(mixed $offset): mixed /** * Required by the ArrayAccess interface. * + * @param mixed $offset + * @param mixed $value * @throws NotSupportedException * @throws UnknownPropertyException * @since 4.2.0 @@ -128,6 +132,7 @@ public function offsetSet(mixed $offset, mixed $value): void /** * Required by the ArrayAccess interface. * + * @param mixed $offset * @return void * @throws NotSupportedException * @since 4.2.0 diff --git a/src/db/QueryParam.php b/src/db/QueryParam.php index 9b56c87c73d..6068d9938cc 100644 --- a/src/db/QueryParam.php +++ b/src/db/QueryParam.php @@ -25,6 +25,7 @@ final class QueryParam /** * Parses a given query param, separating it into an array of values and the logical operator (`and`, `or`, `not`). * + * @param mixed $value * @return self */ public static function parse(mixed $value): self diff --git a/src/debug/MailPanel.php b/src/debug/MailPanel.php index 8e2eb8cfb35..b2527e6479d 100644 --- a/src/debug/MailPanel.php +++ b/src/debug/MailPanel.php @@ -63,6 +63,7 @@ public function init(): void } /** + * @param mixed $attr * @return string */ private function convertParams(mixed $attr): string diff --git a/src/elements/db/ElementQuery.php b/src/elements/db/ElementQuery.php index 5c6607f059f..b892f3f8446 100644 --- a/src/elements/db/ElementQuery.php +++ b/src/elements/db/ElementQuery.php @@ -2609,6 +2609,7 @@ protected function normalizeOrderBy($columns): array /** * Combines the given condition with an alternative condition if there are any relevant placeholder elements. * + * @param mixed $condition * @return mixed */ private function _placeholderCondition(mixed $condition): mixed diff --git a/src/elements/db/ElementRelationParamParser.php b/src/elements/db/ElementRelationParamParser.php index 74db6923db4..d79f446f3bc 100644 --- a/src/elements/db/ElementRelationParamParser.php +++ b/src/elements/db/ElementRelationParamParser.php @@ -128,6 +128,7 @@ public static function normalizeRelatedToParam(mixed $relatedToParam, array|int| /** * Normalizes an individual `relatedTo` criteria. * + * @param mixed $relCriteria * @param int|string|int[]|null $siteId * @return array * @throws InvalidArgumentException if the criteria contains an invalid site handle @@ -207,6 +208,7 @@ public static function normalizeRelatedToCriteria(mixed $relCriteria, array|int| * Parses a `relatedTo` element query param and returns the condition that should * be applied back on the element query, or `false` if there's an issue. * + * @param mixed $relatedToParam * @param int|string|int[]|null $siteId * @return array|false */ @@ -249,6 +251,7 @@ public function parse(mixed $relatedToParam, array|int|string|null $siteId = nul /** * Parses a part of a relatedTo element query param and returns the condition or `false` if there's an issue. * + * @param mixed $relCriteria * @return mixed */ private function _subparse(mixed $relCriteria): mixed @@ -503,6 +506,7 @@ private function _subparse(mixed $relCriteria): mixed /** * Returns a field model based on its handle or ID. * + * @param mixed $field * @param array|null $fieldHandleParts * @param bool $useElementQueryFields * @return FieldInterface|null diff --git a/src/elements/db/NestedElementQueryTrait.php b/src/elements/db/NestedElementQueryTrait.php index cc4e91adcfb..f2c5f316563 100644 --- a/src/elements/db/NestedElementQueryTrait.php +++ b/src/elements/db/NestedElementQueryTrait.php @@ -273,6 +273,7 @@ private function normalizeFieldId(): void /** * Normalizes the primaryOwnerId param to an array of IDs or null * + * @param mixed $value * @return int[]|null|false */ private function normalizeOwnerId(mixed $value): array|null|false diff --git a/src/fieldlayoutelements/BaseField.php b/src/fieldlayoutelements/BaseField.php index 7489130cb9a..a9beadd5c6d 100644 --- a/src/fieldlayoutelements/BaseField.php +++ b/src/fieldlayoutelements/BaseField.php @@ -843,6 +843,7 @@ protected function actionMenuItems(?ElementInterface $element = null, bool $stat * Return the HTML that should be shown for the native field in the card preview. * It can be used outside an element context, e.g. in a card view designer. * + * @param mixed $value * @param ElementInterface|null $element * @return string * @since 5.5.0 diff --git a/src/fields/BaseOptionsField.php b/src/fields/BaseOptionsField.php index 3f2fec37e5e..3b41be8c798 100644 --- a/src/fields/BaseOptionsField.php +++ b/src/fields/BaseOptionsField.php @@ -372,6 +372,7 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed * Check if given option should be marked as selected. * * @param array $option + * @param mixed $value * @param array $selectedValues * @param bool $selectedBlankOption * @return bool diff --git a/src/fields/Lightswitch.php b/src/fields/Lightswitch.php index c57e4307f31..de51dfabd08 100644 --- a/src/fields/Lightswitch.php +++ b/src/fields/Lightswitch.php @@ -174,6 +174,7 @@ public function getStaticHtml(mixed $value, ?ElementInterface $element = null): /** * Render html for both static and interactive lightswitch field * + * @param mixed $value * @param ElementInterface|null $element * @param bool $static * @return string diff --git a/src/fields/Money.php b/src/fields/Money.php index f7728caa0c9..9ba5e09c170 100644 --- a/src/fields/Money.php +++ b/src/fields/Money.php @@ -264,6 +264,7 @@ public function serializeValue(mixed $value, ElementInterface $element = null): } /** + * @param mixed $value * @param string|null $currency * @return string|null */ diff --git a/src/fields/Number.php b/src/fields/Number.php index 10b9947f149..e01812ce60d 100644 --- a/src/fields/Number.php +++ b/src/fields/Number.php @@ -230,6 +230,7 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed } /** + * @param mixed $value * @return int|float|null */ private function _normalizeNumber(mixed $value): float|int|null diff --git a/src/fields/Range.php b/src/fields/Range.php index e3a4dbc5ab9..03cc437a3e4 100644 --- a/src/fields/Range.php +++ b/src/fields/Range.php @@ -178,6 +178,7 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed } /** + * @param mixed $value * @return int|float|null */ private function _normalizeNumber(mixed $value): int|float|null diff --git a/src/fields/Table.php b/src/fields/Table.php index 0d1d52c0d68..da4f1b6b3b5 100644 --- a/src/fields/Table.php +++ b/src/fields/Table.php @@ -696,6 +696,7 @@ private function _validateCellValue(string $type, mixed $value, ?string &$error /** * Returns the field's input HTML. * + * @param mixed $value * @param ElementInterface|null $element * @param bool $static * @return string diff --git a/src/fields/data/MultiOptionsFieldData.php b/src/fields/data/MultiOptionsFieldData.php index 9f4a205b1d0..ae7ddd1ce6e 100644 --- a/src/fields/data/MultiOptionsFieldData.php +++ b/src/fields/data/MultiOptionsFieldData.php @@ -43,6 +43,7 @@ public function setOptions(array $options): void } /** + * @param mixed $value * @return bool */ public function contains(mixed $value): bool diff --git a/src/fields/data/OptionData.php b/src/fields/data/OptionData.php index e0d01e6f617..0403cb43798 100644 --- a/src/fields/data/OptionData.php +++ b/src/fields/data/OptionData.php @@ -32,8 +32,9 @@ public function __construct( /** * @since 3.5.10 */ - public bool $valid = true, - ) { + public bool $valid = true + ) + { } /** diff --git a/src/gql/ElementQueryConditionBuilder.php b/src/gql/ElementQueryConditionBuilder.php index e4d8e66d281..b985133838b 100644 --- a/src/gql/ElementQueryConditionBuilder.php +++ b/src/gql/ElementQueryConditionBuilder.php @@ -236,6 +236,7 @@ private function _extractArgumentValue(Node $argumentNode): mixed * Figure out whether a node in the parentfield is a special eager-loadable field. * * @param string $nodeName + * @param mixed $parentField * @return bool */ private function _isAdditionalEagerLoadableNode(string $nodeName, mixed $parentField): bool diff --git a/src/gql/GqlEntityRegistry.php b/src/gql/GqlEntityRegistry.php index e06b5407ae0..dc775971a2d 100644 --- a/src/gql/GqlEntityRegistry.php +++ b/src/gql/GqlEntityRegistry.php @@ -92,6 +92,7 @@ public static function getEntity(string $entityName): mixed * Create an entity registry entry. * * @param string $entityName + * @param mixed $entity * @return mixed */ public static function createEntity(string $entityName, mixed $entity): mixed diff --git a/src/gql/base/ArgumentHandler.php b/src/gql/base/ArgumentHandler.php index 252cf554788..c4fea513fc0 100644 --- a/src/gql/base/ArgumentHandler.php +++ b/src/gql/base/ArgumentHandler.php @@ -34,6 +34,7 @@ public function setArgumentManager(ArgumentManager $argumentManager): void /** * Handle a single argument value * + * @param mixed $argumentValue * @return mixed */ abstract protected function handleArgument(mixed $argumentValue): mixed; diff --git a/src/gql/base/ElementResolver.php b/src/gql/base/ElementResolver.php index b405d9cb78f..f5455d2e4d1 100644 --- a/src/gql/base/ElementResolver.php +++ b/src/gql/base/ElementResolver.php @@ -29,7 +29,9 @@ abstract class ElementResolver extends Resolver /** * Resolve an element query to a single result. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return mixed */ @@ -53,6 +55,7 @@ public static function resolve(mixed $source, array $arguments, mixed $context, /** * Resolve an element query to a total count of elements. * + * @param mixed $source * @param array $arguments * @param array|null $context * @param ResolveInfo $resolveInfo @@ -67,6 +70,7 @@ public static function resolveCount(mixed $source, array $arguments, ?array $con /** * Prepare an element query for given resolution argument set. * + * @param mixed $source * @param array $arguments * @param array|null $context * @param ResolveInfo $resolveInfo diff --git a/src/gql/base/Generator.php b/src/gql/base/Generator.php index 31641f73a44..2f112951f5d 100644 --- a/src/gql/base/Generator.php +++ b/src/gql/base/Generator.php @@ -23,6 +23,7 @@ abstract class Generator /** * Get content fields for a given context. * + * @param mixed $context * @return array */ protected static function getContentFields(mixed $context): array diff --git a/src/gql/base/MutationResolver.php b/src/gql/base/MutationResolver.php index 5496e5d32c6..c57a6af9dc3 100644 --- a/src/gql/base/MutationResolver.php +++ b/src/gql/base/MutationResolver.php @@ -36,6 +36,7 @@ public function __construct(private array $_resolutionData = [], private array $ * Set a piece of data to be used by the resolver when resolving. * * @param string $key + * @param mixed $value */ public function setResolutionData(string $key, mixed $value): void { @@ -72,6 +73,7 @@ public function getResolutionData(string $key): mixed * Normalize a value according to stored normalizers. * * @param string $argument + * @param mixed $value * @return mixed */ protected function normalizeValue(string $argument, mixed $value): mixed diff --git a/src/gql/resolvers/mutations/Asset.php b/src/gql/resolvers/mutations/Asset.php index d0d2dd018bb..bbdfa5323bf 100644 --- a/src/gql/resolvers/mutations/Asset.php +++ b/src/gql/resolvers/mutations/Asset.php @@ -39,7 +39,9 @@ class Asset extends ElementMutationResolver /** * Save an asset using the passed arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return AssetElement * @throws Throwable if reasons. @@ -107,7 +109,9 @@ public function saveAsset(mixed $source, array $arguments, mixed $context, Resol /** * Delete an asset identified by the arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Category.php b/src/gql/resolvers/mutations/Category.php index 8e4866cdeda..a42e3b3015e 100644 --- a/src/gql/resolvers/mutations/Category.php +++ b/src/gql/resolvers/mutations/Category.php @@ -34,7 +34,9 @@ class Category extends ElementMutationResolver /** * Save a category using the passed arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return CategoryElement * @throws Throwable if reasons. @@ -78,7 +80,9 @@ public function saveCategory(mixed $source, array $arguments, mixed $context, Re /** * Delete a category identified by the arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Entry.php b/src/gql/resolvers/mutations/Entry.php index 554435eee54..67f42261895 100644 --- a/src/gql/resolvers/mutations/Entry.php +++ b/src/gql/resolvers/mutations/Entry.php @@ -39,7 +39,9 @@ class Entry extends ElementMutationResolver /** * Save an entry or draft using the passed arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return EntryElement * @throws Throwable if reasons. @@ -113,7 +115,9 @@ public function saveEntry(mixed $source, array $arguments, mixed $context, Resol /** * Delete an entry identified by the passed arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. @@ -140,7 +144,9 @@ public function deleteEntry(mixed $source, array $arguments, mixed $context, Res /** * Create a new draft for the entry ID identified by the arguments * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return mixed * @throws Throwable if reasons. @@ -181,7 +187,9 @@ public function createDraft(mixed $source, array $arguments, mixed $context, Res /** * Publish a draft identified by the arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return int * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/GlobalSet.php b/src/gql/resolvers/mutations/GlobalSet.php index e62ae471535..ac065853892 100644 --- a/src/gql/resolvers/mutations/GlobalSet.php +++ b/src/gql/resolvers/mutations/GlobalSet.php @@ -24,7 +24,9 @@ class GlobalSet extends ElementMutationResolver /** * Save the global set identified by resolver data. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return GlobalSetElement * @throws Throwable if reasons. diff --git a/src/gql/resolvers/mutations/Tag.php b/src/gql/resolvers/mutations/Tag.php index d44fc91d752..01cfd16a136 100644 --- a/src/gql/resolvers/mutations/Tag.php +++ b/src/gql/resolvers/mutations/Tag.php @@ -31,7 +31,9 @@ class Tag extends ElementMutationResolver /** * Save a tag using the passed arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return TagElement * @throws Throwable if reasons. @@ -72,7 +74,9 @@ public function saveTag(mixed $source, array $arguments, mixed $context, Resolve /** * Delete a tag identified by the arguments. * + * @param mixed $source * @param array $arguments + * @param mixed $context * @param ResolveInfo $resolveInfo * @return bool * @throws Throwable if reasons. diff --git a/src/gql/types/input/Addresses.php b/src/gql/types/input/Addresses.php index c73f76be57f..296d8f2b716 100644 --- a/src/gql/types/input/Addresses.php +++ b/src/gql/types/input/Addresses.php @@ -141,6 +141,7 @@ public static function getType(): mixed /** * Normalize Matrix GraphQL input data to what Craft expects. * + * @param mixed $value * @return mixed */ public static function normalizeValue(mixed $value): mixed diff --git a/src/gql/types/input/Matrix.php b/src/gql/types/input/Matrix.php index e9b59fa10a0..343f07b50fc 100644 --- a/src/gql/types/input/Matrix.php +++ b/src/gql/types/input/Matrix.php @@ -99,6 +99,7 @@ public static function getType(MatrixField $context): mixed /** * Normalize Matrix GraphQL input data to what Craft expects. * + * @param mixed $value * @return mixed */ public static function normalizeValue(mixed $value): mixed diff --git a/src/helpers/App.php b/src/helpers/App.php index 26423eb817d..37382631340 100644 --- a/src/helpers/App.php +++ b/src/helpers/App.php @@ -240,6 +240,7 @@ public static function parseEnv(?string $value): bool|string|null * $status = App::parseBooleanEnv('$SYSTEM_STATUS') ?? false; * ``` * + * @param mixed $value * @return bool|null * @since 3.7.29 */ @@ -439,6 +440,7 @@ public static function extensionVersion(string $name): string * - `'false'` → `false` * - Numeric string → integer or float * + * @param mixed $value * @return mixed * @since 4.0.0 */ diff --git a/src/helpers/ArrayHelper.php b/src/helpers/ArrayHelper.php index 6c928ab01bf..e023b516bf1 100644 --- a/src/helpers/ArrayHelper.php +++ b/src/helpers/ArrayHelper.php @@ -68,7 +68,7 @@ public static function toArray($object, $properties = [], $recursive = true): ar * @since 3.4.0 * @deprecated in 4.0.0. `array_unshift()` should be used instead. */ - public static function prepend(array &$array, mixed ...$values): void + public static function prepend(array &$array, ...$values): void { array_unshift($array, ...$values); } @@ -86,7 +86,7 @@ public static function prepend(array &$array, mixed ...$values): void * @since 3.4.0 * @deprecated in 4.0.0. `array_push()` should be used instead. */ - public static function append(array &$array, mixed ...$values): void + public static function append(array &$array, ...$values): void { array_push($array, ...$values); } @@ -416,6 +416,7 @@ public static function without(array $array, string $key): array * Returns a copy of an array without items matching the given value. * * @param array $array + * @param mixed $value * @return array */ public static function withoutValue(array $array, mixed $value): array diff --git a/src/helpers/Assets.php b/src/helpers/Assets.php index 6f524204473..0e78935621c 100644 --- a/src/helpers/Assets.php +++ b/src/helpers/Assets.php @@ -831,6 +831,7 @@ public static function scaledDimensions(int $realWidth, int $realHeight, int $ma /** * Parses a srcset size (e.g. `100w` or `2x`). * + * @param mixed $size * @return array An array of the size value and unit (`w` or `x`) * @throws InvalidArgumentException if the size can’t be parsed * @since 3.5.0 diff --git a/src/helpers/ConfigHelper.php b/src/helpers/ConfigHelper.php index 71ba52007dc..b1793aa480c 100644 --- a/src/helpers/ConfigHelper.php +++ b/src/helpers/ConfigHelper.php @@ -28,6 +28,7 @@ class ConfigHelper * - DateInterval object * - an empty value (represents 0 seconds) * + * @param mixed $value * @return int The time duration in seconds * @throws InvalidConfigException if the duration can't be determined */ diff --git a/src/helpers/DateTimeHelper.php b/src/helpers/DateTimeHelper.php index 50885db651e..9d4277fe154 100644 --- a/src/helpers/DateTimeHelper.php +++ b/src/helpers/DateTimeHelper.php @@ -547,6 +547,7 @@ public static function secondsToHumanTimeDuration(int $seconds, bool $showSecond } /** + * @param mixed $timestamp * @return bool */ public static function isValidTimeStamp(mixed $timestamp): bool diff --git a/src/helpers/Db.php b/src/helpers/Db.php index 8b92569f60a..b6c4995c411 100644 --- a/src/helpers/Db.php +++ b/src/helpers/Db.php @@ -929,7 +929,7 @@ public static function parseTimestampParam( * @return bool Whether the value was normalized * @since 3.7.40 */ - public static function normalizeParam(mixed &$value, callable $resolver): bool + public static function normalizeParam(&$value, callable $resolver): bool { if ($value === null) { return true; diff --git a/src/helpers/Diff.php b/src/helpers/Diff.php index bc7a92d3de5..c33e5b84416 100644 --- a/src/helpers/Diff.php +++ b/src/helpers/Diff.php @@ -20,6 +20,8 @@ class Diff /** * Generates a diff for two values, represented as YAML. * + * @param mixed $from + * @param mixed $to * @param int $indent The indent size that nested values should have * @param int $contextLines The number of lines to show before and after changes * @return string @@ -74,6 +76,8 @@ public static function diff(mixed $from, mixed $to, int $indent = 2, int $contex } /** + * @param mixed$from + * @param mixed $to * @param int $indent * @param int $level * @return array[] @@ -147,6 +151,8 @@ private static function _buildLine(string $line, int $indent, int $level, ?strin * * If the values are both arrays, they will be compared recursively. * + * @param mixed $a + * @param mixed $b * @param bool $strict Whether strict comparisons should be used * @return bool * @since 3.6.0 diff --git a/src/helpers/Gql.php b/src/helpers/Gql.php index 71522f59e52..535ae058129 100644 --- a/src/helpers/Gql.php +++ b/src/helpers/Gql.php @@ -289,6 +289,7 @@ public static function getUnionType(string $typeName, array $includedTypes, ?cal /** * Wrap a GQL object type in a NonNull type. * + * @param mixed $type * @return mixed */ public static function wrapInNonNull(mixed $type): mixed @@ -342,7 +343,9 @@ public static function createFullAccessSchema(): GqlSchema /** * Apply directives (if any) to a resolved value according to source and resolve info. * + * @param mixed $source * @param ResolveInfo $resolveInfo + * @param mixed $value * @return mixed */ public static function applyDirectives(mixed $source, ResolveInfo $resolveInfo, mixed $value): mixed @@ -447,6 +450,7 @@ public static function getAllowedSites(?GqlSchema $schema = null): array } /** + * @param mixed $value * @param array $variableValues * @return mixed */ @@ -467,6 +471,7 @@ private static function _convertArgumentValue(mixed $value, array $variableValue * Looking at the resolve information and the source queried, return the field name or it's alias, if used. * * @param ResolveInfo $resolveInfo + * @param mixed $source * @param array|null $context * @return string */ diff --git a/src/helpers/Html.php b/src/helpers/Html.php index bc5a7826c54..b1e7a921001 100644 --- a/src/helpers/Html.php +++ b/src/helpers/Html.php @@ -557,6 +557,7 @@ public static function normalizeTagAttributes(array $attributes): array /** * Explodes a `class` attribute into an array. * + * @param mixed $value * @return string[] * @since 3.5.0 */ @@ -577,6 +578,7 @@ public static function explodeClass(mixed $value): array /** * Explodes a `style` attribute into an array of property/value pairs. * + * @param mixed $value * @return string[] * @since 3.5.0 */ diff --git a/src/helpers/ImageTransforms.php b/src/helpers/ImageTransforms.php index fddaa1980b2..8b54a4a31e6 100644 --- a/src/helpers/ImageTransforms.php +++ b/src/helpers/ImageTransforms.php @@ -263,6 +263,7 @@ public static function parseTransformString(string $str): array /** * Normalize a transform from handle or a set of properties to an ImageTransform. * + * @param mixed $transform * @return ImageTransform|null * @throws ImageTransformException if $transform is an invalid transform handle */ diff --git a/src/helpers/MailerHelper.php b/src/helpers/MailerHelper.php index db720e55911..bcc96d881b5 100644 --- a/src/helpers/MailerHelper.php +++ b/src/helpers/MailerHelper.php @@ -186,6 +186,7 @@ public static function settingsReport(Mailer $mailer, ?TransportAdapterInterface /** * Normalizes a list of emails and returns them in a comma-separated list. * + * @param mixed $emails * @return string */ private static function _emailList(mixed $emails): string diff --git a/src/helpers/MoneyHelper.php b/src/helpers/MoneyHelper.php index 5cd4fa98cbe..871cc316c16 100644 --- a/src/helpers/MoneyHelper.php +++ b/src/helpers/MoneyHelper.php @@ -31,6 +31,7 @@ class MoneyHelper private static ISOCurrencies $_isoCurrencies; /** + * @param mixed $value * @return Money|false */ public static function toMoney(mixed $value): Money|false @@ -56,6 +57,7 @@ public static function toMoney(mixed $value): Money|false /** * Convert money object to standard decimal string. * + * @param mixed $value * @return string|false */ public static function toDecimal(mixed $value): string|false @@ -70,6 +72,7 @@ public static function toDecimal(mixed $value): string|false /** * Convert money object to localized currency string. * + * @param mixed $value * @param string|null $formatLocale * @return string|false */ @@ -92,6 +95,7 @@ public static function toString(mixed $value, ?string $formatLocale = null): str /** * Convert money object to localized decimal string. * + * @param mixed $value * @param string|null $formatLocale * @return string|false */ diff --git a/src/helpers/Number.php b/src/helpers/Number.php index 14b9e9d602f..5fe7db93751 100644 --- a/src/helpers/Number.php +++ b/src/helpers/Number.php @@ -131,6 +131,7 @@ public static function lowerRoman(int $num): string * If the variable is an object with a __toString() method, the numeric value of its string representation will be * returned. * + * @param mixed $var * @return float|int|string */ public static function makeNumeric(mixed $var): float|int|string @@ -149,6 +150,7 @@ public static function makeNumeric(mixed $var): float|int|string /** * Returns whether the given value is an int or float, or a string that represents an int or float. * + * @param mixed $value * @return bool * @since 4.0.5 */ diff --git a/src/helpers/ProjectConfig.php b/src/helpers/ProjectConfig.php index 565012c6bc6..8474e40901c 100644 --- a/src/helpers/ProjectConfig.php +++ b/src/helpers/ProjectConfig.php @@ -26,6 +26,7 @@ class ProjectConfig /** * Returns a project config compatible value encoded for storage. * + * @param mixed $value * @return string * @since 4.0.0 */ @@ -281,6 +282,7 @@ public static function cleanupConfig(array $config): array /** * Cleans a config value. * + * @param mixed $value * @return mixed * @throws InvalidConfigException */ diff --git a/src/helpers/Session.php b/src/helpers/Session.php index 20b76e45e0e..cc804767dc1 100644 --- a/src/helpers/Session.php +++ b/src/helpers/Session.php @@ -204,7 +204,7 @@ public static function hasFlash(string $key): bool * @see YiiSession::addFlash() * @since 5.5.0 */ - public static function addFlash($key, mixed $value = true, $removeAfterAccess = true): void + public static function addFlash($key, $value = true, $removeAfterAccess = true): void { self::session()?->addFlash($key, $value, $removeAfterAccess); } diff --git a/src/models/ProjectConfigData.php b/src/models/ProjectConfigData.php index d929c823c72..0b814a157d3 100644 --- a/src/models/ProjectConfigData.php +++ b/src/models/ProjectConfigData.php @@ -46,6 +46,8 @@ public function getHasPathBeenModified(string $path): bool /** * Commit changes by firing the appropriate events and updating the appropriate storages. * + * @param mixed $oldValue + * @param mixed $newValue * @param string $path * @param bool $triggerUpdate * @param string|null $message @@ -109,6 +111,7 @@ public function commitChanges(mixed $oldValue, mixed $newValue, string $path, bo * Update the internal data storage. * * @param string|string[] $path + * @param mixed $value */ protected function setInternal(string|array $path, mixed $value): void { diff --git a/src/queue/BaseBatchedJob.php b/src/queue/BaseBatchedJob.php index bbec1cd3d91..077f7b84b0c 100644 --- a/src/queue/BaseBatchedJob.php +++ b/src/queue/BaseBatchedJob.php @@ -167,6 +167,8 @@ public function execute($queue): void /** * Processes an item. + * + * @param mixed $item */ abstract protected function processItem(mixed $item): void; diff --git a/src/services/Assets.php b/src/services/Assets.php index 9bf8fce4d82..70d2f1a38b7 100644 --- a/src/services/Assets.php +++ b/src/services/Assets.php @@ -123,6 +123,7 @@ public function getAssetById(int $assetId, ?int $siteId = null): ?Asset /** * Gets the total number of assets that match a given criteria. * + * @param mixed $criteria * @return int */ public function getTotalAssets(mixed $criteria = null): int @@ -442,6 +443,7 @@ public function getFolderByUid(string $folderUid): ?VolumeFolder /** * Finds folders that match a given criteria. * + * @param mixed $criteria * @return VolumeFolder[] */ public function findFolders(mixed $criteria = []): array @@ -531,6 +533,7 @@ public function getAllDescendantFolders( /** * Finds the first folder that matches a given criteria. * + * @param mixed $criteria * @return VolumeFolder|null */ public function findFolder(mixed $criteria = []): ?VolumeFolder @@ -587,6 +590,7 @@ public function getRootFolderByVolumeId(int $volumeId): ?VolumeFolder /** * Gets the total number of folders that match a given criteria. * + * @param mixed $criteria * @return int */ public function getTotalFolders(mixed $criteria): int @@ -606,10 +610,11 @@ public function getTotalFolders(mixed $criteria): int /** * Returns whether any folders exist which match a given criteria. * + * @param mixed $criteria * @return bool * @since 4.4.0 */ - public function foldersExist(mixed $criteria = null): bool + public function foldersExist($criteria = null): bool { if (!($criteria instanceof FolderCriteria)) { $criteria = new FolderCriteria($criteria); diff --git a/src/services/Gql.php b/src/services/Gql.php index 370250ac228..e3fc18f38eb 100644 --- a/src/services/Gql.php +++ b/src/services/Gql.php @@ -1337,6 +1337,7 @@ public function prepareFieldDefinitions(array $fields, string $typeName): array * * @param GqlSchema $schema * @param string $query + * @param mixed $rootValue * @param array|null $variables * @param string|null $operationName * @return string|null diff --git a/src/services/ProjectConfig.php b/src/services/ProjectConfig.php index 1d682def1b0..43cec4a92ab 100644 --- a/src/services/ProjectConfig.php +++ b/src/services/ProjectConfig.php @@ -1705,6 +1705,8 @@ public function getHadFileWriteIssues(): bool * is null, it will be removed instead. * * @param string $path + * @param mixed $oldValue + * @param mixed $newValue * @param string|null $message message describing the changes made. * @since 4.0.0 */ diff --git a/src/services/Security.php b/src/services/Security.php index b850c3ccbd1..672b330dc61 100644 --- a/src/services/Security.php +++ b/src/services/Security.php @@ -182,6 +182,7 @@ public function isSensitive(string $key): bool * Checks the given key to see if it looks like it contains sensitive info, and if so, redacts the given value. * * @param string $key + * @param mixed $value * @return mixed The possibly-redacted value */ public function redactIfSensitive(string $key, mixed $value): mixed diff --git a/src/services/Sso.php b/src/services/Sso.php index 12d0d2890ca..6b92b65ab9c 100644 --- a/src/services/Sso.php +++ b/src/services/Sso.php @@ -145,6 +145,7 @@ private function initProviders(array $configs = []): MemoizableArray /** * Creates an auth provider from a given config. * + * @param mixed $config * @return ProviderInterface * @throws InvalidConfigException */ diff --git a/src/test/Craft.php b/src/test/Craft.php index 04649b1a63f..b4e857ac444 100644 --- a/src/test/Craft.php +++ b/src/test/Craft.php @@ -313,6 +313,7 @@ public static function getCodeceptionName(): string } /** + * @param mixed $path * @return string|false */ public static function normalizePathSeparators(mixed $path): string|false diff --git a/src/test/TestCase.php b/src/test/TestCase.php index 0af3ad62653..bb3731967fd 100644 --- a/src/test/TestCase.php +++ b/src/test/TestCase.php @@ -50,6 +50,7 @@ public function assertObjectIsInstanceOfClassCallback(string $class): callable * * @param object|string $object * @param string $propertyName + * @param mixed $value * @param bool $revoke whether to make property inaccessible after setting * @throws ReflectionException * @credit https://github.com/yiisoft/yii2/blob/master/tests/TestCase.php#L155 diff --git a/src/test/console/CommandTest.php b/src/test/console/CommandTest.php index a499f67a03d..3c4e87a10e3 100644 --- a/src/test/console/CommandTest.php +++ b/src/test/console/CommandTest.php @@ -147,6 +147,7 @@ public function stderr(iterable|string $desiredOutput): CommandTest /** * @param string $prompt + * @param mixed $returnValue * @param array $options * @return CommandTest */ @@ -162,6 +163,7 @@ public function prompt(string $prompt, mixed $returnValue, array $options = []): /** * @param string $message + * @param mixed $returnValue * @param bool $default * @return CommandTest */ @@ -177,6 +179,7 @@ public function confirm(string $message, mixed $returnValue, bool $default = fal /** * @param string $prompt + * @param mixed $returnValue * @param array $options * @return CommandTest */ diff --git a/src/web/Request.php b/src/web/Request.php index 65835a5a233..b705edb4275 100644 --- a/src/web/Request.php +++ b/src/web/Request.php @@ -1804,6 +1804,7 @@ private function _utf8AllTheThings(array $things): array } /** + * @param mixed $value * @return mixed */ private function _utf8Value(mixed $value): mixed @@ -1825,6 +1826,7 @@ private function _utf8Value(mixed $value): mixed * The name may include dots, to specify the path to a nested param. * * @param string|null $name + * @param mixed $defaultValue * @param array $params * @return mixed */ diff --git a/src/web/View.php b/src/web/View.php index 5e9fb224009..ec6999942d1 100644 --- a/src/web/View.php +++ b/src/web/View.php @@ -1680,6 +1680,7 @@ public function getInitialDeltaValues(): array * Sets the initial value of a delta input name. * * @param string $inputName + * @param mixed $value * @see getInitialDeltaValues() * @since 3.4.6 */ diff --git a/src/web/twig/Extension.php b/src/web/twig/Extension.php index 9bf453c2e24..bb59cfdda6f 100644 --- a/src/web/twig/Extension.php +++ b/src/web/twig/Extension.php @@ -524,6 +524,9 @@ public function sortFilter(TwigEnvironment $env, iterable $array, string|callabl * Reduces an array. * * @param TwigEnvironment $env + * @param mixed $array + * @param mixed $arrow + * @param mixed $initial * @return mixed * @throws RuntimeError * @since 4.4.16 @@ -538,6 +541,8 @@ public function reduceFilter(TwigEnvironment $env, mixed $array, mixed $arrow, m * Maps an array. * * @param TwigEnvironment $env + * @param mixed $array + * @param mixed $arrow * @return array * @throws RuntimeError * @since 4.4.16 @@ -552,6 +557,7 @@ public function mapFilter(TwigEnvironment $env, mixed $array, mixed $arrow = nul /** * Formats the value as a currency number. * + * @param mixed $value * @param string|null $currency * @param array $options * @param array $textOptions @@ -575,6 +581,7 @@ public function currencyFilter(mixed $value, ?string $currency = null, array $op /** * Formats the value in bytes as a size in human-readable form, for example `12 kB`. * + * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -597,6 +604,7 @@ public function filesizeFilter(mixed $value, ?int $decimals = null, array $optio /** * Formats the value as a decimal number. * + * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -619,6 +627,7 @@ public function numberFilter(mixed $value, ?int $decimals = null, array $options /** * Formats the value as a percent number with "%" sign. * + * @param mixed $value * @param int|null $decimals * @param array $options * @param array $textOptions @@ -641,6 +650,7 @@ public function percentageFilter(mixed $value, ?int $decimals = null, array $opt /** * Formats the value as a human-readable timestamp. * + * @param mixed $value * @param string|null $format * @param bool $withPreposition * @return string @@ -715,6 +725,8 @@ public function widontFilter(string $string): string /** * Returns an array without certain values. * + * @param mixed $arr + * @param mixed $exclude * @param bool $strict * @return array */ @@ -736,6 +748,7 @@ public function withoutFilter(mixed $arr, mixed $exclude, bool $strict = false): /** * Returns an array without a certain key. * + * @param mixed $arr * @param string|string[] $key * @return array * @since 3.2.0 @@ -776,6 +789,7 @@ public function parseAttrFilter(string $tag): array /** * Parses a string for reference tags. * + * @param mixed $str * @param int|null $siteId * @return string */ @@ -897,6 +911,9 @@ public function removeClassFilter(string $tag, array|string $class): string * Replaces Twig's |replace filter, adding support for passing in separate * search and replace arrays. * + * @param mixed $str + * @param mixed $search + * @param mixed $replace * @param bool|null $regex * @return mixed */ @@ -1197,6 +1214,8 @@ public function httpdateFilter(TwigEnvironment $env, mixed $date, mixed $timezon /** * Returns the index of an item in a string or array, or -1 if it cannot be found. * + * @param mixed $haystack + * @param mixed $needle * @param int|null $default * @return int|null */ @@ -1408,6 +1427,7 @@ public function getFunctions(): array /** * Returns a clone of the given variable. * + * @param mixed $var * @return mixed */ public function cloneFunction(mixed $var): mixed @@ -1418,6 +1438,7 @@ public function cloneFunction(mixed $var): mixed /** * Returns a new collection. * + * @param mixed $var * @return Collection * @since 4.0.0 */ @@ -1518,6 +1539,7 @@ public function entryTypeFunction(string $handle): EntryType } /** + * @param mixed $expression * @param array $params * @param array $config * @return Expression @@ -1589,6 +1611,7 @@ public function seqFunction(string $name, ?int $length = null, bool $next = true /** * @param string $template + * @param mixed $object * @return string */ public function renderObjectTemplate(string $template, mixed $object): string diff --git a/tests/unit/config/GeneralConfigTest.php b/tests/unit/config/GeneralConfigTest.php index 808800061e3..65762d08232 100644 --- a/tests/unit/config/GeneralConfigTest.php +++ b/tests/unit/config/GeneralConfigTest.php @@ -25,6 +25,7 @@ class GeneralConfigTest extends Unit * * @param string $oldProperty * @param string $newProperty + * @param mixed $value */ public function testRenamedSetting(string $oldProperty, string $newProperty, mixed $value): void { diff --git a/tests/unit/db/QueryParamTest.php b/tests/unit/db/QueryParamTest.php index 4cc767b7931..9c8b1caa593 100644 --- a/tests/unit/db/QueryParamTest.php +++ b/tests/unit/db/QueryParamTest.php @@ -23,6 +23,7 @@ class QueryParamTest extends TestCase * @dataProvider toArrayDataProvider * * @param array $expected + * @param mixed $value */ public function testToArray(array $expected, mixed $value): void { diff --git a/tests/unit/elements/db/ElementQueryTest.php b/tests/unit/elements/db/ElementQueryTest.php index 698b6bccddd..4eb2c232f5d 100644 --- a/tests/unit/elements/db/ElementQueryTest.php +++ b/tests/unit/elements/db/ElementQueryTest.php @@ -22,6 +22,8 @@ class ElementQueryTest extends TestCase /** * @dataProvider relatedToDataProvider * @param array|false $expected + * @param mixed $relatedToParam + * @param mixed $andRelatedToParam */ public function testAndRelatedTo(array|false $expected, mixed $relatedToParam, mixed $andRelatedToParam): void { @@ -39,6 +41,7 @@ public function testAndRelatedTo(array|false $expected, mixed $relatedToParam, m /** * @dataProvider normalizeOrderByDataProvider * @param array $expected + * @param mixed $columns * @return void */ public function testNormalizeOrderBy(array $expected, mixed $columns): void diff --git a/tests/unit/elements/db/ElementRelationParamParserTest.php b/tests/unit/elements/db/ElementRelationParamParserTest.php index 1efe150c571..9bb2d3f93bf 100644 --- a/tests/unit/elements/db/ElementRelationParamParserTest.php +++ b/tests/unit/elements/db/ElementRelationParamParserTest.php @@ -22,6 +22,7 @@ class ElementRelationParamParserTest extends TestCase /** * @dataProvider normalizeRelatedToParamDataProvider * @param array $expected + * @param mixed $param */ public function testNormalizeRelatedToParam(array $expected, mixed $param): void { @@ -47,6 +48,7 @@ public static function normalizeRelatedToParamDataProvider(): array /** * @dataProvider normalizeRelatedToCriteriaDataProvider * @param array|false $expected + * @param mixed $param */ public function testNormalizeRelatedToCriteria(array|false $expected, mixed $param): void { diff --git a/tests/unit/fields/MoneyTest.php b/tests/unit/fields/MoneyTest.php index db0b92a0825..63840fcf190 100644 --- a/tests/unit/fields/MoneyTest.php +++ b/tests/unit/fields/MoneyTest.php @@ -53,6 +53,7 @@ public function testConstruct(array $config, array $expected): void /** * @dataProvider normalizeValueDataProvider + * @param mixed $money * @param string $value * @param string|null $defaultValue * @param ElementInterface|null $element @@ -68,6 +69,7 @@ public function testNormalizeValue(mixed $money, string $value, ?string $default /** * @dataProvider getTableAttributeHtmlDataProvider + * @param mixed $value * @param string $expected * @param string|null $locale * @return void diff --git a/tests/unit/gql/DirectiveTest.php b/tests/unit/gql/DirectiveTest.php index 30bf2d16e60..0ef4cf7042a 100644 --- a/tests/unit/gql/DirectiveTest.php +++ b/tests/unit/gql/DirectiveTest.php @@ -45,6 +45,7 @@ protected function _after(): void * * @dataProvider directiveDataProvider * @param mixed $in input + * @param mixed $directiveClass * @param array $directives an array of directive data as expected by GQL * @param string $result expected result */ diff --git a/tests/unit/gql/ElementFieldResolverTest.php b/tests/unit/gql/ElementFieldResolverTest.php index b68c689afdb..5b37d85b735 100644 --- a/tests/unit/gql/ElementFieldResolverTest.php +++ b/tests/unit/gql/ElementFieldResolverTest.php @@ -261,6 +261,7 @@ public function testUserFieldResolving(string $gqlTypeClass, string $propertyNam * Test whether url transform properties are correctly passed on when transforming * * @param array $fieldArguments + * @param mixed $expectedArguments * @dataProvider assetTransformDataProvider */ public function testAssetUrlTransform(array $fieldArguments, mixed $expectedArguments): void @@ -298,6 +299,7 @@ public function testAssetUrlTransform(array $fieldArguments, mixed $expectedArgu /** * Run the test on an element for a type class with the property name. * + * @param mixed $element * @param string $gqlTypeClass The Gql type class * @phpstan-param class-string $gqlTypeClass * @param string $propertyName The property being tested diff --git a/tests/unit/gql/ScalarTypesTest.php b/tests/unit/gql/ScalarTypesTest.php index 0d61a7dc889..f46e460b369 100644 --- a/tests/unit/gql/ScalarTypesTest.php +++ b/tests/unit/gql/ScalarTypesTest.php @@ -37,6 +37,8 @@ class ScalarTypesTest extends TestCase * * @dataProvider serializationDataProvider * @param ScalarType $type + * @param mixed $testValue + * @param mixed $match * @throws Error */ public function testSerialization(ScalarType $type, mixed $testValue, mixed $match): void @@ -49,6 +51,8 @@ public function testSerialization(ScalarType $type, mixed $testValue, mixed $mat * * @dataProvider parsingValueDataProvider * @param ScalarType $type + * @param mixed $testValue + * @param mixed $match * @param string|null $exceptionThrown * @throws Error */ @@ -81,6 +85,7 @@ public function testDateTimeParseValueAndLiteral(): void * @dataProvider parsingLiteralDataProvider * @param ScalarType $type * @param ValueNode $testValue + * @param mixed $match * @param string|null $exceptionThrown * @throws Exception */ diff --git a/tests/unit/helpers/AppHelperTest.php b/tests/unit/helpers/AppHelperTest.php index c70cc31353a..79253bc5e12 100644 --- a/tests/unit/helpers/AppHelperTest.php +++ b/tests/unit/helpers/AppHelperTest.php @@ -60,8 +60,10 @@ public function testEnv(): void /** * @dataProvider envConfigDataProvider * + * @param mixed $expected * @param string $paramName * @param string $overrideName + * @param mixed $overrideValue */ public function testEnvConfig(mixed $expected, string $paramName, string $overrideName, mixed $overrideValue): void { @@ -101,6 +103,7 @@ public function testParseEnv(): void /** * @dataProvider parseBooleanEnvDataProvider * @param bool|null $expected + * @param mixed $value */ public function testParseBooleanEnv(?bool $expected, mixed $value): void { @@ -206,6 +209,7 @@ public function testEditionIdByHandle(int|false $expected, string $handle): void /** * @dataProvider validEditionsDataProvider * @param bool $expected + * @param mixed $edition */ public function testIsValidEdition(bool $expected, mixed $edition): void { diff --git a/tests/unit/helpers/ArrayHelperTest.php b/tests/unit/helpers/ArrayHelperTest.php index dd5caf2b690..d50c26c79cc 100644 --- a/tests/unit/helpers/ArrayHelperTest.php +++ b/tests/unit/helpers/ArrayHelperTest.php @@ -24,6 +24,7 @@ class ArrayHelperTest extends TestCase /** * @dataProvider toArrayDataProvider * @param array $expected + * @param mixed $object */ public function testToArray(array $expected, mixed $object): void { @@ -58,6 +59,7 @@ public function testAppend(array $expected, array $array, array $values): void * @dataProvider prependOrAppendDataProvider * @param array $expected * @param array $array + * @param mixed $appendable * @param bool $prepend */ public function testPrependOrAppend(array $expected, array $array, mixed $appendable, bool $prepend): void @@ -326,6 +328,7 @@ public function testWhereMultiple(): void * @param bool $expected * @param array $array * @param callable|string $key + * @param mixed $value * @param bool $strict */ public function testContains(bool $expected, array $array, callable|string $key, mixed $value = true, bool $strict = false): void @@ -339,6 +342,7 @@ public function testContains(bool $expected, array $array, callable|string $key, * @param bool $expected * @param array $array * @param callable|string $key + * @param mixed $value * @param bool $strict */ public function testOnlyContains(bool $expected, array $array, callable|string $key, mixed $value = true, bool $strict = false): void @@ -367,6 +371,7 @@ public function testFirstKey(): void /** * @dataProvider firstValueDataProvider + * @param mixed $expected * @param array $array */ public function testFirstValue(mixed $expected, array $array): void @@ -380,6 +385,7 @@ public function testFirstValue(mixed $expected, array $array): void * @param array $array * @param string $oldKey * @param string $newKey + * @param mixed $default */ public function testRename(array $expected, array $array, string $oldKey, string $newKey, mixed $default = null): void { @@ -402,6 +408,7 @@ public function testWithout(array $expected, array $array, string $key): void * @dataProvider withoutValueDataProvider * @param array $expected * @param array $array + * @param mixed $value */ public function testWithoutValue(array $expected, array $array, mixed $value): void { @@ -454,6 +461,7 @@ public function testGetValue(string $expected, array $array, string $key): void * @dataProvider removeValueDataProvider * @param array $expected * @param array $array + * @param mixed $value * @param bool $strict */ public function testRemoveValue(array $expected, array $array, mixed $value, bool $strict = false) diff --git a/tests/unit/helpers/AssetsHelperTest.php b/tests/unit/helpers/AssetsHelperTest.php index c49b5e2b00f..2daeaa18c33 100644 --- a/tests/unit/helpers/AssetsHelperTest.php +++ b/tests/unit/helpers/AssetsHelperTest.php @@ -173,6 +173,7 @@ public function testMaxUploadSize(): void /** * @dataProvider parseSrcsetSizeDataProvider * @param array|false $expected + * @param mixed $size */ public function testParseSrcsetSize(array|false $expected, mixed $size): void { diff --git a/tests/unit/helpers/ConfigHelperTest.php b/tests/unit/helpers/ConfigHelperTest.php index 8a39c698c9e..2ded976c320 100644 --- a/tests/unit/helpers/ConfigHelperTest.php +++ b/tests/unit/helpers/ConfigHelperTest.php @@ -41,6 +41,7 @@ public function testSizeInBytes(int|float $expected, int|string $value): void /** * @dataProvider durationInSecondsDataProvider * @param int $expected + * @param mixed $value * @throws InvalidConfigException */ public function testDurationInSeconds(int $expected, mixed $value): void @@ -80,6 +81,8 @@ public function testDurationSecondsException(): void /** * @dataProvider localizedValueDataProvider + * @param mixed $expected + * @param mixed $value * @param string|null $siteHandle */ public function testLocalizedValue(mixed $expected, mixed $value, ?string $siteHandle = null): void diff --git a/tests/unit/helpers/DateTimeHelperTest.php b/tests/unit/helpers/DateTimeHelperTest.php index 78458ede550..a444a40d3c8 100644 --- a/tests/unit/helpers/DateTimeHelperTest.php +++ b/tests/unit/helpers/DateTimeHelperTest.php @@ -268,6 +268,7 @@ public function testCurrentUtcDateTimeStamp(): void * toDateTime must start the DateTime from Asia/Tokyo instead of UTC(The default starting point) and then convert it to the system timezone. * * @dataProvider formatsWithTimezoneDataProvider + * @param mixed $value * @param callable $expectedResult * @throws Exception */ @@ -291,6 +292,7 @@ public function testUtcIgnorance(mixed $value, callable $expectedResult): void /** * @dataProvider toDateTimeDataProvider * @param callable|DateTime|false $expected + * @param mixed $value * @throws Exception */ public function testToDateTime(callable|DateTime|false $expected, mixed $value): void @@ -317,6 +319,7 @@ public function testToDateTime(callable|DateTime|false $expected, mixed $value): * Test that if we set the $setToSystemTimezone value to false that toDateTime creates a tz in UTC. * * @dataProvider simpleDateTimeFormatsDataProvider + * @param mixed $value * @throws Exception */ public function testUtcDefault(mixed $value): void @@ -329,6 +332,7 @@ public function testUtcDefault(mixed $value): void * Test that dateTime is created with the passed in timezone IF $setSystemTimezone is set to false. * * @dataProvider toDateTimeWithTzFormatsDataProvider + * @param mixed $value * @param DateTime $expectedResult * @param DateTimeZone $expectedTimezone * @throws Exception @@ -345,6 +349,7 @@ public function testToDateTimeRespectsTz(mixed $value, DateTime $expectedResult, /** * @dataProvider toDateTimeFormatsDataProvider + * @param mixed $value * @param callable $expectedResult * @param string|null $closureParam * @throws Exception @@ -386,6 +391,7 @@ public function testNormalizeTimeZone(string|false $expected, string $timeZone): /** * @dataProvider isIsIso8601DataProvider * @param bool $expected + * @param mixed $value */ public function testIsIso8601(bool $expected, mixed $value): void { @@ -580,6 +586,7 @@ public function testIntervalToSeconds(int $expected, string $duration): void /** * @dataProvider toIso8601DataProvider * @param string|false $expected + * @param mixed $date */ public function testToIso8601(string|false $expected, mixed $date): void { @@ -589,6 +596,7 @@ public function testToIso8601(string|false $expected, mixed $date): void /** * @dataProvider isValidTimeStampDataProvider * @param bool $expected + * @param mixed $timestamp */ public function testIsValidTimeStamp(bool $expected, mixed $timestamp): void { diff --git a/tests/unit/helpers/DiffHelperTest.php b/tests/unit/helpers/DiffHelperTest.php index 9ad2986cf60..43a8f7f7e5d 100644 --- a/tests/unit/helpers/DiffHelperTest.php +++ b/tests/unit/helpers/DiffHelperTest.php @@ -22,6 +22,8 @@ class DiffHelperTest extends TestCase /** * @dataProvider compareDataProvider * @param bool $expected + * @param mixed $a + * @param mixed $b * @param bool $strict */ public function testCompare(bool $expected, mixed $a, mixed $b, bool $strict): void @@ -32,6 +34,8 @@ public function testCompare(bool $expected, mixed $a, mixed $b, bool $strict): v /** * @dataProvider diffDataProvider * @param string $expected + * @param mixed $from + * @param mixed $to * @param int $indent * @param int $contextLines */ diff --git a/tests/unit/helpers/GqlHelperTest.php b/tests/unit/helpers/GqlHelperTest.php index e70d04c37c2..917c1ba5c25 100644 --- a/tests/unit/helpers/GqlHelperTest.php +++ b/tests/unit/helpers/GqlHelperTest.php @@ -137,6 +137,8 @@ public function testEntityActionExtraction(array $scope, string $entity, array $ /** * Test GQL types correctly wrapped in NonNull type. * + * @param mixed $input + * @param mixed $expected * @dataProvider wrapInNonNullProvider */ public function testWrapInNonNull(mixed $input, mixed $expected): void diff --git a/tests/unit/helpers/JsonHelperTest.php b/tests/unit/helpers/JsonHelperTest.php index c02ca908099..6d0f05e4523 100644 --- a/tests/unit/helpers/JsonHelperTest.php +++ b/tests/unit/helpers/JsonHelperTest.php @@ -22,6 +22,7 @@ class JsonHelperTest extends TestCase { /** * @dataProvider decodeIfJsonDataProvider + * @param mixed $expected * @param string $str */ public function testDecodeIfJson(mixed $expected, string $str): void diff --git a/tests/unit/helpers/LocalizationHelperTest.php b/tests/unit/helpers/LocalizationHelperTest.php index 4506354f56a..a4cde6af0ff 100644 --- a/tests/unit/helpers/LocalizationHelperTest.php +++ b/tests/unit/helpers/LocalizationHelperTest.php @@ -51,6 +51,8 @@ public function testLanguageNormalizationExceptions(): void /** * @dataProvider normalizeNumberDataProvider + * @param mixed $expected + * @param mixed $number * @param string|null $localeId */ public function testNormalizeNumber(mixed $expected, mixed $number, ?string $localeId): void diff --git a/tests/unit/helpers/MoneyHelperTest.php b/tests/unit/helpers/MoneyHelperTest.php index 262205f3d4d..f661b4bd4a7 100644 --- a/tests/unit/helpers/MoneyHelperTest.php +++ b/tests/unit/helpers/MoneyHelperTest.php @@ -24,6 +24,7 @@ class MoneyHelperTest extends TestCase { /** * @dataProvider toMoneyDataProvider + * @param mixed $value * @param Money|false $expected */ public function testToMoney(mixed $value, Money|false $expected): void @@ -33,6 +34,8 @@ public function testToMoney(mixed $value, Money|false $expected): void /** * @dataProvider toDecimalDataProvider + * @param mixed $value + * @param mixed $expected * @return void */ public function testToDecimal(mixed $value, mixed $expected): void @@ -42,6 +45,8 @@ public function testToDecimal(mixed $value, mixed $expected): void /** * @dataProvider toNumberDataProvider + * @param mixed $value + * @param mixed $expected * @param string|null $locale * @return void */ @@ -61,6 +66,8 @@ public function testToNumber(mixed $value, mixed $expected, ?string $locale = nu /** * @dataProvider toStringDataProvider + * @param mixed $value + * @param mixed $expected * @param string|null $locale * @return void */ diff --git a/tests/unit/helpers/NumberHelperTest.php b/tests/unit/helpers/NumberHelperTest.php index 37a749709f5..bc223bc42b2 100644 --- a/tests/unit/helpers/NumberHelperTest.php +++ b/tests/unit/helpers/NumberHelperTest.php @@ -72,6 +72,8 @@ public function testLowerRoman(string $expected, int $num): void /** * @dataProvider makeNumericDataProvider + * @param mixed $expected + * @param mixed $var */ public function testMakeNumeric(mixed $expected, mixed $var): void { @@ -81,6 +83,7 @@ public function testMakeNumeric(mixed $expected, mixed $var): void /** * @dataProvider isIntOrFloatDataProvider * @param bool $expected + * @param mixed $value */ public function testIsIntOrFloat(bool $expected, mixed $value): void { diff --git a/tests/unit/helpers/ProjectConfigHelperTest.php b/tests/unit/helpers/ProjectConfigHelperTest.php index 797fbcf01d7..84fbb37ddd8 100644 --- a/tests/unit/helpers/ProjectConfigHelperTest.php +++ b/tests/unit/helpers/ProjectConfigHelperTest.php @@ -81,6 +81,7 @@ public function testTouch(string $input, string $expected): void } /** + * @param mixed $incomingData * @param string $expectedResult * @dataProvider encodeTestDataProvider */ diff --git a/tests/unit/helpers/StringHelperTest.php b/tests/unit/helpers/StringHelperTest.php index 0a0215fa67b..8002688f329 100644 --- a/tests/unit/helpers/StringHelperTest.php +++ b/tests/unit/helpers/StringHelperTest.php @@ -1401,6 +1401,7 @@ public function testToSpaces(string $expected, string $string, int $tabLength = /** * @dataProvider toStringDataProvider * @param string $expected + * @param mixed $object * @param string $glue */ public function testToString(string $expected, mixed $object, string $glue = ','): void diff --git a/tests/unit/helpers/TypecastHelperTest.php b/tests/unit/helpers/TypecastHelperTest.php index 3f90411a8c6..35aa81fd0f0 100644 --- a/tests/unit/helpers/TypecastHelperTest.php +++ b/tests/unit/helpers/TypecastHelperTest.php @@ -28,6 +28,8 @@ class TypecastHelperTest extends TestCase * * @param string $class * @param string $property + * @param mixed $expected + * @param mixed $value */ public function testScalarProperties(string $class, string $property, mixed $expected, mixed $value): void { diff --git a/tests/unit/helpers/dbhelper/DbHelperTest.php b/tests/unit/helpers/dbhelper/DbHelperTest.php index ff3af2f0244..c770663c0a7 100644 --- a/tests/unit/helpers/dbhelper/DbHelperTest.php +++ b/tests/unit/helpers/dbhelper/DbHelperTest.php @@ -75,6 +75,7 @@ class DbHelperTest extends TestCase * @dataProvider parseParamDataProvider * @param array|null $expected * @param string $column + * @param mixed $value * @param string $defaultOperator * @param bool $caseInsensitive * @param string|null $columnType @@ -218,6 +219,8 @@ public function testDeleteIfExistsException(): void /** * @dataProvider prepareValueForDbDataProvider + * @param mixed $expected + * @param mixed $value */ public function testPrepareValueForDb(mixed $expected, mixed $value): void { @@ -320,6 +323,7 @@ public function testGetMinAllowedValueForNumericColumn(int|false $expected, stri /** * @dataProvider prepareValuesForDbDataProvider * @param array $expected + * @param mixed $values */ public function testPrepareValuesForDb(array $expected, mixed $values): void { diff --git a/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php b/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php index a7cd5d84e24..eca7cb532f7 100644 --- a/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php +++ b/tests/unit/helpers/dbhelper/MysqlDbHelperTest.php @@ -60,6 +60,7 @@ public static function getTextualColumnStorageCapacityDataProvider(): array /** * @dataProvider parseParamDataProvider + * @param mixed $expected * @param string $column * @param string|int|array $value * @param string $defaultOperator diff --git a/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php b/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php index fa02067b9ce..0721cc38ae7 100644 --- a/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php +++ b/tests/unit/helpers/dbhelper/PgsqlDbHelperTest.php @@ -51,6 +51,7 @@ public function testGetTextualColumnStorageCapacity(int|null|false $expected, st * @dataProvider parseParamDataProvider * @param string|array $expected * @param string $column + * @param mixed $value * @param string $defaultOperator * @param bool $caseInsensitive */ diff --git a/tests/unit/i18n/FormatterTest.php b/tests/unit/i18n/FormatterTest.php index fe9e5b92181..0fa62e11ac9 100644 --- a/tests/unit/i18n/FormatterTest.php +++ b/tests/unit/i18n/FormatterTest.php @@ -21,6 +21,7 @@ class FormatterTest extends TestCase { /** * @param string $expected + * @param mixed $value * @param int|null $decimals * @dataProvider asPercentDataProvider */ diff --git a/tests/unit/services/ProjectConfigTest.php b/tests/unit/services/ProjectConfigTest.php index 2fbd0dcd89e..d35f95b1e4a 100644 --- a/tests/unit/services/ProjectConfigTest.php +++ b/tests/unit/services/ProjectConfigTest.php @@ -120,6 +120,7 @@ public function testRebuildIgnoresReadOnly(): void /** * @param string|null $path * @param bool $useExternal + * @param mixed $expectedValue * @throws Exception * @dataProvider getValueDataProvider */ @@ -131,6 +132,7 @@ public function testGettingValue(?string $path, bool $useExternal, mixed $expect /** * @param string $path + * @param mixed $value * @dataProvider setValueDataProvider */ public function testSettingValue(string $path, mixed $value): void diff --git a/tests/unit/services/SearchTest.php b/tests/unit/services/SearchTest.php index fd0557e8bfc..e4be5fc9348 100644 --- a/tests/unit/services/SearchTest.php +++ b/tests/unit/services/SearchTest.php @@ -133,6 +133,7 @@ protected function _before(): void } /** + * @param mixed $attributeName * @param iterable $searchIndex * @return string */ diff --git a/tests/unit/services/SecurityTest.php b/tests/unit/services/SecurityTest.php index c6c73a9014d..e8f3ab03ce4 100644 --- a/tests/unit/services/SecurityTest.php +++ b/tests/unit/services/SecurityTest.php @@ -21,7 +21,9 @@ class SecurityTest extends TestCase { /** * @dataProvider redactIfSensitiveDataProvider + * @param mixed $expected * @param string $name + * @param mixed $value * @param string[] $sensitiveKeywords */ public function testRedactIfSensitive(mixed $expected, string $name, mixed $value, array $sensitiveKeywords): void diff --git a/tests/unit/validators/ArrayValidatorTest.php b/tests/unit/validators/ArrayValidatorTest.php index 2d81b01cf3d..36315b0e755 100644 --- a/tests/unit/validators/ArrayValidatorTest.php +++ b/tests/unit/validators/ArrayValidatorTest.php @@ -63,6 +63,7 @@ public function testCountArrayInputValue(): void /** * @dataProvider arrayValidatorValuesDataProvider + * @param mixed $inputValue * @param bool $mustValidate */ public function testValidation(mixed $inputValue, bool $mustValidate): void diff --git a/tests/unit/validators/PasswordValidatorTest.php b/tests/unit/validators/PasswordValidatorTest.php index 16618bb2941..4ed06cac36e 100644 --- a/tests/unit/validators/PasswordValidatorTest.php +++ b/tests/unit/validators/PasswordValidatorTest.php @@ -63,6 +63,7 @@ public function testValidation(string $inputValue, bool $mustValidate, string $c /** * @dataProvider customConfigDataProvider + * @param mixed $input * @param bool $mustValidate * @param int $min * @param int $max diff --git a/tests/unit/validators/UriValidatorTest.php b/tests/unit/validators/UriValidatorTest.php index 56ea454d40d..32f616f0eb7 100644 --- a/tests/unit/validators/UriValidatorTest.php +++ b/tests/unit/validators/UriValidatorTest.php @@ -33,6 +33,7 @@ class UriValidatorTest extends TestCase /** * @dataProvider validateValueDataProvider * @param bool $mustValidate + * @param mixed $input * @param string|null $pattern */ public function testValidateValue(bool $mustValidate, mixed $input, string $pattern = null): void diff --git a/tests/unit/web/RequestTest.php b/tests/unit/web/RequestTest.php index 7de5e4b9d34..9cf490c1f76 100644 --- a/tests/unit/web/RequestTest.php +++ b/tests/unit/web/RequestTest.php @@ -363,6 +363,8 @@ public function testCsrfTokenValidFailure(): void /** * @dataProvider getParamDataProvider + * @param mixed $expected + * @param mixed $defaultValue * @param array $params * @param string|null $name * @throws ReflectionException @@ -526,6 +528,7 @@ protected function _before(): void /** * @param string|null $name + * @param mixed $defaultValue * @param array $params * @return mixed * @throws ReflectionException diff --git a/tests/unit/web/ResponseTest.php b/tests/unit/web/ResponseTest.php index a69d1887d0b..10e3d7e71e7 100644 --- a/tests/unit/web/ResponseTest.php +++ b/tests/unit/web/ResponseTest.php @@ -76,6 +76,7 @@ public function testSetLastModifiedHeader(): void /** * @param string $expected + * @param mixed $url * @dataProvider testRedirectDataProvider */ public function testRedirect(string $expected, mixed $url): void diff --git a/tests/unit/web/ViewTest.php b/tests/unit/web/ViewTest.php index 1cbfe1eee90..f25bb586c8c 100644 --- a/tests/unit/web/ViewTest.php +++ b/tests/unit/web/ViewTest.php @@ -174,6 +174,7 @@ public function testRenderString(): void * @dataProvider renderObjectTemplateDataProvider * @param string $expected * @param string $template + * @param mixed $object * @param array $variables * @throws Exception * @throws Throwable @@ -623,6 +624,7 @@ protected function _before(): void } /** + * @param mixed $category * @param array $messages * @return string */ @@ -640,6 +642,8 @@ private function _generateTranslationJs(mixed $category, array $messages): strin } /** + * @param mixed $desiredJs + * @param mixed $desiredPosition * @throws \Exception */ private function _assertRegisterJsInputValues(mixed $desiredJs, mixed $desiredPosition) From 8f99b2b6039fef3789179da3d7a13080c764cd93 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 20 Feb 2025 18:11:04 +0700 Subject: [PATCH 3/9] run cs fix --- src/fields/data/OptionData.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fields/data/OptionData.php b/src/fields/data/OptionData.php index 0403cb43798..e0d01e6f617 100644 --- a/src/fields/data/OptionData.php +++ b/src/fields/data/OptionData.php @@ -32,9 +32,8 @@ public function __construct( /** * @since 3.5.10 */ - public bool $valid = true - ) - { + public bool $valid = true, + ) { } /** From de6fed397636a70821b072a994c20b7c8a25b6a6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 02:43:05 +0700 Subject: [PATCH 4/9] do not rename property on property promotion --- rector.php | 6 +++++- src/base/MemoizableArray.php | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index a9a2f3f3f8c..1243ab88d74 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; +use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; @@ -41,4 +42,7 @@ MixedTypeRector::class, ]) - ->withPhpSets(php80: true); + ->withPhpSets(php80: true) + ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ + ClassPropertyAssignToConstructorPromotionRector::RENAME_PROPERTY => false, + ]); diff --git a/src/base/MemoizableArray.php b/src/base/MemoizableArray.php index 9ae8d453bc1..0a1c5dc181d 100644 --- a/src/base/MemoizableArray.php +++ b/src/base/MemoizableArray.php @@ -34,6 +34,11 @@ */ class MemoizableArray implements IteratorAggregate, Countable { + /** + * @var array Array elements + */ + private array $_elements; + /** * @var callable|null Normalizer method */ @@ -52,12 +57,13 @@ class MemoizableArray implements IteratorAggregate, Countable /** * Constructor * - * @param array $_elements The items to be memoized + * @param array $elements The items to be memoized * @param callable|null $normalizer A method that the items should be normalized with when first returned by * [[all()]] or [[firstWhere()]]. */ - public function __construct(private array $_elements, ?callable $normalizer = null) + public function __construct(array $elements, ?callable $normalizer = null) { + $this->_elements = $elements; $this->_normalizer = $normalizer; } From cadbf1b315548bd9f97b34c8a4acf91282d00a95 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 02:48:03 +0700 Subject: [PATCH 5/9] skip property promotion when property is different --- src/fields/data/ColorData.php | 10 ++++++++-- src/gql/base/MutationResolver.php | 18 +++++++++++++++--- src/search/SearchQuery.php | 10 ++++++++-- src/test/console/CommandTest.php | 18 +++++++++++++++--- src/test/mockclasses/ToString.php | 10 ++++++++-- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/fields/data/ColorData.php b/src/fields/data/ColorData.php index 0e67f0393be..b0bf9c53b55 100644 --- a/src/fields/data/ColorData.php +++ b/src/fields/data/ColorData.php @@ -28,6 +28,11 @@ */ class ColorData extends BaseObject implements Serializable, \Stringable { + /** + * @var string The color’s hex value + */ + private string $_hex; + /** * @var array * @see _hsl() @@ -37,11 +42,12 @@ class ColorData extends BaseObject implements Serializable, \Stringable /** * Constructor. * - * @param string $_hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.) + * @param string $hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.) * @param array $config name-value pairs that will be used to initialize the object properties */ - public function __construct(private string $_hex, array $config = []) + public function __construct(string $hex, array $config = []) { + $this->_hex = $hex; parent::__construct($config); } diff --git a/src/gql/base/MutationResolver.php b/src/gql/base/MutationResolver.php index c57a6af9dc3..3ee1a642002 100644 --- a/src/gql/base/MutationResolver.php +++ b/src/gql/base/MutationResolver.php @@ -20,15 +20,27 @@ */ abstract class MutationResolver extends Component { + /** + * @var array Data that might be useful during mutation resolution. + */ + private array $_resolutionData; + + /** + * @var callable[] Value normalizers stored by argument name + */ + private array $_valueNormalizers = []; + /** * Construct a mutation resolver and store the resolution data as well as normalizers, if any provided. * - * @param array $_resolutionData Resolver data - * @param array $_valueNormalizers Data normalizers + * @param array $data Resolver data + * @param array $valueNormalizers Data normalizers * @param array $config */ - public function __construct(private array $_resolutionData = [], private array $_valueNormalizers = [], array $config = []) + public function __construct(array $data = [], array $valueNormalizers = [], array $config = []) { + $this->_resolutionData = $data; + $this->_valueNormalizers = $valueNormalizers; parent::__construct($config); } diff --git a/src/search/SearchQuery.php b/src/search/SearchQuery.php index 251c02a2236..4352cb72a1f 100644 --- a/src/search/SearchQuery.php +++ b/src/search/SearchQuery.php @@ -17,6 +17,11 @@ */ class SearchQuery { + /** + * @var string + */ + private string $_query; + /** * @var array * @phpstan-var array{subLeft:bool,subRight:bool,exclude:bool,exact:bool} @@ -31,12 +36,13 @@ class SearchQuery /** * Constructor * - * @param string $_query + * @param string $query * @param array $defaultTermOptions * @phpstan-param array{subLeft?:bool,subRight?:bool,exclude?:bool,exact?:bool} $defaultTermOptions */ - public function __construct(private string $_query, array $defaultTermOptions = []) + public function __construct(string $query, array $defaultTermOptions = []) { + $this->_query = $query; $this->_defaultTermOptions = $defaultTermOptions + [ 'subLeft' => false, 'subRight' => true, diff --git a/src/test/console/CommandTest.php b/src/test/console/CommandTest.php index 3c4e87a10e3..7a39c821c94 100644 --- a/src/test/console/CommandTest.php +++ b/src/test/console/CommandTest.php @@ -29,6 +29,16 @@ class CommandTest public const SELECT = 'select'; public const OUTPUT_COMMAND = 'outputCommand'; + /** + * @var ConsoleTest + */ + protected ConsoleTest $test; + + /** + * @var bool + */ + protected bool $ignoreStdout = false; + /** * @var int */ @@ -72,14 +82,16 @@ class CommandTest /** * CommandTest constructor. * - * @param ConsoleTest $test + * @param ConsoleTest $consoleTest * @param string $command * @param array $parameters - * @param bool $ignoreStdout + * @param bool $ignoreStdOut * @throws InvalidConfigException */ - public function __construct(protected ConsoleTest $test, protected string $command, protected array $parameters = [], protected bool $ignoreStdout = false) + public function __construct(ConsoleTest $consoleTest, protected string $command, protected array $parameters = [], bool $ignoreStdOut = false) { + $this->ignoreStdout = $ignoreStdOut; + $this->test = $consoleTest; $this->setupController(); } diff --git a/src/test/mockclasses/ToString.php b/src/test/mockclasses/ToString.php index 7d874e6e14b..9dd520c2e64 100644 --- a/src/test/mockclasses/ToString.php +++ b/src/test/mockclasses/ToString.php @@ -16,13 +16,19 @@ */ class ToString implements \Stringable { + /** + * @var string + */ + private string $_string; + /** * ToString constructor. * - * @param string $_string + * @param string $string */ - public function __construct(private string $_string) + public function __construct(string $string) { + $this->_string = $string; } /** From 0ef22bea0d202a8ee6ec97d63443155669314c24 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 03:21:24 +0700 Subject: [PATCH 6/9] import Stringable --- src/base/Field.php | 3 ++- src/fields/data/ColorData.php | 3 ++- src/fields/data/LinkData.php | 3 ++- src/fields/data/OptionData.php | 3 ++- src/i18n/Locale.php | 3 ++- src/models/AssetIndexData.php | 3 ++- src/models/CategoryGroup.php | 3 ++- src/models/EntryType.php | 3 ++- src/models/GqlSchema.php | 3 ++- src/models/GqlToken.php | 3 ++- src/models/ImageTransform.php | 3 ++- src/models/ImageTransformIndex.php | 3 ++- src/models/Section.php | 3 ++- src/models/Site.php | 3 ++- src/models/SiteGroup.php | 3 ++- src/models/TagGroup.php | 3 ++- src/models/UserGroup.php | 3 ++- src/models/VolumeFolder.php | 3 ++- src/test/mockclasses/ToString.php | 4 +++- 19 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/base/Field.php b/src/base/Field.php index 92202ff1fb6..cf04eaa81cf 100644 --- a/src/base/Field.php +++ b/src/base/Field.php @@ -30,6 +30,7 @@ use DateTime; use Exception; use GraphQL\Type\Definition\Type; +use Stringable; use yii\base\Arrayable; use yii\base\ErrorHandler; use yii\base\InvalidArgumentException; @@ -43,7 +44,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -abstract class Field extends SavableComponent implements FieldInterface, Iconic, Actionable, \Stringable +abstract class Field extends SavableComponent implements FieldInterface, Iconic, Actionable, Stringable { use FieldTrait; diff --git a/src/fields/data/ColorData.php b/src/fields/data/ColorData.php index b0bf9c53b55..95d5280030c 100644 --- a/src/fields/data/ColorData.php +++ b/src/fields/data/ColorData.php @@ -8,6 +8,7 @@ namespace craft\fields\data; use craft\base\Serializable; +use Stringable; use yii\base\BaseObject; /** @@ -26,7 +27,7 @@ * @author Top Shelf Craft * @since 3.0.0 */ -class ColorData extends BaseObject implements Serializable, \Stringable +class ColorData extends BaseObject implements Serializable, Stringable { /** * @var string The color’s hex value diff --git a/src/fields/data/LinkData.php b/src/fields/data/LinkData.php index aea8c2b6a4d..758badfe93d 100644 --- a/src/fields/data/LinkData.php +++ b/src/fields/data/LinkData.php @@ -14,6 +14,7 @@ use craft\fields\linktypes\BaseLinkType; use craft\helpers\Html; use craft\helpers\Template; +use Stringable; use Twig\Markup; use yii\base\BaseObject; @@ -30,7 +31,7 @@ * @author Pixel & Tonic, Inc. * @since 5.3.0 */ -class LinkData extends BaseObject implements Serializable, \Stringable +class LinkData extends BaseObject implements Serializable, Stringable { /** * @var string|null The link’s URL suffix value. diff --git a/src/fields/data/OptionData.php b/src/fields/data/OptionData.php index e0d01e6f617..3663b96d0be 100644 --- a/src/fields/data/OptionData.php +++ b/src/fields/data/OptionData.php @@ -8,6 +8,7 @@ namespace craft\fields\data; use craft\base\Serializable; +use Stringable; /** * Class OptionData @@ -15,7 +16,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class OptionData implements Serializable, \Stringable +class OptionData implements Serializable, Stringable { /** * Constructor diff --git a/src/i18n/Locale.php b/src/i18n/Locale.php index 4521ddaf7bb..b03bd58afd1 100644 --- a/src/i18n/Locale.php +++ b/src/i18n/Locale.php @@ -11,6 +11,7 @@ use DateTime; use IntlDateFormatter; use NumberFormatter; +use Stringable; use yii\base\BaseObject; use yii\base\Exception; use yii\base\InvalidArgumentException; @@ -22,7 +23,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class Locale extends BaseObject implements \Stringable +class Locale extends BaseObject implements Stringable { /** * @var int Positive prefix. diff --git a/src/models/AssetIndexData.php b/src/models/AssetIndexData.php index 2391089abfd..a147eb948a7 100644 --- a/src/models/AssetIndexData.php +++ b/src/models/AssetIndexData.php @@ -9,6 +9,7 @@ use craft\base\Model; use DateTime; +use Stringable; /** * AssetIndexData model class. @@ -16,7 +17,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class AssetIndexData extends Model implements \Stringable +class AssetIndexData extends Model implements Stringable { /** * @var int|null ID diff --git a/src/models/CategoryGroup.php b/src/models/CategoryGroup.php index dbddc08bb90..53a956e1de6 100644 --- a/src/models/CategoryGroup.php +++ b/src/models/CategoryGroup.php @@ -23,6 +23,7 @@ use craft\validators\HandleValidator; use craft\validators\UniqueValidator; use DateTime; +use Stringable; /** * CategoryGroup model. @@ -36,7 +37,7 @@ class CategoryGroup extends Model implements Chippable, CpEditable, FieldLayoutProviderInterface, - \Stringable + Stringable { /** @since 3.7.0 */ public const DEFAULT_PLACEMENT_BEGINNING = 'beginning'; diff --git a/src/models/EntryType.php b/src/models/EntryType.php index e6bf8013047..199fa8d29b3 100644 --- a/src/models/EntryType.php +++ b/src/models/EntryType.php @@ -27,6 +27,7 @@ use craft\records\EntryType as EntryTypeRecord; use craft\validators\HandleValidator; use craft\validators\UniqueValidator; +use Stringable; /** * EntryType model class. @@ -44,7 +45,7 @@ class EntryType extends Model implements Indicative, Colorable, Actionable, - \Stringable + Stringable { /** * @inheritdoc diff --git a/src/models/GqlSchema.php b/src/models/GqlSchema.php index 4a723d3b9a6..b42d0a67a27 100644 --- a/src/models/GqlSchema.php +++ b/src/models/GqlSchema.php @@ -11,6 +11,7 @@ use craft\helpers\StringHelper; use craft\records\GqlSchema as GqlSchemaRecord; use craft\validators\UniqueValidator; +use Stringable; /** * GraphQL schema class @@ -18,7 +19,7 @@ * @author Pixel & Tonic, Inc. * @since 3.3.0 */ -class GqlSchema extends Model implements \Stringable +class GqlSchema extends Model implements Stringable { /** * @var int|null ID diff --git a/src/models/GqlToken.php b/src/models/GqlToken.php index c29694a8a21..e310f19359f 100644 --- a/src/models/GqlToken.php +++ b/src/models/GqlToken.php @@ -13,6 +13,7 @@ use craft\records\GqlToken as GqlSchemaRecord; use craft\validators\UniqueValidator; use DateTime; +use Stringable; /** * GraphQL token class @@ -21,7 +22,7 @@ * @author Pixel & Tonic, Inc. * @since 3.4.0 */ -class GqlToken extends Model implements \Stringable +class GqlToken extends Model implements Stringable { /** * The public access token value. diff --git a/src/models/ImageTransform.php b/src/models/ImageTransform.php index 67d57d498f1..7b9f890bca9 100644 --- a/src/models/ImageTransform.php +++ b/src/models/ImageTransform.php @@ -17,6 +17,7 @@ use craft\validators\HandleValidator; use craft\validators\UniqueValidator; use DateTime; +use Stringable; /** * The ImageTransform model class. @@ -25,7 +26,7 @@ * @author Pixel & Tonic, Inc. * @since 4.0.0 */ -class ImageTransform extends Model implements \Stringable +class ImageTransform extends Model implements Stringable { /** * @var string The default image transformer diff --git a/src/models/ImageTransformIndex.php b/src/models/ImageTransformIndex.php index dd481b26c40..4df47255f9b 100644 --- a/src/models/ImageTransformIndex.php +++ b/src/models/ImageTransformIndex.php @@ -13,6 +13,7 @@ use craft\helpers\ImageTransforms; use craft\validators\DateTimeValidator; use DateTime; +use Stringable; use yii\base\InvalidConfigException; /** @@ -22,7 +23,7 @@ * @author Pixel & Tonic, Inc. * @since 4.0.0 */ -class ImageTransformIndex extends Model implements \Stringable +class ImageTransformIndex extends Model implements Stringable { /** * @var int|null ID diff --git a/src/models/Section.php b/src/models/Section.php index d9e0197a57e..a8f99163454 100644 --- a/src/models/Section.php +++ b/src/models/Section.php @@ -24,6 +24,7 @@ use craft\records\Section as SectionRecord; use craft\validators\HandleValidator; use craft\validators\UniqueValidator; +use Stringable; /** * Section model class. @@ -34,7 +35,7 @@ * @property EntryType[] $entryTypes Entry types * @property bool $hasMultiSiteEntries Whether entries in this section support multiple sites */ -class Section extends Model implements Chippable, CpEditable, Iconic, \Stringable +class Section extends Model implements Chippable, CpEditable, Iconic, Stringable { public const TYPE_SINGLE = 'single'; public const TYPE_CHANNEL = 'channel'; diff --git a/src/models/Site.php b/src/models/Site.php index 953940914e9..4316ce3dd90 100644 --- a/src/models/Site.php +++ b/src/models/Site.php @@ -18,6 +18,7 @@ use craft\validators\UniqueValidator; use craft\validators\UrlValidator; use DateTime; +use Stringable; use yii\base\InvalidConfigException; /** @@ -30,7 +31,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class Site extends Model implements Chippable, \Stringable +class Site extends Model implements Chippable, Stringable { public static function get(int|string $id): ?static { diff --git a/src/models/SiteGroup.php b/src/models/SiteGroup.php index cce61b63d8c..ffdd9329932 100644 --- a/src/models/SiteGroup.php +++ b/src/models/SiteGroup.php @@ -12,6 +12,7 @@ use craft\helpers\App; use craft\records\SiteGroup as SiteGroupRecord; use craft\validators\UniqueValidator; +use Stringable; /** * SiteGroup model class. @@ -20,7 +21,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class SiteGroup extends Model implements \Stringable +class SiteGroup extends Model implements Stringable { /** * @var int|null ID diff --git a/src/models/TagGroup.php b/src/models/TagGroup.php index 98ae8716db0..3ba51bc8db6 100644 --- a/src/models/TagGroup.php +++ b/src/models/TagGroup.php @@ -16,6 +16,7 @@ use craft\validators\HandleValidator; use craft\validators\UniqueValidator; use DateTime; +use Stringable; /** * TagGroup model. @@ -24,7 +25,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class TagGroup extends Model implements FieldLayoutProviderInterface, \Stringable +class TagGroup extends Model implements FieldLayoutProviderInterface, Stringable { /** * @var int|null ID diff --git a/src/models/UserGroup.php b/src/models/UserGroup.php index 2dc22cf09f2..3303e075798 100644 --- a/src/models/UserGroup.php +++ b/src/models/UserGroup.php @@ -12,6 +12,7 @@ use craft\records\UserGroup as UserGroupRecord; use craft\validators\HandleValidator; use craft\validators\UniqueValidator; +use Stringable; /** * UserGroup model class. @@ -19,7 +20,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class UserGroup extends Model implements \Stringable +class UserGroup extends Model implements Stringable { /** * @var int|null ID diff --git a/src/models/VolumeFolder.php b/src/models/VolumeFolder.php index e2474f05351..e18804b4aaf 100644 --- a/src/models/VolumeFolder.php +++ b/src/models/VolumeFolder.php @@ -11,6 +11,7 @@ use craft\base\FsInterface; use craft\base\Model; use craft\helpers\Html; +use Stringable; use yii\base\InvalidConfigException; /** @@ -22,7 +23,7 @@ * @author Pixel & Tonic, Inc. * @since 3.0.0 */ -class VolumeFolder extends Model implements \Stringable +class VolumeFolder extends Model implements Stringable { /** * @var int|null ID diff --git a/src/test/mockclasses/ToString.php b/src/test/mockclasses/ToString.php index 9dd520c2e64..7c7cb524939 100644 --- a/src/test/mockclasses/ToString.php +++ b/src/test/mockclasses/ToString.php @@ -7,6 +7,8 @@ namespace craft\test\mockclasses; +use Stringable; + /** * Class ToString. * @@ -14,7 +16,7 @@ * @author Global Network Group | Giel Tettelaar * @since 3.2 */ -class ToString implements \Stringable +class ToString implements Stringable { /** * @var string From 045613fef983f51c1158cb0dbd232c6fd93bc8d5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 13:12:54 +0700 Subject: [PATCH 7/9] skip only void on switch --- rector.php | 10 ++++- src/base/NestedElementTrait.php | 15 ++++--- .../controllers/ProjectConfigController.php | 16 +++++--- src/elements/db/ElementQuery.php | 11 +++-- src/elements/db/EntryQuery.php | 19 ++++++--- src/i18n/Locale.php | 41 ++++++++++++++----- 6 files changed, 80 insertions(+), 32 deletions(-) diff --git a/rector.php b/rector.php index 1243ab88d74..fcb1132e6c3 100644 --- a/rector.php +++ b/rector.php @@ -35,9 +35,17 @@ __DIR__ . '/src/helpers/DateTimeHelper.php', ], - // object check + ChangeSwitchToMatchRector::class => [ + // object check __DIR__ . '/src/elements/Entry.php', + + // by preference usage, no assign or returns used, just void call + __DIR__ . '/src/base/NestedElementTrait.php', + __DIR__ . '/src/console/controllers/ProjectConfigController.php', + __DIR__ . '/src/elements/db/ElementQuery.php', + __DIR__ . '/src/elements/db/EntryQuery.php', + __DIR__ . '/src/i18n/Locale.php', ], MixedTypeRector::class, diff --git a/src/base/NestedElementTrait.php b/src/base/NestedElementTrait.php index e935bede9ec..8f8734e340a 100644 --- a/src/base/NestedElementTrait.php +++ b/src/base/NestedElementTrait.php @@ -371,11 +371,16 @@ public function addInvalidNestedElementIds(array $ids): void */ public function setEagerLoadedElements(string $handle, array $elements, EagerLoadPlan $plan): void { - match ($plan->handle) { - 'owner' => $this->setOwner(reset($elements) ?: null), - 'primaryOwner' => $this->setPrimaryOwner(reset($elements) ?: null), - default => parent::setEagerLoadedElements($handle, $elements, $plan), - }; + switch ($plan->handle) { + case 'owner': + $this->setOwner(reset($elements) ?: null); + break; + case 'primaryOwner': + $this->setPrimaryOwner(reset($elements) ?: null); + break; + default: + parent::setEagerLoadedElements($handle, $elements, $plan); + } } /** diff --git a/src/console/controllers/ProjectConfigController.php b/src/console/controllers/ProjectConfigController.php index 8c24472a7dd..8ae9c1d4ad3 100644 --- a/src/console/controllers/ProjectConfigController.php +++ b/src/console/controllers/ProjectConfigController.php @@ -244,11 +244,17 @@ public function actionDiff(): int foreach (explode("\n", $diff) as $line) { $firstChar = $line[0] ?? ''; - match ($firstChar) { - '-' => $this->stdout($line . PHP_EOL, Console::FG_RED), - '+' => $this->stdout($line . PHP_EOL, Console::FG_GREEN), - default => $this->stdout($line . PHP_EOL), - }; + switch ($firstChar) { + case '-': + $this->stdout($line . PHP_EOL, Console::FG_RED); + break; + case '+': + $this->stdout($line . PHP_EOL, Console::FG_GREEN); + break; + default: + $this->stdout($line . PHP_EOL); + break; + } } $this->stdout(PHP_EOL); diff --git a/src/elements/db/ElementQuery.php b/src/elements/db/ElementQuery.php index b892f3f8446..1003178ecab 100644 --- a/src/elements/db/ElementQuery.php +++ b/src/elements/db/ElementQuery.php @@ -607,10 +607,13 @@ public function __construct(public string $elementType, array $config = []) */ public function __set($name, $value) { - match ($name) { - 'site' => $this->site($value), - default => parent::__set($name, $value), - }; + switch ($name) { + case 'site': + $this->site($value); + break; + default: + parent::__set($name, $value); + } } /** diff --git a/src/elements/db/EntryQuery.php b/src/elements/db/EntryQuery.php index 22ef7b1c82e..760783dc7f2 100644 --- a/src/elements/db/EntryQuery.php +++ b/src/elements/db/EntryQuery.php @@ -233,12 +233,19 @@ public function __construct($elementType, array $config = []) */ public function __set($name, $value) { - match ($name) { - 'section' => $this->section($value), - 'type' => $this->type($value), - 'authorGroup' => $this->authorGroup($value), - default => $this->nestedTraitSet($name, $value), - }; + switch ($name) { + case 'section': + $this->section($value); + break; + case 'type': + $this->type($value); + break; + case 'authorGroup': + $this->authorGroup($value); + break; + default: + $this->nestedTraitSet($name, $value); + } } /** diff --git a/src/i18n/Locale.php b/src/i18n/Locale.php index b03bd58afd1..9eb2ce14cc6 100644 --- a/src/i18n/Locale.php +++ b/src/i18n/Locale.php @@ -494,11 +494,18 @@ public function getMonthName(int $month, ?string $length = null, bool $standAlon $formatter = new IntlDateFormatter($this->aliasOf ?? $this->id, IntlDateFormatter::NONE, IntlDateFormatter::NONE); - match ($length) { - self::LENGTH_ABBREVIATED => $formatter->setPattern($standAlone ? 'LLLLL' : 'MMMMM'), - self::LENGTH_SHORT, self::LENGTH_MEDIUM => $formatter->setPattern($standAlone ? 'LLL' : 'MMM'), - default => $formatter->setPattern($standAlone ? 'LLLL' : 'MMMM'), - }; + switch ($length) { + case self::LENGTH_ABBREVIATED: + $formatter->setPattern($standAlone ? 'LLLLL' : 'MMMMM'); + break; // S + case self::LENGTH_SHORT: + case self::LENGTH_MEDIUM: + $formatter->setPattern($standAlone ? 'LLL' : 'MMM'); + break; // Sep + default: + $formatter->setPattern($standAlone ? 'LLLL' : 'MMMM'); + break; // September + } return $formatter->format(new DateTime('1970-' . sprintf('%02d', $month) . '-01')); } @@ -537,12 +544,24 @@ public function getWeekDayName(int $day, ?string $length = null, bool $standAlon $formatter = new IntlDateFormatter($this->aliasOf ?? $this->id, IntlDateFormatter::NONE, IntlDateFormatter::NONE); - match ($length) { - self::LENGTH_ABBREVIATED => $formatter->setPattern($standAlone ? 'ccccc' : 'eeeee'), - self::LENGTH_SHORT => $formatter->setPattern($standAlone ? 'cccccc' : 'eeeeee'), - self::LENGTH_MEDIUM => $formatter->setPattern($standAlone ? 'ccc' : 'eee'), - default => $formatter->setPattern($standAlone ? 'cccc' : 'eeee'), - }; + switch ($length) { + case self::LENGTH_ABBREVIATED: + // T + $formatter->setPattern($standAlone ? 'ccccc' : 'eeeee'); + break; + case self::LENGTH_SHORT: + // Tu + $formatter->setPattern($standAlone ? 'cccccc' : 'eeeeee'); + break; + case self::LENGTH_MEDIUM: + // Tue + $formatter->setPattern($standAlone ? 'ccc' : 'eee'); + break; + default: + // Tuesday + $formatter->setPattern($standAlone ? 'cccc' : 'eeee'); + break; + } // 1970-01-04 => Sunday (0 + 4) // 1970-01-05 => Monday (1 + 4) From 72306b6c1bd4aa0d86787bde0c6d620b28cef8bd Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 13:15:24 +0700 Subject: [PATCH 8/9] skip more only void call usage on switch --- rector.php | 1 + src/elements/db/NestedElementQueryTrait.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rector.php b/rector.php index fcb1132e6c3..12ca3a7488c 100644 --- a/rector.php +++ b/rector.php @@ -42,6 +42,7 @@ // by preference usage, no assign or returns used, just void call __DIR__ . '/src/base/NestedElementTrait.php', + __DIR__ . '/src/elements/db/NestedElementQueryTrait.php', __DIR__ . '/src/console/controllers/ProjectConfigController.php', __DIR__ . '/src/elements/db/ElementQuery.php', __DIR__ . '/src/elements/db/EntryQuery.php', diff --git a/src/elements/db/NestedElementQueryTrait.php b/src/elements/db/NestedElementQueryTrait.php index f2c5f316563..fb44a86c08e 100644 --- a/src/elements/db/NestedElementQueryTrait.php +++ b/src/elements/db/NestedElementQueryTrait.php @@ -73,12 +73,19 @@ trait NestedElementQueryTrait */ public function __set($name, $value) { - match ($name) { - 'field' => $this->field($value), - 'owner' => $this->owner($value), - 'primaryOwner' => $this->primaryOwner($value), - default => parent::__set($name, $value), - }; + switch ($name) { + case 'field': + $this->field($value); + break; + case 'owner': + $this->owner($value); + break; + case 'primaryOwner': + $this->primaryOwner($value); + break; + default: + parent::__set($name, $value); + } } /** From 2ce4511b49c8611ddbac10ea6180bdafedbbca9e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 1 Mar 2025 12:23:34 +0700 Subject: [PATCH 9/9] skip ElementQueryTagDependency --- rector.php | 4 ++++ src/cache/ElementQueryTagDependency.php | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 12ca3a7488c..accb03734ff 100644 --- a/rector.php +++ b/rector.php @@ -50,6 +50,10 @@ ], MixedTypeRector::class, + + ClassPropertyAssignToConstructorPromotionRector::class => [ + __DIR__ . '/src/cache/ElementQueryTagDependency.php', + ], ]) ->withPhpSets(php80: true) ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ diff --git a/src/cache/ElementQueryTagDependency.php b/src/cache/ElementQueryTagDependency.php index be2a8e19d77..e075dd01bd1 100644 --- a/src/cache/ElementQueryTagDependency.php +++ b/src/cache/ElementQueryTagDependency.php @@ -18,14 +18,20 @@ */ class ElementQueryTagDependency extends TagDependency { + /** + * @var ElementQuery|null + */ + public ?ElementQuery $elementQuery = null; + /** * Constructor * * @param ElementQuery $elementQuery * @param array $config */ - public function __construct(public ?ElementQuery $elementQuery, array $config = []) + public function __construct(ElementQuery $elementQuery, array $config = []) { + $this->elementQuery = $elementQuery; parent::__construct($config); }