Skip to content

Commit 4324a44

Browse files
Do not use ./phpunit --version to generate the version identifier in PHAR build
1 parent b3cda42 commit 4324a44

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

build.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,7 @@
330330
</target>
331331

332332
<target name="-phar-determine-version">
333-
<exec executable="bash" outputproperty="version">
334-
<arg value="-c"/>
335-
<arg value="${basedir}/phpunit --version | awk 'BEGIN { ORS = &quot;&quot;; } {print $2}'"/>
336-
</exec>
333+
<exec executable="${basedir}/build/version.php" outputproperty="version" />
337334
</target>
338335

339336
<target name="generate-project-documentation" depends="-phploc,-phpcs,-phpmd,-phpunit">

build/version.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env php
2+
<?php
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use SebastianBergmann\Version;
6+
7+
$buffer = file_get_contents(__DIR__ . '/../src/Runner/Version.php');
8+
$start = strpos($buffer, 'new Version(\'') + strlen('new Version(\'');
9+
$end = strpos($buffer, '\'', $start);
10+
$version = substr($buffer, $start, $end - $start);
11+
$version = new Version($version, __DIR__ . '/../');
12+
13+
print $version->getVersion();

src/Runner/Version.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* file that was distributed with this source code.
99
*/
1010

11+
use SebastianBergmann\Version;
12+
1113
/**
1214
* This class defines the current version of PHPUnit.
1315
*
@@ -30,7 +32,7 @@ public static function id()
3032
}
3133

3234
if (self::$version === null) {
33-
$version = new SebastianBergmann\Version('4.8.31', dirname(dirname(__DIR__)));
35+
$version = new Version('4.8.31', dirname(dirname(__DIR__)));
3436
self::$version = $version->getVersion();
3537
}
3638

0 commit comments

Comments
 (0)