Skip to content

Commit

Permalink
Merge branch '5.x' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 20, 2024
2 parents 31e7c78 + d303c47 commit c8ecf6e
Show file tree
Hide file tree
Showing 92 changed files with 237 additions and 502 deletions.
5 changes: 2 additions & 3 deletions src/Craft.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function getAlias($alias, $throwException = true)
/**
* @inheritdoc
* @template T
* @param string|array|callable $type
* @param class-string<T>|array|callable $type
* @phpstan-param class-string<T>|array{class:class-string<T>}|callable():T $type
* @param array $params
* @return T
Expand Down Expand Up @@ -196,8 +196,7 @@ public static function cookieConfig(array $config = [], ?Request $request = null
/**
* Class autoloader.
*
* @param string $className
* @phpstan-param class-string $className
* @param class-string $className
*/
public static function autoload($className): void
{
Expand Down
3 changes: 1 addition & 2 deletions src/base/ElementAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public static function isDownload(): bool
}

/**
* @var string
* @phpstan-var class-string<ElementInterface>
* @var class-string<ElementInterface>
* @since 3.0.30
*/
protected string $elementType;
Expand Down
3 changes: 1 addition & 2 deletions src/base/ElementActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public static function isDownload(): bool;
/**
* Sets the element type on the action.
*
* @param string $elementType
* @phpstan-param class-string<ElementInterface> $elementType
* @param class-string<ElementInterface> $elementType
*/
public function setElementType(string $elementType): void;

Expand Down
3 changes: 1 addition & 2 deletions src/base/ElementExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static function isFormattable(): bool
}

/**
* @var string
* @phpstan-var class-string<ElementInterface>
* @var class-string<ElementInterface>
*/
protected string $elementType;

Expand Down
3 changes: 1 addition & 2 deletions src/base/ElementExporterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public static function isFormattable(): bool;
/**
* Sets the element type on the exporter.
*
* @param string $elementType
* @phpstan-param class-string<ElementInterface> $elementType
* @param class-string<ElementInterface> $elementType
*/
public function setElementType(string $elementType): void;

Expand Down
14 changes: 6 additions & 8 deletions src/base/FieldLayoutComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ private static function defaultUserCondition(): UserCondition
}

