E5E7 Feature/hhvm 4.35 patch by ytake · Pull Request #38 · nazg-hack/framework · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10BC0
9 changes: 6 additions & 3 deletions .hhconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
assume_php = false
enable_experimental_tc_features = no_fallback_in_namespaces
ignored_paths = [ "vendor/.+/tests/.+" ]
safe_array = true
safe_vector_array = true
ignored_paths = [ "vendor/.+/tests/.+", "vendor/bin/.*"]
disallow_assign_by_ref = false
unsafe_rx = false
disallow_elvis_space=true
disallow_non_arraykey_keys=true
disallow_unsafe_comparisons=true
decl_override_require_hint=true
enable_experimental_tc_features=shape_field_check,sealed_classes,reified_generics
9 changes: 7 additions & 2 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ php --version
cd $(mktemp -d)
curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
)

if (hhvm --version | grep -q -- -dev); then
# Doesn't exist in master, but keep it here so that we can test release
# branches on nightlies too
rm -f composer.lock
fi
composer install
hh_client

hhvm ./vendor/bin/hacktest.hack tests/
./vendor/bin/hacktest.hack tests/
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ services:
- docker
env:
matrix:
- HHVM_VERSION=4.20.0
- HHVM_VERSION=4.21.0
- HHVM_VERSION=4.22.0
- HHVM_VERSION=4.23.0
- HHVM_VERSION=4.24.0
- HHVM_VERSION=4.25.0
- HHVM_VERSION=4.26.0
- HHVM_VERSION=latest
- HHVM_VERSION=4.35.0
- HHVM_VERSION=4.36.0
- HHVM_VERSION=4.38.0
- HHVM_VERSION=4.39.0
- HHVM_VERSION=4.40.0
- HHVM_VERSION=4.41.0
- HHVM_VERSION=4.42.0
- HHVM_VERSION=4.43.0
- HHVM_VERSION=4.44.0
- HHVM_VERSION=latest
install:
- docker pull hhvm/hhvm:$HHVM_VERSION
- docker pull hhvm/hhvm-proxygen:$HHVM_VERSION
script:
- docker run --rm -w /var/source -v $(pwd):/var/source hhvm/hhvm:$HHVM_VERSION ./.travis.sh
notifications:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017-2019 Yuuki Takezawa
Copyright (c) 2017-2020 Yuuki Takezawa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
[![Packagist](https://img.shields.io/packagist/l/nazg/framework.svg?style=flat-square)](https://packagist.org/packages/nazg/framework)
[![Build Status](http://img.shields.io/travis/nazg-hack/framework/master.svg?style=flat-square)](https://travis-ci.org/nazg-hack/framework)

Http Application / Microframework for HHVM/Hack
Http Application / MicroFramework for HHVM/Hack

## Supported

HHVM 4.35 and above.

## Usage

Expand Down
44 changes: 17 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,27 @@
}
],
"require": {
"hhvm": "^4.20",
"hhvm/hsl": "^4.15",
"hhvm/hsl-experimental": "^4.15",
"hhvm/hhvm-autoload": "^2.0.0",
"facebook/hh-clilib": "^2.0.0",
"hhvm": "^4.35",
"hhvm/hsl": "^4.0",
"hhvm/hsl-experimental": "^4.25",
"hhvm/hhvm-autoload": "^3.0.0",
"hhvm/type-assert": "^3.7",
"hack-psr/psr7-http-message-hhi": "^1.0.0",
"ytake/hungrr": "^0.5",
"ytake/hhypermedia": "^0.3.2",
"nazg/glue": "^1.2",
"nazg/heredity": "^1.5",
"nazg/hcache": "^0.3",
"nazg/http-server-request-handler": "^0.3.0",
"nazg/http-executor": "^0.5.0",
"facebook/hack-router": "^0.19",
"ytake/hungrr": "^0.9.0",
"ytake/hhypermedia": "^0.5.0",
"nazg/glue": "^1.4.0",
"nazg/heredity": "^1.8.0",
"nazg/hcache": "^0.5.0",
"nazg/http-server-request-handler": "^0.4.1",
"nazg/http-executor": "^0.8.0",
"facebook/hack-router": ">=0.17 <1.0",
"facebook/hack-http-request-response-interfaces": "^0.2",
"hack-logging/hack-logging": "^0.1.1"
"hack-logging/hack-logging": "^0.4.0"
},
"require-dev": {
"hhvm/hacktest": "^1.6",
"facebook/fbexpect": "^2.5",
"hhvm/hhast": "^4.0.0"
},
"autoload": {
"psr-4": {
"Nazg\\": "src/"
},
"files": [
"src/http_enum.php",
"src/types.php"
]
"facebook/fbexpect": "^2.6.1",
"hhvm/hhast": "^4.0",
"hhvm/hacktest": "^2.0"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -55,7 +46,6 @@
"tests/Struct/Shapes.php"
]
},
"minimum-stability": "stable",
"scripts": {
"tests": [
"hhvm ./vendor/bin/hacktest.hack tests/"
Expand Down
4 changes: 3 additions & 1 deletion hh_autoload.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
],
"devRoots": [
"tests/"
]
],
"devFailureHandler": null,
"parser": "ext-factparse"
}
2 changes: 1 addition & 1 deletion src/Exception/ExceptionRegister.hack
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class ExceptionRegister implements BootstrapRegisterInterface {
) {}

