Skip to content

Commit e2a0352

Browse files
authored
Supported HHVM 4.0 (#3) (#4)
* wip * added * changed to travis ci * Update .travis.sh * Update .travis.yml * rename
1 parent e43b07a commit e2a0352

File tree

13 files changed

+52
-68
lines changed

13 files changed

+52
-68
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
composer.phar
22
composer.lock
33
vendor/
4+
docker/
5+
docker-compose.yml

.hhconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
assume_php=false
2-
ignored_paths = [ "vendor/.+/tests/.+", "vendor/hhvm/hhast/.+" ]
1+
assume_php = false
2+
enable_experimental_tc_features = no_fallback_in_namespaces
3+
ignored_paths = [ "vendor/.+/tests/.+" ]
34
safe_array = true
45
safe_vector_array = true
6+
disallow_assign_by_ref = false
57
unsafe_rx = false
6-
enable_experimental_tc_features = no_fallback_in_namespaces

.travis.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/bin/bash
22
set -ex
3+
apt update -y
4+
DEBIAN_FRONTEND=noninteractive apt install -y php-cli zip unzip
35
hhvm --version
4-
curl https://getcomposer.org/installer | hhvm -d hhvm.jit=0 --php -- /dev/stdin --install-dir=/usr/local/bin --filename=composer
6+
php --version
57

6-
cd /var/source
7-
hhvm -d xdebug.enable=0 -d hhvm.jit=0 -d hhvm.hack.lang.auto_typecheck=0 /usr/local/bin/composer install
8-
hhvm -d xdebug.enable=0 -d hhvm.jit=0 vendor/bin/hacktest tests/
8+
(
9+
cd $(mktemp -d)
10+
curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
11+
)
12+
composer install
13+
hh_client
14+
15+
hhvm ./vendor/bin/hacktest tests/

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ services:
44
- docker
55
env:
66
matrix:
7-
- HHVM_VERSION=3.30.0
8-
- HHVM_VERSION=3.30.1
7+
- HHVM_VERSION=4.0.0
8+
- HHVM_VERSION=4.0.1
9+
- HHVM_VERSION=4.0.2
10+
- HHVM_VERSION=4.0.3
911
- HHVM_VERSION=latest
1012
install:
1113
- docker pull hhvm/hhvm:$HHVM_VERSION
1214
script:
13-
- env | egrep '^(HHVM_VERSION|GITHUB_API_KEY|TRAVIS_EVENT_TYPE)=' > ./env-list
14-
- docker run --env-file ./env-list -v $(pwd):/var/source hhvm/hhvm:$HHVM_VERSION /var/source/.travis.sh
15+
- docker run --rm -w /var/source -v $(pwd):/var/source hhvm/hhvm:$HHVM_VERSION ./.travis.sh

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
],
1212
"minimum-stability": "stable",
1313
"require": {
14-
"hhvm": "^3.30.0",
15-
"hhvm/hhvm-autoload": "^1.7",
16-
"hhvm/hsl": "^3.30.0",
17-
"hhvm/hsl-experimental": "^3.30.0"
14+
"hhvm": "^4.0",
15+
"hhvm/hsl": "^4.0",
16+
"hhvm/hsl-experimental": "^4.0",
17+
"hhvm/hhvm-autoload": "^2.0.0"
1818
},
1919
"require-dev": {
20-
"hhvm/hacktest": "^1.3",
21-
"facebook/fbexpect": "^2.3",
22-
"hhvm/hhast": "^3.30.0"
20+
"hhvm/hacktest": "^1.4",
21+
"facebook/fbexpect": "^2.5.2",
22+
"hhvm/hhast": "^4.0.0"
2323
},
2424
"autoload": {
2525
"psr-4": {

hh_autoload.json

100755100644
File mode changed.

hhast-lint.json

100755100644
File mode changed.
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
<?hh // strict
2-
31
namespace Nazg\Glue;
42

53
use namespace Nazg\Glue\Exception;
64
use namespace HH\Lib\{C, Str, Dict};
7-
type CallableInjector = (function(\Nazg\Glue\Container): mixed);
85

9-
class Container {
6+
class Container<T> {
107
private bool $lock = false;
11-
private dict<string, (Scope, CallableInjector)> $map = dict[];
8+
private dict<string, (Scope, (function(\Nazg\Glue\Container<T>): T))> $map = dict[];
129

13-
public function set<T>(
14-
classname<T> $id,
15-
CallableInjector $callback,
10+
public function set(
11+
typename<T> $id,
12+
(function(\Nazg\Glue\Container<T>): T) $callback,
1613
Scope $scope = Scope::PROTOTYPE,
1714
): void {
1815
if(!$this->lock) {
1916
$this->map[$id] = tuple($scope, $callback);
2017
}
2118
}
2219

23-
protected function resolve<T>(classname<T> $id): mixed {
20+
protected function resolve(typename<T> $id): T {
2421
if ($this->has($id)) {
2522
list($scope, $callable) = $this->map[$id];
2623
if ($callable is nonnull) {
@@ -35,20 +32,18 @@ protected function resolve<T>(classname<T> $id): mixed {
3532
);
3633
}
3734

38-
public function getInstance<T>(classname<T> $t): T {
39-
$mixed = $this->resolve($t);
40-
invariant($mixed instanceof $t, "invalid use of incomplete type %s", $t);
41-
return $mixed;
35+
public function get(typename<T> $t): T {
36+
return $this->resolve($t);
4237
}
4338

4439
<<__Memoize>>
45-
protected function shared<T>(classname<T> $id): mixed {
40+
protected function shared(typename<T> $id): T {
4641
list($_, $callable) = $this->map[$id];
4742
return $callable($this);
4843
}
4944

5045
<<__Rx>>
51-
public function has(string $id): bool {
46+
public function has(typename<T> $id): bool {
5247
if($this->lock) {
5348
return C\contains_key($this->map, $id);
5449
}
@@ -65,7 +60,7 @@ public function unlock(): void {
6560
$this->lock = false;
6661
}
6762

68-
public function remove<T>(classname<T> $id): void {
63+
public function remove(typename<T> $id): void {
6964
if(!$this->lock) {
7065
$this->map = Dict\filter_with_key($this->map, ($k, $_) ==> $k !== $id);
7166
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<?hh // strict
2-
31
namespace Nazg\Glue\Exception;
42

53
final class ContainerNotLockedException extends \Exception {}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<?hh // strict
2-
31
namespace Nazg\Glue\Exception;
42

53
final class NotFoundException extends \Exception {}

0 commit comments

Comments
 (0)