1
1
<?php
2
+
2
3
/**
3
4
* This file contains the ApibFileParser.
4
5
*
@@ -33,7 +34,7 @@ class ApibFileParser
33
34
/**
34
35
* Filename to parse.
35
36
*
36
- * @var
37
+ * @var string
37
38
*/
38
39
private $ filename ;
39
40
@@ -75,15 +76,18 @@ public function parse(): self
75
76
*
76
77
* @return string The full API blueprint file.
77
78
*/
78
- private function get_apib (string $ filename , ?string $ rel_path = NULL ): string
79
+ private function get_apib (string $ filename , ?string $ rel_path = null ): string
79
80
{
80
81
$ path = $ this ->file_path ($ filename , $ rel_path );
81
82
$ file = file_get_contents ($ path );
82
83
$ matches = [];
83
84
preg_match_all ('<!-- include\(([\S\s]*?)(\.[a-z]*?)\) --> ' , $ file , $ matches );
84
85
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
+ );
87
91
}
88
92
89
93
preg_match_all ('<!-- schema\(([a-z0-9_.\/\:]*?)\) --> ' , $ file , $ matches );
@@ -104,15 +108,15 @@ private function get_apib(string $filename, ?string $rel_path = NULL): string
104
108
*
105
109
* @return string
106
110
*/
107
- private function file_path (string $ filename , ?string $ rel_path = NULL ): string
111
+ private function file_path (string $ filename , ?string $ rel_path = null ): string
108
112
{
109
113
// Absolute path
110
114
if (file_exists ($ filename )) {
111
115
return $ filename ;
112
116
}
113
117
114
118
// 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 )) {
116
120
return $ rel_path . $ filename ;
117
121
}
118
122
@@ -122,7 +126,7 @@ private function file_path(string $filename, ?string $rel_path = NULL): string
122
126
}
123
127
124
128
$ included_path = stream_resolve_include_path ($ filename );
125
- if ($ included_path !== FALSE ) {
129
+ if ($ included_path !== false ) {
126
130
return $ included_path ;
127
131
}
128
132
0 commit comments