original_string: public static function infer($val, $descriptor = null, $lenient = false)
      {
          $field = new static($descriptor);
          try {
              $field->castValue($val);
          } catch (FieldValidationException $e) {
              return false;
          }
          $field->inferProperties($val, $lenient);
  
          return $field;
      }
code: public static function infer($val, $descriptor = null, $lenient = false)
      {
          $field = new static($descriptor);
          try {
              $field->castValue($val);
          } catch (FieldValidationException $e) {
              return false;
          }
          $field->inferProperties($val, $lenient);
  
          return $field;
      }
code_tokens: public static function infer ( $ val , $ descriptor = null , $ lenient = false ) { $ field = new static ( $ descriptor ) ; try { $ field -> castValue ( $ val ) ; } catch ( FieldValidationException $ e ) { return false ; } $ field -> inferProperties ( $ val , $ lenient ) ; return $ field ; }
docstring: try to create a new field object based on the given value.
  
  @param mixed       $val
  @param null|object $descriptor
  @param bool @lenient
  
  @return bool|BaseField
docstring_tokens: try to create a new field object based on the given value .