Skip to content

Commit

Permalink
Prevent problems when PHP_VERSION includes extra information
Browse files Browse the repository at this point in the history
E.g. "php:7.0.33-57+ubuntu20.04.1+deb.sury.org+1"
  • Loading branch information
thekid committed Jan 30, 2022
1 parent 056e79d commit 3990bc5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/php/module.xp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module xp-framework/compiler {

/** @return void */
public function initialize() {
ClassLoader::registerLoader(CompilingClassloader::instanceFor('php:'.PHP_VERSION));
ClassLoader::registerLoader(CompilingClassloader::instanceFor('php:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION));

if (!interface_exists(\IDisposable::class, false)) {
eval('interface IDisposable { public function __dispose(); }');
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/xp/compiler/AstRunner.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function main(array $args) {
}

$lang= Language::named('PHP');
$emit= Emitter::forRuntime('php:'.PHP_VERSION)->newInstance();
$emit= Emitter::forRuntime('php:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION)->newInstance();
foreach ($lang->extensions() as $extension) {
$extension->setup($lang, $emit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/xp/compiler/CompileRunner.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static function emitter(string $name): XPClass {
public static function main(array $args) {
if (empty($args)) return Usage::main($args);

$target= 'php:'.PHP_VERSION;
$target= 'php:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION;
$in= $out= '-';
$quiet= false;
$augment= [];
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/xp/compiler/Usage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/** @codeCoverageIgnore */
class Usage {
const RUNTIME = 'PHP';
const RUNTIME = 'php';

/** @return int */
public static function main(array $args) {
Expand All @@ -20,7 +20,7 @@ public function add($t, $active= false) {
}
};

$emitter= Emitter::forRuntime(self::RUNTIME.'.'.PHP_VERSION);
$emitter= Emitter::forRuntime(self::RUNTIME.':'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION);
foreach (Package::forName('lang.ast.emit')->getClasses() as $class) {
if ($class->isSubclassOf(Emitter::class) && !(MODIFIER_ABSTRACT & $class->getModifiers())) {
$impl->add($class, $class->equals($emitter));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CompilingClassLoaderTest {
private static $runtime;

static function __static() {
self::$runtime= 'php:'.PHP_VERSION;
self::$runtime= 'php:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION;
}

/**
Expand Down

0 comments on commit 3990bc5

Please sign in to comment.