src/Cli/CommandLine.php
public function cast($value, $type, $array = false)
    {
        if (is_array($value)) {
            $result = [];
            foreach ($value as $key => $item) {
                $result[$key] = $this->cast($item, $type);
            }
            return $result;
        }
        if ($type === 'boolean') {
            $value = ($value === 'false' || $value === '0' || $value === false || $value === null) ? false : true;
        } elseif ($type === 'numeric') {
            $value = $value !== null ? (int) $value + 0 : 1;
        } elseif ($type === 'string') {
            $value = ($value !== true && $value !== null) ? (string) $value : null;
        }
        if ($array) {
            return $value ? (array) $value : [];
        }
        return $value;
    }
public function cast($value, $type, $array = false)
    {
        if (is_array($value)) {
            $result = [];
            foreach ($value as $key => $item) {
                $result[$key] = $this->cast($item, $type);
            }
            return $result;
        }
        if ($type === 'boolean') {
            $value = ($value === 'false' || $value === '0' || $value === false || $value === null) ? false : true;
        } elseif ($type === 'numeric') {
            $value = $value !== null ? (int) $value + 0 : 1;
        } elseif ($type === 'string') {
            $value = ($value !== true && $value !== null) ? (string) $value : null;
        }
        if ($array) {
            return $value ? (array) $value : [];
        }
        return $value;
    }
public function cast ( $ value , $ type , $ array = false ) { if ( is_array ( $ value ) ) { $ result = [ ] ; foreach ( $ value as $ key => $ item ) { $ result [ $ key ] = $ this -> cast ( $ item , $ type ) ; } return $ result ; } if ( $ type === 'boolean' ) { $ value = ( $ value === 'false' || $ value === '0' || $ value === false || $ value === null ) ? false : true ; } elseif ( $ type === 'numeric' ) { $ value = $ value !== null ? ( int ) $ value + 0 : 1 ; } elseif ( $ type === 'string' ) { $ value = ( $ value !== true && $ value !== null ) ? ( string ) $ value : null ; } if ( $ array ) { return $ value ? ( array ) $ value : [ ] ; } return $ value ; }
Casts a value according to the option attributes.

@param  string  $value The value to cast.
@param  string  $type  The type of the value.
@param  boolean $array If `true`, the argument value is considered to be an array.
@return array          The casted value.
Casts a value according to the option attributes .