Skip to content

Conversation

@Mdsujansarkar
Copy link

Missing docblock add

    /**
     * Get an array item from an array using "dot" notation.
     *
     * @return array
     *
     * @throws \InvalidArgumentException
     */
    public static function array(ArrayAccess|array $array, string|int|null $key, ?array $default = null)
    {
        $value = Arr::get($array, $key, $default);

        if (! is_array($value)) {
            throw new InvalidArgumentException(
                sprintf('Array value for key [%s] must be an array, %s found.', $key, gettype($value))
            );
        }

        return $value;
    }

to

    /**
     * Get an array item from an array using "dot" notation.
     *
     * @param  \ArrayAccess|array  $array
     * @param  string|int|null  $key
     * @param  array|null  $default
     * @return array
     *
     * @throws \InvalidArgumentException
     */
    public static function array(ArrayAccess|array $array, string|int|null $key, ?array $default = null)
    {
        $value = Arr::get($array, $key, $default);

        if (! is_array($value)) {
            throw new InvalidArgumentException(
                sprintf('Array value for key [%s] must be an array, %s found.', $key, gettype($value))
            );
        }

        return $value;
    }

Comment on lines +67 to 70
* @param \ArrayAccess|array $array
* @param string|int|null $key
* @param array|null $default
* @return array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could improve this a bit:

Suggested change
* @param \ArrayAccess|array $array
* @param string|int|null $key
* @param array|null $default
* @return array
* @template TKey of string|int
*
* @param \ArrayAccess|array<TKey, array> $array
* @param TKey|null $key
* @param array|null $default
* @return array

making the array generic as well probably doesn't help here:

Suggested change
* @param \ArrayAccess|array $array
* @param string|int|null $key
* @param array|null $default
* @return array
* @template TKey of string|int
* @template TReturn of array
*
* @param \ArrayAccess|array<TKey, TReturn> $array
* @param TKey|null $key
* @param TReturn|null $default
* @return TReturn

Copy link
Contributor

@shaedrich shaedrich Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, the way it is now, you merely duplicated the PHPDoc block. This wouldn't be very helpful on its own and would work against efforts like #57219 and #56775

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Close my PR.

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants