11<?php
2+
23/**
34 * This file contains the ApibFileParser.
45 *
@@ -33,7 +34,7 @@ class ApibFileParser
3334 /**
3435 * Filename to parse.
3536 *
36- * @var
37+ * @var string
3738 */
3839 private $ filename ;
3940
@@ -75,15 +76,18 @@ public function parse(): self
7576 *
7677 * @return string The full API blueprint file.
7778 */
78- private function get_apib (string $ filename , ?string $ rel_path = NULL ): string
79+ private function get_apib (string $ filename , ?string $ rel_path = null ): string
7980 {
8081 $ path = $ this ->file_path ($ filename , $ rel_path );
8182 $ file = file_get_contents ($ path );
8283 $ matches = [];
8384 preg_match_all ('<!-- include\(([\S\s]*?)(\.[a-z]*?)\) --> ' , $ file , $ matches );
8485 for ($ i = 0 ; $ i < count ($ matches [1 ]); $ i ++) {
85- $ file = str_replace ('<!-- include( ' . $ matches [1 ][$ i ] . $ matches [2 ][$ i ] . ') --> ' ,
86- $ this ->get_apib ($ matches [1 ][$ i ] . $ matches [2 ][$ i ], dirname ($ path )), $ file );
86+ $ file = str_replace (
87+ '<!-- include( ' . $ matches [1 ][$ i ] . $ matches [2 ][$ i ] . ') --> ' ,
88+ $ this ->get_apib ($ matches [1 ][$ i ] . $ matches [2 ][$ i ], dirname ($ path )),
89+ $ file
90+ );
8791 }
8892
8993 preg_match_all ('<!-- schema\(([a-z0-9_.\/\:]*?)\) --> ' , $ file , $ matches );
@@ -104,15 +108,15 @@ private function get_apib(string $filename, ?string $rel_path = NULL): string
104108 *
105109 * @return string
106110 */
107- private function file_path (string $ filename , ?string $ rel_path = NULL ): string
111+ private function file_path (string $ filename , ?string $ rel_path = null ): string
108112 {
109113 // Absolute path
110114 if (file_exists ($ filename )) {
111115 return $ filename ;
112116 }
113117
114118 // Path relative to the top file
115- if ($ rel_path !== NULL && file_exists ($ rel_path . $ filename )) {
119+ if ($ rel_path !== null && file_exists ($ rel_path . $ filename )) {
116120 return $ rel_path . $ filename ;
117121 }
118122
@@ -122,7 +126,7 @@ private function file_path(string $filename, ?string $rel_path = NULL): string
122126 }
123127
124128 $ included_path = stream_resolve_include_path ($ filename );
125- if ($ included_path !== FALSE ) {
129+ if ($ included_path !== false ) {
126130 return $ included_path ;
127131 }
128132
0 commit comments