public static function dump( $data, int $deep = 10 ) {

    if( --$deep < 0 ) return '...';
    else if( !Collection::is( $data ) ) return $data;
    else {

      // handle custom classes
      $_data = Collection::copy( $data, false );
      if( is_object( $data ) && !( $data instanceof \StdClass ) ) try {
        if( \method_exists( $data, '__debugInfo'  ) ) $_data = $data->__debugInfo();
        else {

          $reflection = new \ReflectionClass( $data );
          $tmp        = [ '__CLASS__' => $reflection->getName() ];

          foreach( $reflection->getProperties() as $property ) {
            if( !$property->isStatic() ) {
              $property->setAccessible( true );

              $key                                = $property->isPrivate() ? '-' : ( $property->isProtected() ? '#' : '+' );
              $tmp[ $key . $property->getName() ] = $property->getValue( $data );
            }
          }

          $_data = $tmp;
        }

      } catch( \ReflectionException $_ ) {
        // can't do anything
      }

      //
      foreach( $_data as &$value ) $value = static::dump( $value, $deep );
      return $_data;
    }
  }
public static function dump( $data, int $deep = 10 ) {

    if( --$deep < 0 ) return '...';
    else if( !Collection::is( $data ) ) return $data;
    else {

      // handle custom classes
      $_data = Collection::copy( $data, false );
      if( is_object( $data ) && !( $data instanceof \StdClass ) ) try {
        if( \method_exists( $data, '__debugInfo'  ) ) $_data = $data->__debugInfo();
        else {

          $reflection = new \ReflectionClass( $data );
          $tmp        = [ '__CLASS__' => $reflection->getName() ];

          foreach( $reflection->getProperties() as $property ) {
            if( !$property->isStatic() ) {
              $property->setAccessible( true );

              $key                                = $property->isPrivate() ? '-' : ( $property->isProtected() ? '#' : '+' );
              $tmp[ $key . $property->getName() ] = $property->getValue( $data );
            }
          }

          $_data = $tmp;
        }

      } catch( \ReflectionException $_ ) {
        // can't do anything
      }

      //
      foreach( $_data as &$value ) $value = static::dump( $value, $deep );
      return $_data;
    }
  }
public static function dump ( $ data , int $ deep = 10 ) { if ( -- $ deep < 0 ) return '...' ; else if ( ! Collection :: is ( $ data ) ) return $ data ; else { // handle custom classes $ _data = Collection :: copy ( $ data , false ) ; if ( is_object ( $ data ) && ! ( $ data instanceof \ StdClass ) ) try { if ( \ method_exists ( $ data , '__debugInfo' ) ) $ _data = $ data -> __debugInfo ( ) ; else { $ reflection = new \ ReflectionClass ( $ data ) ; $ tmp = [ '__CLASS__' => $ reflection -> getName ( ) ] ; foreach ( $ reflection -> getProperties ( ) as $ property ) { if ( ! $ property -> isStatic ( ) ) { $ property -> setAccessible ( true ) ; $ key = $ property -> isPrivate ( ) ? '-' : ( $ property -> isProtected ( ) ? '#' : '+' ) ; $ tmp [ $ key . $ property -> getName ( ) ] = $ property -> getValue ( $ data ) ; } } $ _data = $ tmp ; } } catch ( \ ReflectionException $ _ ) { // can't do anything } // foreach ( $ _data as & $ value ) $ value = static :: dump ( $ value , $ deep ) ; return $ _data ; } }
Preprocess the data before log it

This will convert classes to array of properties with reflection

@param mixed $data
@param int   $deep Max process recursion

@return mixed
Preprocess the data before log it