Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ function lang(string $line, array $args = [], ?string $locale = null)
* - notice
* - info
* - debug
*
* @param array<string, mixed> $context
*/
function log_message(string $level, string $message, array $context = []): void
{
Expand Down Expand Up @@ -861,7 +863,7 @@ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn
* @param string|null $default
* @param 'attr'|'css'|'html'|'js'|'raw'|'url'|false $escape
*
* @return array|string|null
* @return array<array-key, mixed>|string|null
*/
function old(string $key, $default = null, $escape = 'html')
{
Expand Down Expand Up @@ -1185,7 +1187,7 @@ function slash_item(string $item): ?string
* Helper function used to convert a string, array, or object
* of attributes to a string.
*
* @param array|object|string $attributes string, array, object that can be cast to array
* @param array<array-key, mixed>|object|string $attributes
*/
function stringify_attributes($attributes, bool $js = false): string
{
Expand Down Expand Up @@ -1252,7 +1254,8 @@ function timer(?string $name = null, ?callable $callable = null)
* NOTE: Does not provide any escaping of the data, so that must
* all be handled manually by the developer.
*
* @param array $options Options for saveData or third-party extensions.
* @param array<string, mixed> $data
* @param array<string, mixed> $options Options for saveData or third-party extensions.
*/
function view(string $name, array $data = [], array $options = []): string
{
Expand All @@ -1275,7 +1278,7 @@ function view(string $name, array $data = [], array $options = []): string
* View cells are used within views to insert HTML chunks that are managed
* by other classes.
*
* @param array|string|null $params
* @param array<array-key, mixed>|string|null $params
*
* @throws ReflectionException
*/
Expand Down
15 changes: 8 additions & 7 deletions system/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ protected function cachePage(int $time)
/**
* A shortcut to performing validation on Request data.
*
* @param array|string $rules
* @param array $messages An array of custom error messages
* @param array<array-key, mixed>|string $rules
* @param array<string, array<string, string>|string> $messages An array of custom error messages
*/
protected function validate($rules, array $messages = []): bool
{
Expand All @@ -139,10 +139,10 @@ protected function validate($rules, array $messages = []): bool
/**
* A shortcut to performing validation on any input data.
*
* @param array $data The data to validate
* @param array|string $rules
* @param array $messages An array of custom error messages
* @param string|null $dbGroup The database group to use
* @param array<array-key, mixed> $data The data to validate
* @param array<array-key, mixed>|string $rules
* @param array<string, array<string, string>|string> $messages An array of custom error messages
* @param string|null $dbGroup The database group to use
*/
protected function validateData(array $data, $rules, array $messages = [], ?string $dbGroup = null): bool
{
Expand All @@ -152,7 +152,8 @@ protected function validateData(array $data, $rules, array $messages = [], ?stri
}

/**
* @param array|string $rules
* @param array<array-key, mixed>|string $rules
* @param array<string, array<string, string>|string> $messages
*/
private function setValidator($rules, array $messages): void
{
Expand Down
2 changes: 2 additions & 0 deletions system/Cookie/CookieStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public function getIterator(): Traversable
/**
* Validates all cookies passed to be instances of Cookie.
*
* @param array<array-key, Cookie> $cookies
*
* @throws CookieException
*/
protected function validateCookies(array $cookies): void
Expand Down
2 changes: 2 additions & 0 deletions system/Exceptions/PageNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static function forLocaleNotSupported(string $locale)
* have the current locale, so even if users call
* `$this->request->setLocale()` in the controller afterwards,
* the Language locale will not be changed.
*
* @param array<array-key, float|int|string> $args
*/
private static function lang(string $line, array $args = []): string
{
Expand Down
2 changes: 2 additions & 0 deletions system/HotReloader/DirectoryHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function hash(): string
/**
* Generates an array of md5 hashes for all directories that are
* watched by the Hot Reloader, as defined in the Config\Toolbar.
*
* @return array<string, string>
*/
public function hashApp(): array
{
Expand Down
2 changes: 2 additions & 0 deletions system/HotReloader/HotReloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function run(): void

/**
* Send an event to the browser.
*
* @param array<string, string> $data
*/
private function sendEvent(string $event, array $data): void
{
Expand Down
3 changes: 3 additions & 0 deletions system/HotReloader/IteratorFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
final class IteratorFilter extends RecursiveFilterIterator implements RecursiveIterator
{
/**
* @var list<string>
*/
private array $watchedExtensions = [];

public function __construct(RecursiveIterator $iterator)
Expand Down
6 changes: 6 additions & 0 deletions system/Images/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ public function fit(int $width, ?int $height = null, string $position = 'center'
* @param float|int|null $height
* @param float|int $origWidth
* @param float|int $origHeight
*
* @return array{0: float|int, 1: float|int}
*/
protected function calcAspectRatio($width, $height = null, $origWidth = 0, $origHeight = 0): array
{
Expand Down Expand Up @@ -593,6 +595,8 @@ protected function calcAspectRatio($width, $height = null, $origWidth = 0, $orig
* @param float|int $origWidth
* @param float|int $origHeight
* @param string $position
*
* @return array{0: float|int, 1: float|int}
*/
protected function calcCropCoords($width, $height, $origWidth, $origHeight, $position): array
{
Expand Down Expand Up @@ -684,6 +688,8 @@ abstract protected function process(string $action);
* Provide access to the Image class' methods if they don't exist
* on the handler itself.
*
* @param list<mixed> $args
*
* @return mixed
*/
public function __call(string $name, array $args = [])
Expand Down
2 changes: 1 addition & 1 deletion system/Images/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function copy(string $targetPath, ?string $targetName = null, int $perms
*
* A helper function that gets info about the file
*
* @return array|bool
* @return array{width: int, height: int, image_type: int, size_str: string, mime_type: string}|bool
*/
public function getProperties(bool $return = false)
{
Expand Down
3 changes: 3 additions & 0 deletions system/Modules/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function shouldDiscover(string $alias): bool
return in_array(strtolower($alias), $this->aliases, true);
}

/**
* @param array<string, mixed> $array
*/
public static function __set_state(array $array)
{
$obj = new static();
Expand Down
25 changes: 15 additions & 10 deletions system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,23 @@ class Pager implements PagerInterface
/**
* The group data.
*
* @var array
* @var array<string, array{
* currentUri: URI,
* uri: URI,
* hasMore: bool,
* total: int|null,
* perPage: int,
* pageCount: int,
* pageSelector: string,
* currentPage: int
* }>
*/
protected $groups = [];

/**
* URI segment for groups if provided.
*
* @var array
* @var array<string, int>
*/
protected $segment = [];

Expand Down Expand Up @@ -272,7 +281,7 @@ public function getPageURI(?int $page = null, string $group = 'default', bool $r

$segment = $this->segment[$group] ?? 0;

if ($segment) {
if ($segment !== 0) {
$uri->setSegment($segment, $page);
} else {
$uri->addQuery($this->groups[$group]['pageSelector'], $page);
Expand All @@ -281,7 +290,7 @@ public function getPageURI(?int $page = null, string $group = 'default', bool $r
if ($this->only !== null) {
$query = array_intersect_key(service('superglobals')->getGetArray(), array_flip($this->only));

if (! $segment) {
if ($segment === 0) {
$query[$this->groups[$group]['pageSelector']] = $page;
}

Expand Down Expand Up @@ -357,12 +366,6 @@ public function getPerPage(string $group = 'default'): int
return (int) $this->groups[$group]['perPage'];
}

/**
* Returns an array with details about the results, including
* total, per_page, current_page, last_page, next_url, prev_url, from, to.
* Does not include the actual data. This data is suitable for adding
* a 'data' object to with the result set and converting to JSON.
*/
public function getDetails(string $group = 'default'): array
{
if (! array_key_exists($group, $this->groups)) {
Expand All @@ -380,6 +383,8 @@ public function getDetails(string $group = 'default'): array

/**
* Sets only allowed queries on pagination links.
*
* @param list<string> $queries
*/
public function only(array $queries): self
{
Expand Down
14 changes: 14 additions & 0 deletions system/Pager/PagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ public function getPerPage(string $group = 'default'): int;
* total, per_page, current_page, last_page, next_url, prev_url, from, to.
* Does not include the actual data. This data is suitable for adding
* a 'data' object to with the result set and converting to JSON.
*
* @return array{
* currentUri: URI,
* uri: URI,
* hasMore: bool,
* total: int|null,
* perPage: int,
* pageCount: int,
* pageSelector: string,
* currentPage: int,
* next: string|null,
* previous: string|null,
* segment: int
* }
*/
public function getDetails(string $group = 'default'): array;
}
11 changes: 10 additions & 1 deletion system/Pager/PagerRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ class PagerRenderer
protected ?int $perPageEnd = null;

/**
* Constructor.
* @param array{
* uri: URI,
* pageCount: int,
* currentPage: int,
* total: int|null,
* segment?: int,
* pageSelector?: string,
* perPage?: int|null,
* ...<string, mixed>
* } $details
*/
public function __construct(array $details)
{
Expand Down
2 changes: 1 addition & 1 deletion system/Publisher/ContentReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ContentReplacer
/**
* Replace content
*
* @param array $replaces [search => replace]
* @param array<string, string> $replaces [search => replace]
*/
public function replace(string $content, array $replaces): string
{
Expand Down
2 changes: 1 addition & 1 deletion system/Publisher/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ final public function merge(bool $replace = true): bool
/**
* Replace content
*
* @param array $replaces [search => replace]
* @param array<string, string> $replaces [search => replace]
*/
public function replace(string $file, array $replaces): bool
{
Expand Down
4 changes: 3 additions & 1 deletion system/Typography/Typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Typography
/**
* array of block level elements that require inner content to be within another block level element
*
* @var array
* @var list<string>
*/
public $innerBlockRequired = ['blockquote'];

Expand Down Expand Up @@ -316,6 +316,8 @@ protected function formatNewLines(string $str): string
* We don't want quotes converted within tags so we'll temporarily convert them to {@DQ} and {@SQ}
* and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
* likewise double spaces are converted to {@NBS} to prevent entity conversion
*
* @param array<int|string, string> $match
*/
protected function protectCharacters(array $match): string
{
Expand Down
18 changes: 9 additions & 9 deletions system/View/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public function __construct(CacheInterface $cache)
/**
* Render a cell, returning its body as a string.
*
* @param string $library Cell class and method name.
* @param array<string, string>|string|null $params Parameters to pass to the method.
* @param int $ttl Number of seconds to cache the cell.
* @param string|null $cacheName Cache item name.
* @param string $library Cell class and method name.
* @param array<array-key, mixed>|string|null $params Parameters to pass to the method.
* @param int $ttl Number of seconds to cache the cell.
* @param string|null $cacheName Cache item name.
*
* @throws ReflectionException
*/
Expand Down Expand Up @@ -116,9 +116,9 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c
* If a string, it should be in the format "key1=value key2=value".
* It will be split and returned as an array.
*
* @param array<string, string>|float|string|null $params
* @param array<array-key, mixed>|float|string|null $params
*
* @return array<string, string>
* @return array<array-key, mixed>
*/
public function prepareParams($params)
{
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function determineClass(string $library): array
/**
* Renders a cell that extends the BaseCell class.
*
* @param array<string, mixed> $params
* @param array<array-key, mixed> $params
*/
final protected function renderCell(BaseCell $instance, string $method, array $params): string
{
Expand Down Expand Up @@ -237,7 +237,7 @@ final protected function renderCell(BaseCell $instance, string $method, array $p
* for a method, in the order they are defined. This allows
* them to be passed directly into the method.
*
* @param array<string, mixed> $params
* @param array<array-key, mixed> $params
*
* @return list<mixed>
*/
Expand Down Expand Up @@ -268,7 +268,7 @@ private function getMethodParams(BaseCell $instance, string $method, array $para
*
* @todo Determine if this can be refactored to use $this-getMethodParams().
*
* @param array<string, mixed> $params
* @param array<array-key, mixed> $params
*/
final protected function renderSimpleClass(object $instance, string $method, array $params, string $class): string
{
Expand Down
10 changes: 6 additions & 4 deletions tests/system/CLI/CLITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,20 @@ private function captureGenerateDimensionsStderr(?array $env = null): string
}

/**
* @param array $tbody
* @param array $thead
* @param array $expected
* @param list<array<array-key, mixed>> $tbody
* @param list<string> $thead
*/
#[DataProvider('provideTable')]
public function testTable($tbody, $thead, $expected): void
public function testTable(array $tbody, array $thead, string $expected): void
{
CLI::table($tbody, $thead);

$this->assertSame($this->getStreamFilterBuffer(), $expected);
}

/**
* @return iterable<int, array{list<array<array-key, mixed>>, list<string>, string}>
*/
public static function provideTable(): iterable
{
$head = [
Expand Down
Loading
Loading