public function maybeSerialize($value, bool $strict = true): string
    {
        if (!$strict) {
            if (is_string($value)) {
                return $string = $value;
            } elseif (is_bool($value)) {
                return $string = (string) (int) $value;
            } elseif (is_int($value) || is_float($value)) {
                return $string = (string) $value;
            } else { // Serialize.
                return $string = $this->__invoke($value);
            }
        } else { // Default.
            if (is_string($value)) {
                return $string = $value;
            } else { // Serialize.
                return $string = $this->__invoke($value);
            }
        }
    }
public function maybeSerialize($value, bool $strict = true): string
    {
        if (!$strict) {
            if (is_string($value)) {
                return $string = $value;
            } elseif (is_bool($value)) {
                return $string = (string) (int) $value;
            } elseif (is_int($value) || is_float($value)) {
                return $string = (string) $value;
            } else { // Serialize.
                return $string = $this->__invoke($value);
            }
        } else { // Default.
            if (is_string($value)) {
                return $string = $value;
            } else { // Serialize.
                return $string = $this->__invoke($value);
            }
        }
    }
public function maybeSerialize ( $ value , bool $ strict = true ) : string { if ( ! $ strict ) { if ( is_string ( $ value ) ) { return $ string = $ value ; } elseif ( is_bool ( $ value ) ) { return $ string = ( string ) ( int ) $ value ; } elseif ( is_int ( $ value ) || is_float ( $ value ) ) { return $ string = ( string ) $ value ; } else { // Serialize. return $ string = $ this -> __invoke ( $ value ) ; } } else { // Default. if ( is_string ( $ value ) ) { return $ string = $ value ; } else { // Serialize. return $ string = $ this -> __invoke ( $ value ) ; } } }
Maybe serialize value.

@since 150424 Serializer.
@since 170824.30708 `$strict` param (= true).

@param mixed $value  Value to serialize.
@param bool  $strict Enable strict types?

@return string A string (possibly serialized).
Maybe serialize value .