From 50ff094b4765715e25c95a2f2bbba39843c56ec6 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 11 Nov 2019 20:37:15 +0300 Subject: [PATCH] refactor(core): Parser API's refactoring #288 --- flextype/parsers/Markdown.php | 5 ++--- flextype/parsers/Yaml.php | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/flextype/parsers/Markdown.php b/flextype/parsers/Markdown.php index 3f98188c..5603254a 100644 --- a/flextype/parsers/Markdown.php +++ b/flextype/parsers/Markdown.php @@ -15,7 +15,6 @@ use ParsedownExtra; class Markdown { - /** * Markdown Object * @@ -31,9 +30,9 @@ class Markdown * * @return mixed The MARKDOWN converted to a PHP value */ - public static function decode($input) : string + public static function decode(string $input) : string { - !isset(self::$markdown) and self::$markdown = new ParsedownExtra(); + ! isset(self::$markdown) and self::$markdown = new ParsedownExtra(); return self::$markdown->text($input); } diff --git a/flextype/parsers/Yaml.php b/flextype/parsers/Yaml.php index 9c3ab75f..f12f167d 100644 --- a/flextype/parsers/Yaml.php +++ b/flextype/parsers/Yaml.php @@ -21,17 +21,17 @@ use function ini_set; class Yaml { - const DUMP_OBJECT = 1; - const PARSE_EXCEPTION_ON_INVALID_TYPE = 2; - const PARSE_OBJECT = 4; - const PARSE_OBJECT_FOR_MAP = 8; - const DUMP_EXCEPTION_ON_INVALID_TYPE = 16; - const PARSE_DATETIME = 32; - const DUMP_OBJECT_AS_MAP = 64; - const DUMP_MULTI_LINE_LITERAL_BLOCK = 128; - const PARSE_CONSTANT = 256; - const PARSE_CUSTOM_TAGS = 512; - const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024; + public const DUMP_OBJECT = 1; + public const PARSE_EXCEPTION_ON_INVALID_TYPE = 2; + public const PARSE_OBJECT = 4; + public const PARSE_OBJECT_FOR_MAP = 8; + public const DUMP_EXCEPTION_ON_INVALID_TYPE = 16; + public const PARSE_DATETIME = 32; + public const DUMP_OBJECT_AS_MAP = 64; + public const DUMP_MULTI_LINE_LITERAL_BLOCK = 128; + public const PARSE_CONSTANT = 256; + public const PARSE_CUSTOM_TAGS = 512; + public const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024; /** * Inline @@ -105,7 +105,7 @@ class Yaml public static function decode(string $input) : array { // Try native PECL YAML PHP extension first if available. - if (\function_exists('yaml_parse') && self::$native) { + if (function_exists('yaml_parse') && self::$native) { // Safely decode YAML. $saved = @ini_get('yaml.decode_php'); @ini_set('yaml.decode_php', '0');