Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit adca7d3

Browse files
lexidorusox
authored andcommitted
Apply stricter typchecker options.
Depends on updated hackmock.
1 parent 37a73b1 commit adca7d3

7 files changed

Lines changed: 65 additions & 23 deletions

File tree

.hhconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
assume_php = false
2+
check_attribute_locations = true
3+
check_xhp_attribute = true
4+
const_default_func_args = true
5+
decl_override_require_hint = true
6+
disable_halt_compiler = true
7+
disable_instanceof_refinement = true
8+
disable_legacy_soft_typehints = true
9+
disable_lval_as_an_expression = true
10+
disable_partially_abstract_typeconsts = true
11+
disable_primitive_refinement = true
12+
disable_static_closures = true
13+
disable_static_local_variables = true
14+
disable_unsafe_block = true
15+
disable_unsafe_expr = true
16+
disable_unset_class_const = true
17+
disallow_ambiguous_lambda = true
18+
disallow_array_literal = true
19+
disallow_byref_calls = true
20+
disallow_byref_dynamic_calls = true
21+
disallow_destruct = true
22+
disallow_elvis_space = true
23+
disallow_func_ptrs_in_constants = true
24+
disallow_invalid_arraykey = true
25+
disallow_invalid_arraykey_constraint = true
26+
disallow_non_arraykey_keys = true
27+
disallow_scrutinee_case_value_type_mismatch = true
28+
disallow_silence = true
29+
disallow_stringish_magic = true
30+
disallow_toplevel_requires = true
31+
disallow_unsafe_comparisons = true
32+
disallowed_decl_fixmes = 2049, 2050, 4002, 4041, 4049, 4050, 4052, 4055, 4057, 4068, 4077, 4080, 4085, 4086, 4090, 4104, 4105, 4106, 4300, 4337, 4352, 4366
33+
error_php_lambdas = true
34+
ignored_fixme_codes = 1001, 1002, 1003, 1004, 1005, 1006, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2023, 2024, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2044, 2045, 2046, 2047, 2048, 2051, 2052, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 3001, 3002, 3003, 3005, 3006, 3008, 3009, 3010, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 4002, 4008, 4012, 4014, 4020, 4024, 4033, 4034, 4035, 4039, 4042, 4043, 4049, 4050, 4052, 4055, 4067, 4068, 4070, 4077, 4080, 4083, 4085, 4086, 4089, 4121, 4131, 4133, 4143, 4152, 4154, 4166, 4168, 4175, 4181, 4182, 4183, 4190, 4191, 4192, 4194, 4223, 4225, 4231, 4239, 4250, 4253, 4267, 4275, 4296, 4299, 4315, 4321, 4328, 4330, 4331, 4332, 4336, 4353
35+
new_inference_lambda = true
36+
safe_array = true
37+
safe_vector_array = true
38+
typecheck_xhp_cvars = true
39+
unsafe_rx = false

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require-dev": {
2424
"usox/hackmock": "^1.3",
25-
"hhvm/hhast": "^4.1"
25+
"hhvm/hhast": "^4.1",
26+
"hhvm/hacktest": "^1.4|^2.0"
2627
},
2728
"autoload": {
2829
"psr-4": {

example/index.hack

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
namespace Usox\HackTTP\Example;
22

3-
require_once '../vendor/hh_autoload.hh';
43

54
<<__EntryPoint>>
65
async function main(): Awaitable<noreturn> {
7-
$response = \Usox\HackTTP\create_response(200);
6+
require_once '../vendor/hh_autoload.hack';
7+
\Facebook\AutoloadMap\initialize();
8+
$response = \Usox\HackTTP\create_response(200);
89

9-
$response = $response->withAddedHeaderLine('X-ZOMG', 'aggi');
10+
$response = $response->withAddedHeaderLine('X-ZOMG', 'aggi');
1011

11-
await $response->getBody()->writeAsync('foo');
12+
await $response->getBody()->writeAsync('foo');
1213

13-
$emitter = new \Usox\HackTTP\Response\TemporaryFileSapiEmitter();
14-
await $emitter->emitAsync($response);
15-
exit();
16-
}
14+
$emitter = new \Usox\HackTTP\Response\TemporaryFileSapiEmitter();
15+
await $emitter->emitAsync($response);
16+
exit();
17+
}

src/Request.hack

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ class Request implements Message\RequestInterface {
115115
if ($host === '' || $host === null) {
116116
return;
117117
}
118-
if (($port = $this->uri->getPort()) !== null) {
118+
$port = $this->uri->getPort();
119+
if ($port is nonnull) {
119120
$host .= ':'.$port;
120121
}
121122

src/Uri.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ final class Uri implements UriInterface {
339339
static::$char_unreserved.
340340
static::$char_sub_delimeters.
341341
'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
342-
function($match) {
342+
($match) ==> {
343343
return \rawurlencode($match[0]);
344344
},
345345
$path,
@@ -355,7 +355,7 @@ final class Uri implements UriInterface {
355355
static::$char_unreserved.
356356
static::$char_sub_delimeters.
357357
'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
358-
function($match) {
358+
($match) ==> {
359359
return \rawurlencode($match[0]);
360360
},
361361
$str,

tests/FunctionsTest.hack

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class FunctionsTest extends HackTest {
1818
$uri = 'up/and.at?them';
1919

2020
// Define all those (not so) fancy php super globals
21-
$_POST = ['foo' => 'bar'];
22-
$_GET = ['foo' => 'baz'];
23-
$_SERVER = [
21+
$_POST = darray['foo' => 'bar'];
22+
$_GET = darray['foo' => 'baz'];
23+
$_SERVER = darray[
2424
'REQUEST_URI' => $uri,
2525
'REQUEST_METHOD' => 'POST',
2626
'CONTENT_TYPE' => 'multipart/form-data',
2727
];
28-
$_COOKIE = ['some' => 'cookie'];
29-
$_FILES = ['some-file' => ['tmp_name' => '/dev/null', 'size' => 666, 'error' => 0]];
28+
$_COOKIE = darray['some' => 'cookie'];
29+
$_FILES = darray['some-file' => darray['tmp_name' => '/dev/null', 'size' => 666, 'error' => 0]];
3030

3131
$server_request = create_server_request_from_globals();
3232

tests/UriTest.hack

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
2121
expect($uri->getScheme())->toBeSame('https');
2222
expect($uri->getAuthority())->toBeSame('user:pass@example.com:8080');
2323
expect($uri->getUserInfo())->toBePHPEqual(
24-
['user' => 'user', 'pass' => 'pass'],
24+
shape('user' => 'user', 'pass' => 'pass'),
2525
);
2626
expect($uri->getHost())->toBeSame('example.com');
2727
expect($uri->getPort())->toBeSame(8080);
@@ -44,7 +44,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
4444
expect($uri->getScheme())->toBeSame('https');
4545
expect($uri->getAuthority())->toBeSame('user:pass@example.com:8080');
4646
expect($uri->getUserInfo())->toBePHPEqual(
47-
['user' => 'user', 'pass' => 'pass'],
47+
shape('user' => 'user', 'pass' => 'pass'),
4848
);
4949
expect($uri->getHost())->toBeSame('example.com');
5050
expect($uri->getPort())->toBeSame(8080);
@@ -84,7 +84,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
8484

8585
expect($uri->getScheme())->toBeSame('0');
8686
expect($uri->getAuthority())->toBeSame('0:0@0');
87-
expect($uri->getUserInfo())->toBePHPEqual(['user' => '0', 'pass' => '0']);
87+
expect($uri->getUserInfo())->toBePHPEqual(shape('user' => '0', 'pass' => '0'));
8888
expect($uri->getHost())->toBeSame('0');
8989
expect($uri->getPath())->toBeSame('/0');
9090
expect($uri->getRawQuery())->toBeSame('0');
@@ -103,7 +103,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
103103

104104
expect($uri->getScheme())->toBeSame('0');
105105
expect($uri->getAuthority())->toBeSame('0:0@0');
106-
expect($uri->getUserInfo())->toBePHPEqual(['user' => '0', 'pass' => '0']);
106+
expect($uri->getUserInfo())->toBePHPEqual(shape('user' => '0', 'pass' => '0'));
107107
expect($uri->getHost())->toBeSame('0');
108108
expect($uri->getPath())->toBeSame('/0');
109109
expect($uri->getRawQuery())->toBeSame('0');
@@ -192,7 +192,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
192192
$uri = (new Uri())->withUserInfo('user', 'pass');
193193

194194
expect($uri->getUserInfo())->toBePHPEqual(
195-
['user' => 'user', 'pass' => 'pass'],
195+
shape('user' => 'user', 'pass' => 'pass'),
196196
);
197197
expect($uri->getAuthority())->toBeSame('user:pass@');
198198

@@ -331,7 +331,7 @@ class UriTest extends \Facebook\HackTest\HackTest {
331331
expect($uri->getPath())->toBeSame('');
332332
expect($uri->getRawQuery())->toBeSame('');
333333
expect($uri->getFragment())->toBeSame('');
334-
expect($uri->getUserInfo())->toBePHPEqual(['user' => '', 'pass' => '']);
334+
expect($uri->getUserInfo())->toBePHPEqual(shape('user' => '', 'pass' => ''));
335335
}
336336

337337
public function testImmutability(): void {

0 commit comments

Comments
 (0)