diff --git a/README.md b/README.md index 9605985c..8b92c084 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest Stable Version](https://poser.pugx.org/raml-org/raml-php-parser/version)](https://packagist.org/packages/raml-org/raml-php-parser) [![Total Downloads](https://poser.pugx.org/raml-org/raml-php-parser/downloads)](https://packagist.org/packages/raml-org/raml-php-parser) -See the RAML spec here: https://github.com/raml-org/raml-spec +See the [RAML specification](https://github.com/raml-org/raml-spec). ## RAML 0.8 Support For RAML 0.8 support follow version 2. diff --git a/src/NamedParameter.php b/src/NamedParameter.php index 27a35247..3220bc44 100644 --- a/src/NamedParameter.php +++ b/src/NamedParameter.php @@ -907,8 +907,7 @@ public function getMatchPattern() break; case self::TYPE_DATE: - // @see https://snipt.net/DamienGarrido/ - // http-date-regular-expression-validation-rfc-1123rfc-850asctime-f64e6aa3/ + // @see https://snipt.net/DamienGarrido/http-date-regular-expression-validation-rfc-1123rfc-850asctime-f64e6aa3/ $pattern = '^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) ' . '(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} ' . '(?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] ' . diff --git a/src/Types/DatetimeType.php b/src/Types/DatetimeType.php index dd31335f..67ac96a2 100644 --- a/src/Types/DatetimeType.php +++ b/src/Types/DatetimeType.php @@ -11,6 +11,7 @@ class DatetimeType extends Type { const DEFAULT_FORMAT = DATE_RFC3339; + /** * DateTime format to use * @@ -23,7 +24,6 @@ class DatetimeType extends Type * * @param string $name * @param array $data - * * @return DatetimeType */ public static function createFromArray($name, array $data = []) diff --git a/src/Types/StringType.php b/src/Types/StringType.php index 114687fa..4675b3f8 100644 --- a/src/Types/StringType.php +++ b/src/Types/StringType.php @@ -145,6 +145,8 @@ public function validate($value) if (!is_string($value)) { $this->errors[] = TypeValidationError::unexpectedValueType($this->getName(), 'string', $value); + + return; } if (null !== $this->pattern) { $pregMatchResult = preg_match('/' . $this->pattern . '/', $value); diff --git a/src/Types/TimeOnlyType.php b/src/Types/TimeOnlyType.php index 5d006f51..a00617b1 100644 --- a/src/Types/TimeOnlyType.php +++ b/src/Types/TimeOnlyType.php @@ -15,9 +15,8 @@ class TimeOnlyType extends Type /** * Create a new TimeOnlyType from an array of data * - * @param string $name - * @param array $data - * + * @param string $name + * @param array $data * @return TimeOnlyType */ public static function createFromArray($name, array $data = []) diff --git a/tests/NamedParameters/ParameterTypesTest.php b/tests/NamedParameters/ParameterTypesTest.php index 373bf3fe..a8ffa4b3 100644 --- a/tests/NamedParameters/ParameterTypesTest.php +++ b/tests/NamedParameters/ParameterTypesTest.php @@ -248,7 +248,9 @@ public function shouldValidateDate() $namedParameter->validate('Sun, 06 Nov 1994 08:49:37 BUNS'); } - /** @test */ + /** + * @test + */ public function shouldValidateDateOnly() { $this->expectException('\Raml\Exception\ValidationException', 'Expected date-only'); @@ -256,7 +258,9 @@ public function shouldValidateDateOnly() $namedParameter->validate('2018-08-05T13:24:55'); } - /** @test */ + /** + * @test + */ public function shouldValidateDateTimeOnly() { $this->expectException('\Raml\Exception\ValidationException', 'Expected datetime-only'); @@ -264,7 +268,9 @@ public function shouldValidateDateTimeOnly() $namedParameter->validate('2018-08-05T13:24:55+12:00'); } - /** @test */ + /** + * @test + */ public function shouldValidateTimeOnly() { $this->expectException('\Raml\Exception\ValidationException', 'Expected time-only'); @@ -272,7 +278,9 @@ public function shouldValidateTimeOnly() $namedParameter->validate('2018-08-05T13:24:55'); } - /** @test */ + /** + * @test + */ public function shouldValidateDateTime() { $this->expectException('\Raml\Exception\ValidationException', 'Expected datetime'); @@ -280,7 +288,9 @@ public function shouldValidateDateTime() $namedParameter->validate('2018-08-05 13:24:55'); } - /** @test */ + /** + * @test + */ public function shouldValidateDateTimeFormat() { $this->expectException('\Raml\Exception\ValidationException', 'Expected datetime with format Y-m-d H:i:s'); @@ -290,8 +300,6 @@ public function shouldValidateDateTimeFormat() // --- - /** @test */ - /** * @test */