Skip to content

Commit f14e9eb

Browse files
committed
Core: Fix loading files from include path
1 parent 443af54 commit f14e9eb

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

build/binary-phar-autoload.php.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#!/usr/bin/env php
21
<?php
3-
if (version_compare('5.6.0', PHP_VERSION, '>')) {
2+
if (version_compare('7.1.0', PHP_VERSION, '>')) {
43
fwrite(
54
STDERR,
6-
'This version of PHPDraft requires PHP 5.6; using the latest version of PHP is highly recommended.' . PHP_EOL
5+
'This version of PHPDraft requires PHP 7.1; using the latest version of PHP is highly recommended.' . PHP_EOL
76
);
87

98
die(1);

phpdraft

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env php
2+
13
<?php
24
/**
35
* Set up include path for source handling

src/PHPDraft/In/ApibFileParser.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public function parse()
6767
*/
6868
private function get_apib($filename)
6969
{
70-
$this->file_check($filename);
71-
$file = file_get_contents($filename);
70+
$path = $this->file_path($filename);
71+
$file = file_get_contents($path);
7272
$matches = [];
73-
preg_match_all('<!-- include\(([a-z0-9_.\/]*?)(\.[a-z]*?)\) -->', $file, $matches);
73+
preg_match_all('<!-- include\(([\S\s]*?)(\.[a-z]*?)\) -->', $file, $matches);
7474
for ($i = 0; $i < count($matches[1]); $i++) {
7575
$file = str_replace('<!-- include(' . $matches[1][$i] . $matches[2][$i] . ') -->',
76-
$this->get_apib($this->location . $matches[1][$i] . $matches[2][$i]), $file);
76+
$this->get_apib($matches[1][$i] . $matches[2][$i]), $file);
7777
}
7878

7979
preg_match_all('<!-- schema\(([a-z0-9_.\/\:]*?)\) -->', $file, $matches);
@@ -91,13 +91,20 @@ private function get_apib($filename)
9191
*
9292
* @throws ExecutionException when the file could not be found.
9393
*
94-
* @return void
94+
* @return string
9595
*/
96-
private function file_check($filename)
96+
private function file_path($filename)
9797
{
98-
if (!file_exists($filename)) {
98+
$path = $this->location . $filename;
99+
if (file_exists($path)) {
100+
return $path;
101+
}
102+
$path = stream_resolve_include_path($filename);
103+
if ($path === FALSE || !file_exists($path)) {
99104
throw new ExecutionException("API File not found: $filename", 1);
100105
}
106+
107+
return $path;
101108
}
102109

103110
/**

tests/phpunit.xml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<phpunit bootstrap="test.bootstrap.inc.php"
44
backupGlobals="false"
55
backupStaticAttributes="false"
6-
syntaxCheck="false"
76
forceCoversAnnotation="true"
8-
mapTestClassNameToCoveredClassName="true"
97
colors="true"
108
verbose="true">
119
<php>
@@ -45,13 +43,13 @@
4543
<directory>../src/PHPDraft/</directory>
4644
<exclude>
4745
<file>../src/PHPDraft/Out/Minifier.php</file>
48-
<directory>../src/PHPDraft/Parse/Tests/</directory>
49-
<directory>../src/PHPDraft/Model/Tests/</directory>
50-
<directory>../src/PHPDraft/Model/Elements/Tests/</directory>
51-
<directory>../src/PHPDraft/Out/Tests/</directory>
52-
<directory>../src/PHPDraft/Out/HTML/</directory>
53-
<directory>../src/PHPDraft/In/Tests/</directory>
54-
<directory>../src/PHPDraft/Core/</directory>
46+
<directory suffix="*Test.php">../src/PHPDraft/Parse/Tests/</directory>
47+
<directory suffix="*Test.php">../src/PHPDraft/Model/Tests/</directory>
48+
<directory suffix="*Test.php">../src/PHPDraft/Model/Elements/Tests/</directory>
49+
<directory suffix="*Test.php">../src/PHPDraft/Out/Tests/</directory>
50+
<directory suffix="*Test.php">../src/PHPDraft/Out/HTML/</directory>
51+
<directory suffix="*Test.php">../src/PHPDraft/In/Tests/</directory>
52+
<directory suffix="*Test.php">../src/PHPDraft/Core/</directory>
5553
<file>../src/PHPDraft/Parse/ResourceException.php</file>
5654
<file>../src/PHPDraft/Model/Comparable.php</file>
5755
<file>../src/PHPDraft/Model/Elements/StructureElement.php</file>
@@ -61,16 +59,11 @@
6159
<logging>
6260
<log type="coverage-html"
6361
target="../build/coverage"
64-
title="PHPDraft"
65-
charset="UTF-8"
66-
yui="true"
67-
highlight="true"
6862
lowUpperBound="35"
6963
highLowerBound="70"/>
7064
<log type="coverage-clover"
7165
target="../build/logs/clover.xml"/>
7266
<log type="junit"
73-
target="../build/logs/junit.xml"
74-
logIncompleteSkipped="false"/>
67+
target="../build/logs/junit.xml"/>
7568
</logging>
7669
</phpunit>

0 commit comments

Comments
 (0)