Skip to content
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default css`
border-radius: var(--c-radius-md);
position: relative;
}

craft-badge-indicator {
position: absolute;
inset-inline-end: 0;
Expand All @@ -34,7 +34,7 @@ export default css`
.nav-item--flush {
margin-inline-start: calc(var(--_padding-inline) * -1);
}

:host([group]) {
margin-block-start: var(--c-spacing-sm);
}
Expand Down
5 changes: 2 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ includes:

parameters:
phpVersion: 80500
level: 5
level: 6
paths:
- src
- config
stubFiles:
- yii2-adapter/stubs/laravel-ruleset-validation.stub
- yii2-adapter/stubs/_generated.stub
- yii2-adapter/stubs/GraphQL/Type/Definition/FieldDefinition.stub
- yii2-adapter/stubs/GraphQL/Type/Definition/ResolveInfo.stub
Expand All @@ -30,5 +31,3 @@ parameters:
configDirectories:
- tests
tmpDir: /tmp/phpstan
ignoreErrors:
- '#^Call to function class_exists\(\) with .* will always evaluate to false.$#'
2 changes: 1 addition & 1 deletion resources/js/pages/users/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
};

collect(page.props.sources ?? []);
collect((page.props.sources ?? []) as Source[]);

return slugs;
});
Expand Down
8 changes: 8 additions & 0 deletions src/Address/Addresses.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function getAddressFormatRepository(): AddressFormatRepository

