1 | <?php |
||
13 | class Parser |
||
14 | { |
||
15 | /** |
||
16 | * Regex for seperators |
||
17 | * @var string |
||
18 | */ |
||
19 | private static $matcherRegex = "/^-{3}\s?(\w*)\r?\n(.*)\r?\n-{3}\r?\n(.*)/s"; |
||
20 | |||
21 | /** |
||
22 | * Constanst for Document::dump() |
||
23 | * @see Document::dump() |
||
24 | */ |
||
25 | const DUMP_YAML = 'yaml'; |
||
26 | const DUMP_JSON = 'json'; |
||
27 | const DUMP_INI = 'ini'; |
||
28 | |||
29 | /** |
||
30 | * Parse the given content |
||
31 | * @param string $input content to be parsed |
||
32 | * @return Document |
||
33 | */ |
||
34 | public static function parse($input) |
||
46 | |||
47 | /** |
||
48 | * Convert a Document to string |
||
49 | * @param Document $document |
||
50 | * @return string |
||
51 | */ |
||
52 | public static function dump (Document $document, $mode = null) |
||
68 | |||
69 | /** |
||
70 | * Determines if given content is valid |
||
71 | * @param string $input Input to be validated |
||
72 | * @return boolean True if valid else false |
||
73 | */ |
||
74 | public static function isValid($input) |
||
79 | |||
80 | /** |
||
81 | * Parses header |
||
82 | * @param string $header |
||
83 | * @param string $parser |
||
84 | * @return array|string |
||
85 | */ |
||
86 | private static function parseHeader($header, $parser) |
||
99 | |||
100 | /** |
||
101 | * Encodes PHP array to ini string |
||
102 | * @param array $config |
||
103 | * @return string |
||
104 | */ |
||
105 | private static function dumpIni(array $config) |
||
130 | } |
||
131 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.