Skip to content

Commit

Permalink
Merge pull request #206 from thekid/refactor/remove-hhvm
Browse files Browse the repository at this point in the history
Remove HHVM support
  • Loading branch information
thekid authored Feb 5, 2019
2 parents e02a24d + 91d1f50 commit bf17d58
Show file tree
Hide file tree
Showing 34 changed files with 67 additions and 464 deletions.
7 changes: 0 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ php:
- 7.2
- 7.3
- nightly
- hhvm
- hhvm-nightly

matrix:
allow_failures:
- php: hhvm
- php: hhvm-nightly

before_script:
- if [[ $TRAVIS_PHP_VERSION = "hhvm"* ]]; then echo hhvm.hack_compiler_default=false > /etc/hhvm/php.ini; fi
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ XP Framework Core
[![Build status on AppVeyor](https://ci.appveyor.com/api/projects/status/bb9gkkq1o7f6m2ns?svg=true)](https://ci.appveyor.com/project/thekid/core)
[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.png)](http://php.net/)
[![Supports HHVM 3.20+](https://raw.githubusercontent.com/xp-framework/web/master/static/hhvm-3_20plus.png)](http://hhvm.com/)
[![Latest Stable Version](https://poser.pugx.org/xp-framework/core/version.png)](https://packagist.org/packages/xp-framework/core)

This is the XP Framework's development checkout.
Expand Down
7 changes: 0 additions & 7 deletions src/main/php/__xp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
if (PHP_VERSION_ID < 70000) {
throw new \Exception('This version of the XP Framework requires PHP 7.0.0+, have PHP '.PHP_VERSION);
}
if (defined('HHVM_VERSION_ID')) {
if (HHVM_VERSION_ID < 32000) {
throw new \Exception('This version of the XP Framework requires HHVM 3.20+, have HHVM '.HHVM_VERSION);
} else if (!ini_get('hhvm.php7.all')) {
throw new \Exception('This version of the XP Framework requires hhvm.php7.all to be set to 1');
}
}

$p= max(strrpos(__FILE__, DIRECTORY_SEPARATOR), strrpos(__FILE__, '?'));
require_once substr(__FILE__, 0, $p + 1).'lang.base.php';
Expand Down
5 changes: 1 addition & 4 deletions src/main/php/lang.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ function __error($code, $msg, $file, $line) {
}
} else if (0 === strncmp($msg, 'Undefined variable', 18)) {
throw new \lang\NullPointerException($msg);
} else if (0 === strncmp($msg, 'Missing argument', 16) || (
defined('HHVM_VERSION') &&
3 === sscanf($msg, '%*s() expects exactly %*d parameter, %*d given')
)) {
} else if (0 === strncmp($msg, 'Missing argument', 16)) {
throw new \lang\IllegalArgumentException($msg);
} else if ((
0 === strncmp($msg, 'Undefined offset', 16) ||
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/lang/ClassLoader.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ protected static function defineForward($name, $func, $invoke) {
}

if ($param->isVariadic()) {
$sig.= defined('HHVM_VERSION') ? ', ... $'.$p : ', '.$constraint.'... $'.$p;
$sig.= ', '.$constraint.'... $'.$p;
$pass.= ', ...$'.$p;
} else {
$sig.= ', '.$constraint.' $'.$p;
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/lang/RuntimeOptions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getClassPath() {
* @return string[]
*/
public function asArguments() {
$s= defined('HHVM_VERSION') ? ['--php'] : [];
$s= [];
foreach ($this->backing as $key => $value) {
if ("\1" === $key{0}) {
$s[]= '-'.substr($key, 1);
Expand Down
8 changes: 2 additions & 6 deletions src/main/php/lang/Type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ public static function forName($type) {
'float' => 'float',
'bool' => 'bool',
'boolean' => 'bool',
'HH\int' => 'int',
'HH\string' => 'string',
'HH\float' => 'float',
'HH\bool' => 'bool'
];

$l= strlen($type);
Expand All @@ -217,9 +213,9 @@ public static function forName($type) {
// Map well-known primitives, var, void, union types as well as nullable and soft types
if (isset($primitives[$type])) {
return Primitive::forName($primitives[$type]);
} else if ('var' === $type || 'resource' === $type || 'HH\mixed' === $type) {
} else if ('var' === $type || 'resource' === $type) {
return self::$VAR;
} else if ('void' === $type || 'HH\void' === $type || 'HH\noreturn' === $type) {
} else if ('void' === $type) {
return self::$VOID;
} else if ('array' === $type) {
return self::$ARRAY;
Expand Down
15 changes: 4 additions & 11 deletions src/main/php/lang/XPClass.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,10 @@ public function getFields() {
*/
public function getDeclaredFields() {
$list= [];
$reflect= $this->reflect();
if (defined('HHVM_VERSION')) {
foreach ($reflect->getProperties() as $p) {
if ('__id' === $p->name || $p->info['class'] !== $reflect->name) continue;
$list[]= new Field($this->_class, $p);
}
} else {
foreach ($reflect->getProperties() as $p) {
if ('__id' === $p->name || $p->class !== $reflect->name) continue;
$list[]= new Field($this->_class, $p);
}
$reflect= $this->reflect()->name;
foreach ($reflect->getProperties() as $p) {
if ('__id' === $p->name || $p->class !== $reflect) continue;
$list[]= new Field($this->_class, $p);
}
return $list;
}
Expand Down
39 changes: 4 additions & 35 deletions src/main/php/lang/reflect/Field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,10 @@
* @see xp://lang.XPClass
*/
class Field implements Value {
private static $read, $write;
protected $accessible= false;
protected $_class= null;
public $_reflect= null;

static function __static() {
if (defined('HHVM_VERSION_ID')) {
self::$read= function($class, $reflect, $instance, $public) {
if (null === $instance) {
return hphp_get_static_property($class, $reflect->name, !$public);
} else {
return hphp_get_property($instance, $class, $reflect->name);
}
};
self::$write= function($class, $reflect, $instance, $value, $public) {
if (null === $instance) {
return hphp_set_static_property($class, $reflect->name, $value, !$public);
} else {
return hphp_set_property($instance, $class, $reflect->name, $value);
}
};
} else {
self::$read= function($class, $reflect, $instance, $public) {
$public || $reflect->setAccessible(true);
return $reflect->getValue($instance);
};
self::$write= function($class, $reflect, $instance, $value, $public) {
$public || $reflect->setAccessible(true);
return $reflect->setValue($instance, $value);
};
}
}

/**
* Constructor
*
Expand All @@ -72,8 +43,6 @@ public function getType(): Type {
$type= $details[DETAIL_RETURNS];
} else if (isset($details[DETAIL_ANNOTATIONS]['type'])) {
$type= $details[DETAIL_ANNOTATIONS]['type'];
} else if (defined('HHVM_VERSION')) {
$type= $this->_reflect->getTypeText() ?: 'var';
} else {
return Type::$VAR;
}
Expand All @@ -94,8 +63,6 @@ public function getTypeName(): string {
return $details[DETAIL_RETURNS];
} else if (isset($details[DETAIL_ANNOTATIONS]['type'])) {
return $details[DETAIL_ANNOTATIONS]['type'];
} else if (defined('HHVM_VERSION')) {
return str_replace('HH\\', '', $this->_reflect->getTypeText()) ?: 'var';
}
}
return 'var';
Expand Down Expand Up @@ -210,7 +177,8 @@ public function get($instance) {
}

try {
return (self::$read)($this->_class, $this->_reflect, $instance, $public);
$public || $this->_reflect->setAccessible(true);
return $this->_reflect->getValue($instance);
} catch (Throwable $e) {
throw $e;
} catch (\Throwable $e) {
Expand Down Expand Up @@ -262,7 +230,8 @@ public function set($instance, $value) {
}

try {
return (self::$write)($this->_class, $this->_reflect, $instance, $value, $public);
$public || $this->_reflect->setAccessible(true);
return $this->_reflect->setValue($instance, $value);
} catch (Throwable $e) {
throw $e;
} catch (\Throwable $e) {
Expand Down
18 changes: 3 additions & 15 deletions src/main/php/lang/reflect/Parameter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ public function getType() {
!isset($details[DETAIL_ARGUMENTS][$this->_details[2]])
) {

// ReflectionParameter::getType() *always* returns "array" on HHVM, this is
// a) useless and b) inconsistent with PHP. Fall back to "var"
if (defined('HHVM_VERSION') && $this->_reflect->isVariadic()) {
return Type::$VAR;
}

// Cannot parse api doc, fall back to PHP native syntax. The reason for not doing
// this the other way around is that we have "richer" information, e.g. "string[]",
// where PHP simply knows about "arrays" (of whatever).
Expand Down Expand Up @@ -96,14 +90,8 @@ public function getTypeName() {
return ltrim($details[DETAIL_ARGUMENTS][$this->_details[2]], '&');
}

// ReflectionParameter::getType() *always* returns "array" on HHVM, this is
// a) useless and b) inconsistent with PHP. Fall back to "var"
if (defined('HHVM_VERSION') && $this->_reflect->isVariadic()) {
return 'var';
}

if ($t= $this->_reflect->getType()) {
return str_replace('HH\\', '', $t);
return $t;
} else {
return 'var';
}
Expand Down Expand Up @@ -143,7 +131,7 @@ public function getTypeRestriction() {
* @return bool
*/
public function isOptional() {
return $this->_reflect->isOptional() || (defined('HHVM_VERSION') && $this->_reflect->isVariadic());
return $this->_reflect->isOptional();
}

/**
Expand Down Expand Up @@ -172,7 +160,7 @@ public function isVariadic() {
* @return var
*/
public function getDefaultValue() {
if ($this->_reflect->isOptional() || (defined('HHVM_VERSION') && $this->_reflect->isVariadic())) {
if ($this->_reflect->isOptional()) {
return $this->_reflect->isDefaultValueAvailable() ? $this->_reflect->getDefaultValue() : null;
}

Expand Down
13 changes: 1 addition & 12 deletions src/main/php/lang/reflect/Routine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,6 @@ public function getReturnType(): Type {
} else {
return Type::forName($t);
}
} else if (defined('HHVM_VERSION')) {
$t= $this->_reflect->getReturnTypeText() ?: 'var';
if ('self' === $t) {
return new XPClass($this->_reflect->getDeclaringClass());
} else if ('HH\\this' === $t) {
return new XPClass($this->_class);
} else {
return Type::forName($t);
}
} else if ($t= $this->_reflect->getReturnType()) {
return Type::forName((string)$t);
} else {
Expand All @@ -137,9 +128,7 @@ public function getReturnTypeName(): string {
) {
return ltrim($details[DETAIL_RETURNS], '&');
} else if ($t= $this->_reflect->getReturnType()) {
return str_replace('HH\\', '', $t);
} else if (defined('HHVM_VERSION')) {
return str_replace('HH\\', '', $this->_reflect->getReturnTypeText() ?: 'var');
return $t;
} else {
return 'var';
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/php/util/Random.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ private static function urandom($limit) {
throw new IOException('Not a character device: /dev/urandom');
}

// HHVM does not have stream_set_read_buffer()!
function_exists('stream_set_read_buffer') && stream_set_read_buffer($f, 0);
stream_set_read_buffer($f, 0);
$bytes= fread($f, $limit);
fclose($f);
return $bytes;
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/xp/runtime/Version.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private function runnersVersion() { return 'Runners/'.getenv('XP_VERSION'); }
private function phpVersion() { return 'PHP/'.phpversion(); }

/** @return string */
private function engineVersion() { return defined('HHVM_VERSION') ? 'HHVM/'.HHVM_VERSION : 'Zend/'.zend_version(); }
private function engineVersion() { return 'Zend/'.zend_version(); }

/** @return string */
private function osVersion() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/xp/runtime/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
```sh
$ xp version php
```
* Display Engine version - HHVM or Zend
* Display Zend Engine version
```sh
$ xp version engine
```
Expand Down
3 changes: 0 additions & 3 deletions src/test/config/unittest/core.ini
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,5 @@ class="net.xp_framework.unittest.runtime.CodeTest"
[markdown-rendering]
class="net.xp_framework.unittest.runtime.RenderMarkdownTest"

[hhvm:hack]
class="net.xp_framework.unittest.reflection.HackLanguageSupportTest"

[environment]
class="net.xp_framework.unittest.core.EnvironmentTest"
61 changes: 0 additions & 61 deletions src/test/php/net/xp_framework/unittest/IgnoredOnHHVM.class.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php namespace net\xp_framework\unittest\core;

use net\xp_framework\unittest\IgnoredOnHHVM;
use lang\{Runtime, RuntimeOptions, Process};
use unittest\PrerequisitesNotMetError;
use util\Objects;
Expand Down Expand Up @@ -54,12 +53,12 @@ protected function runWithTz($tz) {
$this->assertEquals(255, $r[0], 'exitcode');
}

#[@test, @action(new IgnoredOnHHVM())]
#[@test]
public function fatalsForEmptyTimezone() {
$this->runWithTz('');
}

#[@test, @action(new IgnoredOnHHVM())]
#[@test]
public function fatalsForInvalidTimezone() {
$this->runWithTz('Foo/bar');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
use lang\Environment;
use lang\IllegalArgumentException;
use lang\IllegalStateException;
use net\xp_framework\unittest\IgnoredOnHHVM;

#[@action(new IgnoredOnHHVM())]
class EnvironmentTest extends \unittest\TestCase {
private static $set;

Expand Down
Loading

0 comments on commit bf17d58

Please sign in to comment.