/**
* Returns subdivisions for a field based on its parents.
*
* @param list<string> $parents
* @param array<string, string> $options
* @return array<string, string>
*/
public function defineAddressSubdivisions(array $parents, array $options = []): array
{
Expand All @@ -81,6 +85,8 @@ public function defineAddressSubdivisions(array $parents, array $options = []):

/**
* Returns a list of countries to be used as options for selection.
*
* @return array<string, string>
*/
public function getCountryList(?string $locale = null): array
{
Expand Down Expand Up @@ -155,6 +161,8 @@ public function getFieldLabel(string $field, string $countryCode): string

/**
* Formats the address model into the correct sequence and format in HTML.
*
* @param array{locale?: string, html?: bool, html_tag?: string, html_attributes?: array<string, string>} $options
*/
public function formatAddress(Address $address, array $options = [], ?FormatterInterface $formatter = null): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Concerns/LegacyConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CraftCms\Cms\Address\Concerns;

if (! class_exists(LegacyConstants::class)) {
if (! trait_exists(LegacyConstants::class)) {
/**
* @internal This is a hook for the yii2-adapter to define its constants.
*/
Expand Down
1 change: 1 addition & 0 deletions src/Address/Conditions/AdministrativeAreaConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AdministrativeAreaConditionRule extends BaseMultiSelectConditionRule imple
{
public string $countryCode = 'US';

/** @return array<string, mixed> */
#[Override]
public function getConfig(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Conditions/FieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function matchElement(ElementInterface $element): bool
}

/**
* @return Collection<Addresses>
* @return Collection<int, Addresses>
*/
private function addressFields(): Collection
{
Expand Down
10 changes: 8 additions & 2 deletions src/Address/Elements/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class Address extends Element implements AddressInterface, NestedElementInterfac
#[AllowedInSandbox]
public ?string $longitude = null;

public function __construct($config = [])
/** @param array<string, mixed>|object $config */
public function __construct(object|array $config = [])
{
parent::__construct($config);

Expand Down Expand Up @@ -188,6 +189,7 @@ public static function createCondition(): ElementConditionInterface
return new AddressCondition(self::class);
}

/** @return list<class-string<Copy>> */
#[Override]
protected static function defineActions(string $source): array
{
Expand All @@ -196,6 +198,7 @@ protected static function defineActions(string $source): array
];
}

/** @return array<string, array{label: string}> */
#[Override]
protected static function defineTableAttributes(): array
{
Expand Down Expand Up @@ -224,6 +227,7 @@ protected function attributeHtml(string $attribute): string
};
}

/** @return list<array{label: string, orderBy: string, attribute?: string, defaultDir?: 'asc'|'desc'}> */
#[Override]
protected static function defineSortOptions(): array
{
Expand Down Expand Up @@ -293,6 +297,7 @@ public static function addressAttributes(): array
];
}

/** @return list<string> */
#[Override]
public function safeAttributes(): array
{
Expand Down Expand Up @@ -323,7 +328,7 @@ public function setAttributes($values): void
}

#[Override]
public function getAttributeLabel($attribute): string
public function getAttributeLabel(string $attribute): string
{
if (AddressField::exists($attribute)) {
/** @phpstan-var AddressField::* $attribute */
Expand Down Expand Up @@ -353,6 +358,7 @@ public function getBelongsToCurrentUser(): bool
return $owner instanceof User && $owner->getIsCurrent();
}

/** @return list<array<string, mixed>> */
#[Override]
protected function safeActionMenuItems(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Events/AddressCountriesResolving.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AddressCountriesResolving
{
public function __construct(
public string $locale,
/** @var array list of countries keyed by their country code. */
/** @var array<string, string> List of countries keyed by their country code. */
public array $countries,
) {}
}
4 changes: 2 additions & 2 deletions src/Address/Events/AddressSubdivisionsResolving.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class AddressSubdivisionsResolving
{
public function __construct(
/**
* @var array The field's parents; always in order of: countryCode, administrativeArea, locality
* @var list<string> The field's parents; always in order of: countryCode, administrativeArea, locality
*/
public array $parents,
/** @var string[] $subdivisions The subdivisions */
/** @var array<string, string> $subdivisions The subdivisions */
public array $subdivisions,
) {}
}
2 changes: 2 additions & 0 deletions src/Address/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace CraftCms\Cms\Address\Models;

use CraftCms\Cms\Database\Factories\AddressFactory;
use CraftCms\Cms\Database\Table;
use CraftCms\Cms\Shared\BaseModel;
use CraftCms\Cms\User\Models\User;
Expand All @@ -12,6 +13,7 @@

class Address extends BaseModel
{
/** @use HasFactory<AddressFactory> */
use HasFactory;

#[\Override]
Expand Down
7 changes: 7 additions & 0 deletions src/Address/Repositories/SubdivisionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
class SubdivisionRepository extends BaseSubdivisionRepository
{
/**
* @param list<string> $parents
* @return array<string, string>
*/
#[Override]
public function getList(array $parents, $locale = null): array
{
Expand All @@ -34,6 +38,9 @@ public function getList(array $parents, $locale = null): array

/**
* Get a list of extra subdivision options
*
* @param list<string> $parents
* @return array<string, string>
*/
private function getExtraOptions(array $parents, ?string $lang = null): array
{
Expand Down
21 changes: 21 additions & 0 deletions src/Address/Validation/AddressRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function prepareForValidation(): void
}
}

/** @return array<string, array<int, mixed>> */
#[Override]
public function rules(): array
{
Expand All @@ -85,6 +86,10 @@ public function rules(): array
return $this->addCoordinateValidation($rules);
}

/**
* @param array<string, array<int, mixed>> $rules
* @return array<string, array<int, mixed>>
*/
private function addAddressAttributeRules(array $rules): array
{
$rules['fieldId'] = ['nullable', 'integer'];
Expand All @@ -110,6 +115,10 @@ private function addAddressAttributeRules(array $rules): array
return $rules;
}

/**
* @param array<string, array<int, mixed>> $rules
* @return array<string, array<int, mixed>>
*/
private function addCountryCodeValidation(array $rules): array
{
$countryCodes = array_keys(app(Addresses::class)->getCountryRepository()->getList());
Expand All @@ -118,6 +127,10 @@ private function addCountryCodeValidation(array $rules): array
return $rules;
}

/**
* @param array<string, array<int, mixed>> $rules
* @return array<string, array<int, mixed>>
*/
private function addAddressFormatRequirements(array $rules): array
{
foreach (Address::addressAttributes() as $attribute) {
Expand Down Expand Up @@ -145,6 +158,10 @@ private function isRequiredByAddressFormat(string $attribute): bool
return in_array($attribute, $formatter->getRequiredFields());
}

/**
* @param array<string, array<int, mixed>> $rules
* @return array<string, array<int, mixed>>
*/
private function addFieldLayoutRequirements(array $rules): array
{
$fieldLayout = $this->subject->getFieldLayout();
Expand Down Expand Up @@ -182,6 +199,10 @@ private function resolveFieldAttributes(BaseNativeField $field): array
};
}

/**
* @param array<string, array<int, mixed>> $rules
* @return array<string, array<int, mixed>>
*/
private function addCoordinateValidation(array $rules): array
{
$coordinateScenarios = $this->inScenarios(self::SCENARIO_LIVE, self::SCENARIO_DEFAULT);
Expand Down
2 changes: 2 additions & 0 deletions src/Announcement/Announcements.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function push(string $heading, string $body, ?string $pluginHandle = null

/**
* Returns any announcements for the logged-in user.
*
* @return list<array{id: int, icon: string|false, label: string, heading: string, body: string, unread: bool}>
*/
public function get(): array
{
Expand Down
6 changes: 6 additions & 0 deletions src/Announcement/Models/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace CraftCms\Cms\Announcement\Models;

use CraftCms\Cms\Database\Factories\AnnouncementFactory;
use CraftCms\Cms\Plugin\Models\Plugin;
use CraftCms\Cms\Shared\BaseModel;
use CraftCms\Cms\User\Models\User;
Expand All @@ -14,6 +15,7 @@

class Announcement extends BaseModel
{
/** @use HasFactory<AnnouncementFactory> */
use HasFactory;

public const ?string UPDATED_AT = null;
Expand All @@ -38,6 +40,10 @@ public function plugin(): BelongsTo
return $this->belongsTo(Plugin::class, 'pluginId');
}

/**
* @param Builder<Announcement> $query
* @return Builder<Announcement>
*/
#[Scope]
protected function visible(Builder $query): Builder
{
Expand Down
1 change: 1 addition & 0 deletions src/Asset/Actions/EditImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class EditImage extends ElementAction
{
public string $label;

/** @param array<string, mixed>|object $config */
public function __construct(array|object $config = [])
{
parent::__construct($config);
Expand Down
1 change: 1 addition & 0 deletions src/Asset/Actions/PreviewAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PreviewAsset extends ElementAction
{
public ?string $label = null;

/** @param array<string, mixed>|object $config */
public function __construct(array|object $config = [])
{
parent::__construct($config);
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/AssetFileKinds.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#[Singleton]
class AssetFileKinds
{
/** @var array<string, array|Closure> */
/** @var array<string, array{label?:string, extensions?:list<string>}|Closure():array{label?:string, extensions?:list<string>}> */
private array $fileKinds = [];

/** @var array<string, true> */
Expand Down
5 changes: 4 additions & 1 deletion src/Asset/AssetIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#[Singleton]
class AssetIndexer
{
/** @var Collection<int, IndexingSession> */
public Collection $existingIndexingSessions {
get => $this->getExistingIndexingSessions();
}
Expand All @@ -58,6 +59,7 @@ public function __construct(
private readonly Volumes $volumes,
) {}

/** @return Generator<int, FsListing> */
public function getIndexListOnVolume(Volume $volume, string $directory = ''): Generator
{
try {
Expand Down Expand Up @@ -109,7 +111,7 @@ public function getIndexListOnVolume(Volume $volume, string $directory = ''): Ge
}
}

/** @return Collection<IndexingSession> */
/** @return Collection<int, IndexingSession> */
public function getExistingIndexingSessions(): Collection
{
return AssetIndexingSessionModel::query()
Expand Down Expand Up @@ -467,6 +469,7 @@ public function getNextIndexEntry(IndexingSession $session): ?AssetIndexEntry
return $result ? new AssetIndexEntry((array) $result) : null;
}

/** @param array{inProgress?:bool, completed?:bool, recordId?:int, isSkipped?:bool, processedEntries?:int} $data */
public function updateIndexEntry(int $entryId, array $data): void
{
$data = array_intersect_key(
Expand Down
Loading
Loading