From 566a177a4686d04434590c1ad0fffb699409347e Mon Sep 17 00:00:00 2001 From: azjezz Date: Sun, 22 Nov 2020 01:37:44 +0100 Subject: [PATCH] drop support for old hhvm version --- .hhconfig | 2 ++ composer.json | 12 ++++++++---- src/Nuxed/Json/decode.hack | 7 ++++++- src/Nuxed/Json/encode.hack | 1 + src/Nuxed/Json/spec.hack | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.hhconfig b/.hhconfig index 563681d..25c43e7 100644 --- a/.hhconfig +++ b/.hhconfig @@ -6,3 +6,5 @@ const_default_func_args = true disallow_array_literal = true disable_lval_as_an_expression = true ignored_paths = [ "vendor/.+/tests/.+", "vendor/.+/bin/.+" ] +allowed_decl_fixme_codes=2053,4045,4047 +allowed_fixme_codes_strict=2011,2049,2050,2053,2083,3084,4027,4045,4047,4104,4106,4107,4108,4110,4128,4135,4188,4200,4223,4248,4240,4323 diff --git a/composer.json b/composer.json index 6e0b50b..430e8ab 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,17 @@ } ], "require": { - "hhvm": "^4.25", - "hhvm/type-assert": "^3.6" + "hhvm": "~4.83.1 || ~4.84.0", + "hhvm/type-assert": "^4.1.2" }, "require-dev": { - "facebook/fbexpect": "^2.7", + "facebook/difflib": "^1.1.1", + "facebook/fbexpect": "^2.7.7", + "facebook/hh-clilib": "^2.5.2", "hhvm/hacktest": "^2.0", - "hhvm/hhast": "^4.25" + "hhvm/hhast": "^4.82.2", + "hhvm/hhvm-autoload": "^3.1.6", + "hhvm/type-assert": "^4.1.2" }, "scripts": { "check": [ diff --git a/src/Nuxed/Json/decode.hack b/src/Nuxed/Json/decode.hack index 90cb1fa..80f1f51 100644 --- a/src/Nuxed/Json/decode.hack +++ b/src/Nuxed/Json/decode.hack @@ -9,7 +9,12 @@ function decode(string $json, bool $assoc = true): dynamic { $json, $assoc, 512, - \JSON_BIGINT_AS_STRING | \JSON_FB_HACK_ARRAYS, + \JSON_BIGINT_AS_STRING | + ( + \defined('JSON_FB_HACK_ARRAYS') + ? \constant('\JSON_FB_HACK_ARRAYS') + : 0 + ), ); } catch (\Throwable $e) { // assoc = true & invalid property name results in `\Error` diff --git a/src/Nuxed/Json/encode.hack b/src/Nuxed/Json/encode.hack index a131ea0..38d4993 100644 --- a/src/Nuxed/Json/encode.hack +++ b/src/Nuxed/Json/encode.hack @@ -7,6 +7,7 @@ function encode(mixed $value, bool $pretty = false, int $flags = 0): string { $flags |= \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | \JSON_PRESERVE_ZERO_FRACTION; + if ($pretty) { $flags |= \JSON_PRETTY_PRINT; } diff --git a/src/Nuxed/Json/spec.hack b/src/Nuxed/Json/spec.hack index 01ef53c..fae318b 100644 --- a/src/Nuxed/Json/spec.hack +++ b/src/Nuxed/Json/spec.hack @@ -7,6 +7,7 @@ use namespace Facebook\{TypeAssert, TypeSpec}; */ function spec(string $json, TypeSpec\TypeSpec $spec): T { $value = decode($json); + try { return $spec->assertType($value); } catch (TypeAssert\IncorrectTypeException $e) {