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;
    }
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;
    }
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 ; }
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
try to create a new field object based on the given value .