@@ -99,14 +99,14 @@ private function fixInternalUrls(string $fileContent, string $dir): string
99
99
{
100
100
return preg_replace_callback (
101
101
'/href="([^"]+?)"/ ' ,
102
- function ($ matches ) use ($ dir ) {
102
+ static function ($ matches ) use ($ dir ) {
103
103
if ('http ' === substr ($ matches [1 ], 0 , 4 ) || '# ' === substr ($ matches [1 ], 0 , 1 )) {
104
104
return $ matches [0 ];
105
105
}
106
106
107
107
$ path = [];
108
108
foreach (explode ('/ ' , $ dir .'/ ' .str_replace (['.html ' , '# ' ], ['' , '- ' ], $ matches [1 ])) as $ part ) {
109
- if ('.. ' == $ part ) {
109
+ if ('.. ' === $ part ) {
110
110
array_pop ($ path );
111
111
} else {
112
112
$ path [] = $ part ;
@@ -130,7 +130,7 @@ private function fixUniqueIdsAndAnchors(string $fileContent, string $uid): strin
130
130
{
131
131
return preg_replace_callback (
132
132
'/id="([^"]+)"/ ' ,
133
- function ($ matches ) use ($ uid ) {
133
+ static function ($ matches ) use ($ uid ) {
134
134
return sprintf ('id="%s-%s" ' , $ uid , $ matches [1 ]);
135
135
},
136
136
$ fileContent
@@ -145,7 +145,7 @@ private function cleanupContent($content)
145
145
// convert links to footnote
146
146
$ content = preg_replace_callback (
147
147
'#<a href="(.*?)" class="reference external"(?:[^>]*)>(.*?)</a># ' ,
148
- function ($ matches ) {
148
+ static function ($ matches ): string {
149
149
if (0 === strpos ($ matches [2 ], 'http ' )) {
150
150
return sprintf ('<em><a href="%s">%s</a></em> ' , $ matches [2 ], $ matches [2 ]);
151
151
}
0 commit comments