/**
* @param string $elementType
* @phpstan-param class-string<ElementInterface> $elementType
* @param class-string<ElementInterface> $elementType
* @return ElementConditionInterface
*/
private static function defaultElementCondition(string $elementType): ElementConditionInterface
{
if (!isset(self::$defaultElementConditions[$elementType])) {
/** @var string|ElementInterface $elementType */
self::$defaultElementConditions[$elementType] = $elementType::createCondition();
}
return self::$defaultElementConditions[$elementType];
Expand All @@ -88,15 +86,15 @@ private static function defaultElementCondition(string $elementType): ElementCon
private FieldLayout $_layout;

/**
* @var UserCondition|string|array|null
* @var UserCondition|class-string<UserCondition>|array|null
* @phpstan-var UserCondition|class-string<UserCondition>|array{class:class-string<UserCondition>}|null
* @see getUserCondition()
* @see setUserCondition()
*/
private mixed $_userCondition = null;

/**
* @var ElementConditionInterface|string|array|null
* @var ElementConditionInterface|class-string<ElementConditionInterface>|array|null
* @phpstan-var ElementConditionInterface|class-string<ElementConditionInterface>|array{class:class-string<ElementConditionInterface>}|null
* @see getElementCondition()
* @see setElementCondition()
Expand Down Expand Up @@ -160,7 +158,7 @@ public function getUserCondition(): ?UserCondition
/**
* Sets the user condition for this layout element.
*
* @param UserCondition|string|array|null $userCondition
* @param UserCondition|class-string<UserCondition>|array|null $userCondition
* @phpstan-param UserCondition|class-string<UserCondition>|array{class:class-string<UserCondition>}|null $userCondition
*/
public function setUserCondition(mixed $userCondition): void
Expand Down Expand Up @@ -192,7 +190,7 @@ public function getElementCondition(): ?ElementConditionInterface
/**
* Sets the element condition for this layout element.
*
* @param ElementConditionInterface|string|array|null $elementCondition
* @param ElementConditionInterface|class-string<ElementConditionInterface>|array|null $elementCondition
* @phpstan-param ElementConditionInterface|class-string<ElementConditionInterface>|array{class:class-string<ElementConditionInterface>}|null $elementCondition
*/
public function setElementCondition(mixed $elementCondition): void
Expand All @@ -204,7 +202,7 @@ public function setElementCondition(mixed $elementCondition): void
* Normalizes a condition.
*
* @template T of ConditionInterface
* @param T|string|array|null $condition
* @param T|class-string<T>|array|null $condition
* @phpstan-param T|class-string<T>|array{class:class-string<T>}|null $condition
* @return T|null
*/
Expand Down
6 changes: 2 additions & 4 deletions src/base/MissingComponentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
trait MissingComponentTrait
{
/**
* @var string The expected component class name.
* @phpstan-var class-string<ComponentInterface>
* @var class-string<ComponentInterface> The expected component class name.
*/
public string $expectedType;

Expand All @@ -39,8 +38,7 @@ trait MissingComponentTrait
/**
* Creates a new component of a given type based on this one’s properties.
*
* @param string $type The component class that should be used as the fallback
* @phpstan-param class-string<ComponentInterface> $type
* @param class-string<ComponentInterface> $type The component class that should be used as the fallback
* @return ComponentInterface
*/
public function createFallback(string $type): ComponentInterface
Expand Down
5 changes: 1 addition & 4 deletions src/base/conditions/BaseElementSelectConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ private function _elements(): array
return [];
}

/** @var string|ElementInterface $elementType */
/** @phpstan-var class-string<ElementInterface>|ElementInterface $elementType */
$elementType = $this->elementType();
return $elementType::find()
return $this->elementType()::find()
->site('*')
->preferSites(array_filter([Cp::requestedSite()?->id]))
->unique()
Expand Down
3 changes: 1 addition & 2 deletions src/behaviors/FieldLayoutBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
class FieldLayoutBehavior extends Behavior
{
/**
* @var string|null The element type that the field layout will be associated with
* @phpstan-var class-string<ElementInterface>|null
* @var class-string<ElementInterface>|null The element type that the field layout will be associated with
*/
public ?string $elementType = null;

Expand Down
3 changes: 1 addition & 2 deletions src/behaviors/SessionBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ private function _setNotificationFlash(string $type, string $message, array $set
* Asset bundles that were queued with this method can be registered using [[getAssetBundleFlashes()]] or
* [[\craft\web\View::getBodyHtml()]].
*
* @param string $name the class name of the asset bundle
* @phpstan-param class-string<AssetBundle> $name
* @param class-string<AssetBundle> $name the class name of the asset bundle
* @param int|null $position if set, this forces a minimum position for javascript files.
* @throws Exception if $name isn't an asset bundle class name
* @see getAssetBundleFlashes()
Expand Down
5 changes: 1 addition & 4 deletions src/console/controllers/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace craft\console\controllers;

use Craft;
use craft\base\ElementInterface;
use craft\base\FieldInterface;
use craft\base\MergeableFieldInterface;
use craft\console\Controller;
Expand Down Expand Up @@ -381,9 +380,7 @@ private function usagesDescriptor(array $layouts): string

private function layoutDescriptor(FieldLayout $layout): string
{
/** @var string|ElementInterface $elementType */
$elementType = $layout->type;
$elementDisplayName = $elementType::lowerDisplayName();
$elementDisplayName = $layout->type::lowerDisplayName();
$providerHandle = $layout->provider?->getHandle();
return $providerHandle
? "the `$providerHandle` $elementDisplayName layout"
Expand Down
5 changes: 1 addition & 4 deletions src/console/controllers/ResaveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,13 @@ public function hasTheFields(FieldLayout $fieldLayout): bool
}

/**
* @param string $elementType The element type that should be resaved
* @phpstan-param class-string<ElementInterface> $elementType
* @param class-string<ElementInterface> $elementType The element type that should be resaved
* @param array $criteria The element criteria that determines which elements should be resaved
* @return int
* @since 3.7.0
*/
public function resaveElements(string $elementType, array $criteria = []): int
{
/** @var string|ElementInterface $elementType */
/** @phpstan-var class-string<ElementInterface>|ElementInterface $elementType */
$criteria += $this->_baseCriteria();

if ($this->queue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function actionIndex(): int
continue;
}

/** @var ElementInterface|string $elementType */
/** @var class-string<ElementInterface> $elementType */
$elementType = $element['type'];
$deleteCount = $element['count'] - 1;

Expand Down
2 changes: 1 addition & 1 deletion src/console/controllers/utils/PruneRevisionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function actionIndex(): int
continue;
}

/** @var ElementInterface|string $elementType */
/** @var class-string<ElementInterface> $elementType */
$elementType = $element['type'];
$deleteCount = $element['count'] - $this->maxRevisions;

Expand Down
3 changes: 1 addition & 2 deletions src/console/controllers/utils/RepairController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ protected function repairStructure(int $structureId, ElementQuery $query): int
])
->all();

/** @var string|ElementInterface $elementType */
/** @phpstan-var class-string<ElementInterface>|ElementInterface $elementType */
/** @var class-string<ElementInterface> $elementType */
$elementType = $query->elementType;
$displayName = $elementType::pluralLowerDisplayName();

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public function actionRenderElements(): Response
$elementHtml = [];

foreach ($criteria as $criterion) {
/** @var string|ElementInterface $elementType */
/** @var class-string<ElementInterface> $elementType */
$elementType = $criterion['type'];
$id = $criterion['id'];
$fieldId = $criterion['fieldId'] ?? null;
Expand Down Expand Up @@ -832,7 +832,7 @@ public function actionRenderComponents(): Response
$menuItemHtml = [];

foreach ($components as $componentInfo) {
/** @var string|Chippable $componentType */
/** @var class-string<Chippable> $componentType */
$componentType = $componentInfo['type'];
$id = $componentInfo['id'];

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/BaseElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function beforeAction($action): bool
/**
* Returns the posted element type class.
*
* @return string
* @return class-string<ElementInterface>
* @throws BadRequestHttpException if the requested element type is invalid
*/
protected function elementType(): string
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public function actionIndex(): Response
$widgetTypeInfo = [];

foreach ($widgetTypes as $widgetType) {
/** @var string|WidgetInterface $widgetType */
/** @phpstan-var class-string<WidgetInterface>|WidgetInterface $widgetType */
/** @var class-string<WidgetInterface> $widgetType */
if (!$widgetType::isSelectable()) {
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/ElementIndexSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public function beforeAction($action): bool
*/
public function actionGetCustomizeSourcesModalData(): Response
{
/** @var string|ElementInterface $elementType */
/** @phpstan-var class-string<ElementInterface>|ElementInterface $elementType */
/** @var class-string<ElementInterface> $elementType */
$elementType = $this->elementType();
$conditionsService = Craft::$app->getConditions();
$view = Craft::$app->getView();
Expand Down
Loading

0 comments on commit c8ecf6e

Please sign in to comment.