Skip to content

Commit

Permalink
Narrow more array phpdocs to list (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Oct 26, 2024
1 parent 4e01d58 commit c1cd2aa
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ trait ConfigTrait
* json - JSON file with { 'foo': 'bar' } structure
* yaml - YAML file with yaml structure
*
* @param string|array<int, string> $files One or more filenames
* @param string $format Optional format for config files
* @param string|list<string> $files One or more filenames
* @param string $format Optional format for config files
*
* @return $this
*/
Expand Down
4 changes: 2 additions & 2 deletions src/DebugTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ trait DebugTrait
/** @var bool Is debug enabled? */
public $debug = false;

/** @var array<string, array<int, string>> Helps debugTraceChange. */
protected array $_previousTrace = [];
/** @var array<string, list<string>> */
private array $_previousTrace = [];

/**
* Outputs message to STDERR.
Expand Down
4 changes: 2 additions & 2 deletions src/DynamicMethodTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ trait DynamicMethodTrait
* Magic method - tries to call dynamic method and throws exception if
* this was not possible.
*
* @param string $name Name of the method
* @param array<int, mixed> $args Array of arguments to pass to this method
* @param string $name Name of the method
* @param list<mixed> $args Array of arguments to pass to this method
*
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ protected function _mergeSeeds(...$seeds)
}

/**
* @param class-string $className
* @param array<int, mixed> $ctorArgs
* @param class-string $className
* @param list<mixed> $ctorArgs
*/
protected function _newObject(string $className, array $ctorArgs): object
{
Expand Down
34 changes: 17 additions & 17 deletions src/HookTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

trait HookTrait
{
/** @var array<string, array<int, array<int, array{\Closure, 1?: array<int, mixed>}>>> Configured hooks (callbacks). */
/** @var array<string, array<int, array<int<0, max>, array{\Closure, list<mixed>}>>> Configured hooks (callbacks). */
protected array $hooks = [];

/** Next hook index counter. */
/** @var int<0, max> Next hook index counter. */
private int $_hookIndexCounter = 0;

/** @var \WeakReference<static>|null */
Expand Down Expand Up @@ -110,9 +110,9 @@ private function _rebindHooksIfCloned(): void
*
* If priority is negative, then hook is prepended (executed first for the same priority).
*
* @param array<int, mixed> $args
* @param list<mixed> $args
*
* @return int index under which the hook was added
* @return int<0, max> index under which the hook was added
*/
public function onHook(string $spot, \Closure $fx, array $args = [], int $priority = 5): int
{
Expand All @@ -134,9 +134,9 @@ public function onHook(string $spot, \Closure $fx, array $args = [], int $priori
/**
* Same as onHook() except no $this is passed to the callback as the 1st argument.
*
* @param array<int, mixed> $args
* @param list<mixed> $args
*
* @return int index under which the hook was added
* @return int<0, max> index under which the hook was added
*/
public function onHookShort(string $spot, \Closure $fx, array $args = [], int $priority = 5): int
{
Expand Down Expand Up @@ -196,9 +196,9 @@ private function _makeHookDynamicFx(?\Closure $getFxThisFx, \Closure $fx, bool $
* Same as onHook() except $this of the callback is dynamically rebound before invoke.
*
* @param \Closure($this): object $getFxThisFx
* @param array<int, mixed> $args
* @param list<mixed> $args
*
* @return int index under which the hook was added
* @return int<0, max> index under which the hook was added
*/
public function onHookDynamic(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
{
Expand All @@ -209,9 +209,9 @@ public function onHookDynamic(string $spot, \Closure $getFxThisFx, \Closure $fx,
* Same as onHookDynamic() except no $this is passed to the callback as the 1st argument.
*
* @param \Closure($this): object $getFxThisFx
* @param array<int, mixed> $args
* @param list<mixed> $args
*
* @return int index under which the hook was added
* @return int<0, max> index under which the hook was added
*/
public function onHookDynamicShort(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
{
Expand All @@ -221,8 +221,8 @@ public function onHookDynamicShort(string $spot, \Closure $getFxThisFx, \Closure
/**
* Returns true if at least one callback is defined for this hook.
*
* @param ($priorityIsIndex is true ? int : int|null) $priority filter specific priority, null for all
* @param bool $priorityIsIndex filter by index instead of priority
* @param ($priorityIsIndex is true ? int<0, max> : int|null) $priority filter specific priority, null for all
* @param bool $priorityIsIndex filter by index instead of priority
*/
public function hookHasCallbacks(string $spot, ?int $priority = null, bool $priorityIsIndex = false): bool
{
Expand Down Expand Up @@ -251,8 +251,8 @@ public function hookHasCallbacks(string $spot, ?int $priority = null, bool $prio
/**
* Delete all hooks for specified spot, priority and index.
*
* @param ($priorityIsIndex is true ? int : int|null) $priority filter specific priority, null for all
* @param bool $priorityIsIndex filter by index instead of priority
* @param ($priorityIsIndex is true ? int<0, max> : int|null) $priority filter specific priority, null for all
* @param bool $priorityIsIndex filter by index instead of priority
*
* @return static
*/
Expand Down Expand Up @@ -287,12 +287,12 @@ public function removeHook(string $spot, ?int $priority = null, bool $priorityIs
/**
* Execute all closures assigned to $spot.
*
* @param array<int, mixed> $args
* @param mixed $brokenBy
* @param list<mixed> $args
* @param mixed $brokenBy
*
* @param-out HookBreaker|null $brokenBy
*
* @return array<int, mixed>|mixed Array of responses indexed by hook indexes or value specified to breakHook
* @return array<int<0, max>, mixed>|mixed Array of responses indexed by hook indexes or value specified to breakHook
*/
public function hook(string $spot, array $args = [], &$brokenBy = null)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DebugTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class DebugAppMock implements LoggerInterface
{
use LoggerTrait;

/** @var array<int, mixed>|null */
/** @var array{mixed, string|\Stringable, array<mixed>}|null */
public $log;
/** @var self */
public $logger;
Expand Down
2 changes: 1 addition & 1 deletion tests/DiContainerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class FactoryDiMock2
{
use DiContainerTrait;

/** @var string|array<int, string> */
/** @var string|list<string> */
public $a = 'AAA';
/** @var string */
public $b = 'BBB';
Expand Down
2 changes: 1 addition & 1 deletion tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class FactoryTestMock
{
/** @var array<mixed> */
public $args;
/** @var int|string|array<int, string> */
/** @var int|string|list<string> */
public $foo;
/** @var int|string */
public $baz = 0;
Expand Down

0 comments on commit c1cd2aa

Please sign in to comment.