public function register(): void {
set_exception_handler([$this->handler, 'handle']);
set_exception_handler(array($this->handler, 'handle'));
}
}
4 changes: 2 additions & 2 deletions src/Logger/LoggerProvider.hack
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use type Nazg\Glue\ProviderInterface;
use type Nazg\Foundation\ApplicationConfig;
use type HackLogging\Logger;
use type HackLogging\Handler\FilesystemHandler;
use namespace HH\Lib\Experimental\Filesystem;
use namespace HH\Lib\Experimental\File;

final class LoggerProvider implements ProviderInterface<Logger> {

Expand All @@ -30,7 +30,7 @@ final class LoggerProvider implements ProviderInterface<Logger> {
$config = $container->get(ApplicationConfig::class);
$logConfig = $config->getLogConfig();
return new Logger($logConfig['logname'], vec[
new FilesystemHandler(Filesystem\open_write_only_non_disposable($logConfig['logfile']))
new FilesystemHandler(File\open_write_only_nd($logConfig['logfile']))
]);
}
}
2 changes: 1 addition & 1 deletion src/Routing/Router.hack
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class Router extends BaseRouter<TResponder> {
protected function collectRoutes(): ImmMap<string, string> {
$map = new Map($this->routeMap);
$i = $map->getIterator();
$named = [];
$named = dict[];
while ($i->valid()) {
$current = $i->current();
$keys = $current->keys();
Expand Down
8 changes: 4 additions & 4 deletions tests/ApplicationTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ use function Facebook\FBExpect\expect;
final class ApplicationTest extends HackTest {

public function testShouldReturnApplicationInstance(): void {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
expect($app)->toBeInstanceOf(Foundation\Application::class);
}

public function testShouldApplyApplication(): void {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
$app->build(new Foundation\ApplicationConfig());
expect($app)->toBeInstanceOf(Foundation\Application::class);
}

public function testApplicationRunThrowException(): void {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
$app->build(new Foundation\ApplicationConfig());
Expand All @@ -33,7 +33,7 @@ final class ApplicationTest extends HackTest {
}

public async function testShouldReturnServerResponseCaseFoundRoute(): Awaitable<void> {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
await $write->writeAsync(json_encode(dict[]));
await $write->closeAsync();
$container = new Container(new DependencyFactory());
Expand Down
6 changes: 3 additions & 3 deletions tests/Exception/ExceptionHandlerTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class ExceptionHandlerTest extends HackTest {

public function testShouldReturnExceptionHandlerInterface(): void {
$container = new Container(new DependencyFactory());
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$container->bind(ExceptionHandleInterface::class)
->provider(new ExceptionHandlerProvider($read, $write, new Emitter\SapiEmitter()));
\HH\Asio\join($container->lockAsync());
Expand All @@ -22,7 +22,7 @@ final class ExceptionHandlerTest extends HackTest {
}

public function testFunctionalExceptionRegister(): void {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$e = new ExceptionHandler($read, $write, new Emitter\SapiEmitter());
$register = new ExceptionRegister($e);
$register->register();
Expand All @@ -39,7 +39,7 @@ final class ExceptionHandlerTest extends HackTest {
}

public function testFunctionalThrowNotFoundHttpException(): void {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$e = new ExceptionHandler($read, $write, new Emitter\SapiEmitter());
$register = new ExceptionRegister($e);
$register->register();
Expand Down
10 changes: 4 additions & 6 deletions tests/Exception/VndErrorFactoryTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use namespace HH\Lib\{Dict, C};
final class VndErrorFactoryTest extends HackTest {

public function testShouldReturnSerializerInstance(): void {
$factory = new VndErrorFactory(
$e = new MockStandardVndErrorException('vnd error testing')
);
$e = new MockStandardVndErrorException('vnd error testing');
$factory = new VndErrorFactory($e);
$v = $factory->invoke(dict[
'exception' => get_class($e),
'file' => $e->getFile(),
Expand All @@ -29,9 +28,8 @@ final class VndErrorFactoryTest extends HackTest {
}

public function testShouldReturnSerializerInstanceWithNotImplementsException(): void {
$factory = new VndErrorFactory(
$e = new NotFoundHttpException('vnd error testing')
);
$e = new NotFoundHttpException('vnd error testing');
$factory = new VndErrorFactory($e);
$v = $factory->invoke(dict[
'exception' => get_class($e),
'file' => $e->getFile(),
Expand Down
10 changes: 6 additions & 4 deletions tests/Http/VndErrorResponseTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,37 @@ use function Facebook\FBExpect\expect;
final class VndErrorResponseTest extends HackTest {

public async function testShouldBe(): Awaitable<void> {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$r = new VndErrorResponse($write);
await $write->writeAsync(\json_encode(dict[]));
await $write->closeAsync();
expect($r->getStatusCode())->toBeSame(500);
expect($r->getProtocolVersion())->toBeSame('1.1');
expect($r->getReasonPhrase())->toBeSame('Internal Server Error');
expect($r->getHeaders())->toBeSame(dict[
'content-type' => vec['application/vnd.error+json'],
]);
await $r->getBody()->closeAsync();
await $r->getBody()->flushAsync();
$re = await $read->readAsync();
expect($re)->toBeSame('{}');
}

public async function testShouldReturnJsonBody(): Awaitable<void> {
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
await $write->writeAsync(\json_encode(dict[
'testing' => dict[
'HHVM' => 'Hack',
5B28 ]
]));
await $write->closeAsync();
$r = new VndErrorResponse($write, StatusCode::FORBIDDEN);
expect($r->getStatusCode())->toBeSame(403);
expect($r->getProtocolVersion())->toBeSame('1.1');
expect($r->getReasonPhrase())->toBeSame('Forbidden');
expect($r->getHeaders())->toBeSame(dict[
'content-type' => vec['application/vnd.error+json'],
]);
await $r->getBody()->closeAsync();
await $r->getBody()->flushAsync();
$re = await $read->readAsync();
expect($re)->toBeSame('{"testing":{"HHVM":"Hack"}}');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Logger/LoggerProviderTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use type Nazg\Glue\{Container, DependencyFactory};
use type Nazg\Foundation\ApplicationConfig;
use type HackLogging\Logger;
use type Facebook\HackTest\HackTest;
use namespace HH\Lib\Experimental\Filesystem;
use namespace HH\Lib\Experimental\File;
use function Facebook\FBExpect\expect;

final class LoggerProviderTest extends HackTest {
Expand All @@ -14,7 +14,7 @@ final class LoggerProviderTest extends HackTest {
$container->bind(ApplicationConfig::class)
->to(ApplicationConfig::class);
expect(() ==> $logger->get($container))
->toThrow(Filesystem\FileOpenException::class);
->toThrow(\HH\Lib\Experimental\OS\NotFoundException::class);
}

public function testShouldReturnLoggerInstance(): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/LogExceptionMiddlewareTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class LogExceptionMiddlewareTest extends HackTest {

public function testShouldPutTestingLog(): void {
$filename = __DIR__ . '/../storages/testing.log';
list($read, $write) = IO\pipe_non_disposable();
list($read, $write) = IO\pipe_nd();
$heredity = new Middleware\Dispatcher(
new AsyncMiddlewareStack(
vec[
Expand Down
4 changes: 2 additions & 2 deletions
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class RouterTest extends HackTest {
}

public function testShouldDetectRouteByRequest(): void {
list($read, $_) = IO\pipe_non_disposable();
list($read, $_) = IO\pipe_nd();
$request = ServerRequestFactory::fromGlobals($read, dict[
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/testing?param=testing'
Expand All @@ -76,7 +76,7 @@ final class RouterTest extends HackTest {
}

public function testShouldNotFoundRouteByRequest(): void {
list($read, $_) = IO\pipe_non_disposable();
list($read, $_) = IO\pipe_nd();
$request = ServerRequestFactory::fromGlobals($read, dict[
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/testing'
Expand Down
4 changes: 2 additions & 2 deletions tests/Validation/ValidatorTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ValidatorTest extends HackTest {
}

public function testShouldThrowTypeException(): void {
list($read, $_) = IO\pipe_non_disposable();
list($read, $_) = IO\pipe_nd();
$v = new MockStructureValidateFalied();
$request = ServerRequestFactory::fromGlobals(
$read,
Expand All @@ -34,7 +34,7 @@ class ValidatorTest extends HackTest {
}

public function testShouldThrow(): void {
list($read, $_) = IO\pipe_non_disposable();
list($read, $_) = IO\pipe_nd();
$v = new MockStructureValidateSuccess();
$request = ServerRequestFactory::fromGlobals(
$read,
Expand Down
0