src/Component/Json.php
/**
     * Finds a specific element using $index and calls a function on it.
     *
     * @param ?callable $function It accepts the following argument(s):
     * 1. The element's value; might be gotten by-reference.
     * 2. The parent element (that is an array); might be gotten by-reference.
     * 3. The last key in the index; might be used to access the element (using the parent element).
     * From within the callable, you can yield as many values as you want, and/or return a value.
     * The return type of the method will be exactly the return type of this callable. Note that if
     * $index is null, the first argument will be the only passing argument.
     * @param ?string|int $index The index of the element to be found, and it's extracted as keys.
     * Pass null if you want to get the data root inside the callback.
     * @param bool $forceCountableValue Force the value be operated to be a countable one, so, the
     * element (i.e. first argument) passing to $function will be an array.
     * @param int $indexingType One of the Indexing::* constants.
     * @param int $options A combination of DoOpt::* constants.
     * @return mixed The return value of $function, whether is a generator or not.F
     * @throws Exception When reaching a key that does not exist and $strictIndexing is true.
     * @throws UncountableValueException If reaching a key that contains an uncountable value.
     * @throws UncountableValueException When reaching an uncountable element and
     * $forceCountableValue is set to true.
     * @throws UncountableValueException If data is scalar and $forceCountableValue is set to true.
     * @todo Remove the at sign operator.
     */
Finds a specific element using $index and calls a function on it.
@param ?callable $function It accepts the following argument(s):
1. The element's value; might be gotten by-reference.
2. The parent element (that is an array); might be gotten by-reference.
3. The last key in the index; might be used to access the element (using the parent element).
From within the callable, you can yield as many values as you want, and/or return a value.
The return type of the method will be exactly the return type of this callable. Note that if
$index is null, the first argument will be the only passing argument.
@param ?string|int $index The index of the element to be found, and it's extracted as keys.
Pass null if you want to get the data root inside the callback.
@param bool $forceCountableValue Force the value be operated to be a countable one, so, the
element  passing to $function will be an array.
@param int $indexingType One of the Indexing::* constants.
@param int $options A combination of DoOpt::* constants.
@return mixed The return value of $function, whether is a generator or not.F
@throws Exception When reaching a key that does not exist and $strictIndexing is true.
@throws UncountableValueException If reaching a key that contains an uncountable value.
@throws UncountableValueException When reaching an uncountable element and
$forceCountableValue is set to true.
@throws UncountableValueException If data is scalar and $forceCountableValue is set to true.
@todo Remove the at sign operator.
Finds a specific element using $index and calls a function on it . @param ?callable $function It accepts the following argument ( s ) : 1 . The element ' s value ; might be gotten by - reference . 2 . The parent element ( that is an array ) ; might be gotten by - reference . 3 . The last key in the index ; might be used to access the element ( using the parent element ) . From within the callable you can yield as many values as you want and / or return a value . The return type of the method will be exactly the return type of this callable . Note that if $index is null the first argument will be the only passing argument . @param ?string|int $index The index of the element to be found and it ' s extracted as keys . Pass null if you want to get the data root inside the callback . @param bool $forceCountableValue Force the value be operated to be a countable one so the element passing to $function will be an array . @param int $indexingType One of the Indexing :: * constants . @param int $options A combination of DoOpt :: * constants . @return mixed The return value of $function whether is a generator or not . F @throws Exception When reaching a key that does not exist and $strictIndexing is true . @throws UncountableValueException If reaching a key that contains an uncountable value . @throws UncountableValueException When reaching an uncountable element and $forceCountableValue is set to true . @throws UncountableValueException If data is scalar and $forceCountableValue is set to true . @todo Remove the at sign operator .
public function &do(
        callable $function = null,
        $index = null,
        bool $forceCountableValue = false,
        int $indexingType = Indexing::STRICT,
        int $options = 0
    ) {
        $data = &$this->data;
        if (is_object($data)) {
            $data = (array)($data);
        }
        if (self::isScalar($data) && $index !== null) {
            throw new UncountableValueException("Cannot use indexing on uncountable");
        }
        $keepIndex = $options & (bool)(DoOpt::KEEP_INDEX);
        @$returnValueReference = &$function(...$this->findElementRecursive(
            $keepIndex ? (array)($index) : $this->extractIndex($index),
            $data,
            $forceCountableValue,
            $indexingType
        ));
        return $returnValueReference;
    }
public function & do ( callable $ function = null , $ index = null , bool $ forceCountableValue = false , int $ indexingType = Indexing :: STRICT , int $ options = 0 ) { $ data = & $ this -> data ; if ( is_object ( $ data ) ) { $ data = ( array ) ( $ data ) ; } if ( self :: isScalar ( $ data ) && $ index !== null ) { throw new UncountableValueException ( " Cannot use indexing on uncountable " ) ; } $ keepIndex = $ options & ( bool ) ( DoOpt :: KEEP_INDEX ) ; @ $ returnValueReference = & $ function ( ... $ this -> findElementRecursive ( $ keepIndex ? ( array ) ( $ index ) : $ this -> extractIndex ( $ index ) , $ data , $ forceCountableValue , $ indexingType ) ) ; return $ returnValueReference ; }
Finds a specific element using $index and calls a function on it.
Finds a specific element using $index and calls a function on it .
// Set options // On debugging, pay attention to the following @ operator!