original_string: protected function typecast($argument, $toString = true, $nested = false, $depth = 4)
      {
          if ($nested) {
              $depth--;
              if ($argument instanceof PheryResponse) {
                  $argument = array('PR' => $argument->process_merged());
              } elseif ($argument instanceof PheryFunction) {
                  $argument = array('PF' => $argument->compile());
              } elseif ($depth > 0 && is_array($argument)) {
                  foreach ($argument as $name => $arg) {
                      $argument[$name] = $this->typecast($arg, $toString, $nested, $depth);
                  }
              }
          }
  
          if ($toString && !empty($argument)) {
              if (is_string($argument) && ctype_digit($argument)) {
                  if ($this->config['convert_integers'] === true) {
                      $argument = (int)$argument;
                  }
              } elseif (is_object($argument) && $this->config['typecast_objects'] === true) {
                  $class = get_class($argument);
                  if ($class !== false) {
                      $rc = new ReflectionClass(get_class($argument));
                      if ($rc->hasMethod('__toString')) {
                          $argument = "{$argument}";
                      } else {
                          $argument = json_decode(json_encode($argument), true);
                      }
                  } else {
                      $argument = json_decode(json_encode($argument), true);
                  }
              }
          }
  
          return $argument;
      }
code: protected function typecast($argument, $toString = true, $nested = false, $depth = 4)
      {
          if ($nested) {
              $depth--;
              if ($argument instanceof PheryResponse) {
                  $argument = array('PR' => $argument->process_merged());
              } elseif ($argument instanceof PheryFunction) {
                  $argument = array('PF' => $argument->compile());
              } elseif ($depth > 0 && is_array($argument)) {
                  foreach ($argument as $name => $arg) {
                      $argument[$name] = $this->typecast($arg, $toString, $nested, $depth);
                  }
              }
          }
  
          if ($toString && !empty($argument)) {
              if (is_string($argument) && ctype_digit($argument)) {
                  if ($this->config['convert_integers'] === true) {
                      $argument = (int)$argument;
                  }
              } elseif (is_object($argument) && $this->config['typecast_objects'] === true) {
                  $class = get_class($argument);
                  if ($class !== false) {
                      $rc = new ReflectionClass(get_class($argument));
                      if ($rc->hasMethod('__toString')) {
                          $argument = "{$argument}";
                      } else {
                          $argument = json_decode(json_encode($argument), true);
                      }
                  } else {
                      $argument = json_decode(json_encode($argument), true);
                  }
              }
          }
  
          return $argument;
      }
code_tokens: protected function typecast ( $ argument , $ toString = true , $ nested = false , $ depth = 4 ) { if ( $ nested ) { $ depth -- ; if ( $ argument instanceof PheryResponse ) { $ argument = array ( 'PR' => $ argument -> process_merged ( ) ) ; } elseif ( $ argument instanceof PheryFunction ) { $ argument = array ( 'PF' => $ argument -> compile ( ) ) ; } elseif ( $ depth > 0 && is_array ( $ argument ) ) { foreach ( $ argument as $ name => $ arg ) { $ argument [ $ name ] = $ this -> typecast ( $ arg , $ toString , $ nested , $ depth ) ; } } } if ( $ toString && ! empty ( $ argument ) ) { if ( is_string ( $ argument ) && ctype_digit ( $ argument ) ) { if ( $ this -> config [ 'convert_integers' ] === true ) { $ argument = ( int ) $ argument ; } } elseif ( is_object ( $ argument ) && $ this -> config [ 'typecast_objects' ] === true ) { $ class = get_class ( $ argument ) ; if ( $ class !== false ) { $ rc = new ReflectionClass ( get_class ( $ argument ) ) ; if ( $ rc -> hasMethod ( '__toString' ) ) { $ argument = "{$argument}" ; } else { $ argument = json_decode ( json_encode ( $ argument ) , true ) ; } } else { $ argument = json_decode ( json_encode ( $ argument ) , true ) ; } } } return $ argument ; }
docstring: Convert, to a maximum depth, nested responses, and typecast int properly
  
  @param mixed $argument The value
  @param bool $toString Call class __toString() if possible, and typecast int correctly
  @param bool $nested Should it look for nested arrays and classes?
  @param int $depth Max depth
  @return mixed
docstring_tokens: Convert to a maximum depth nested responses and typecast int properly