Skip to content

Commit 263c625

Browse files
authored
Merge pull request #51 from slackhq/ssandler_function_reference_syntax
Ssandler function reference syntax
2 parents 59bf97d + 69fc75d commit 263c625

13 files changed

+31
-28
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
os: [ ubuntu ]
1212
hhvm:
1313
- '4.80'
14+
- '4.102'
1415
runs-on: ${{matrix.os}}-latest
1516
steps:
1617
- uses: actions/checkout@v2

.hhconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
hackfmt.line_width=120
22
ignored_paths = [ "vendor/.+/tests/.+", "vendor/.+/bin/.+" ]
33
allowed_decl_fixme_codes=1002,2001,2050,2053,2071,3012,3015,4030,4032,4035,4047,4070,4101,4341
4-
allowed_fixme_codes_strict=1002,2001,2011,2025,2049,2050,2053,2071,2105,3012,3015,4005,4006,4009,4011,4026,4027,4030,4032,4035,4047,4051,4053,4057,4060,4062,4063,4064,4070,4101,4104,4106,4107,4108,4110,4112,4117,4119,4128,4135,4138,4163,4165,4188,4193,4224,4240,4249,4250,4281,4297,4298,4318,4321,4323,4324,4337,4341,4343,4370,4371,4372
5-
allowed_fixme_codes_partial=1002,2001,2011,2025,2049,2050,2053,2071,2105,3012,3015,4005,4006,4009,4011,4026,4027,4030,4032,4035,4047,4051,4053,4057,4060,4062,4063,4064,4070,4101,4104,4106,4107,4108,4110,4112,4117,4119,4128,4135,4138,4163,4165,4188,4193,4224,4240,4249,4250,4281,4297,4298,4318,4321,4323,4324,4337,4341,4343,4370,4371,4372
4+
allowed_fixme_codes_strict=1002,2001,2011,2025,2049,2050,2053,2071,2105,3012,3015,4005,4006,4009,4011,4026,4027,4030,4032,4035,4047,4051,4053,4057,4060,4062,4063,4064,4070,4101,4104,4106,4107,4108,4110,4112,4117,4119,4128,4135,4138,4163,4165,4188,4193,4224,4240,4249,4250,4281,4297,4298,4318,4321,4323,4324,4337,4341,4343,4370,4371,4372,4390
5+
allowed_fixme_codes_partial=1002,2001,2011,2025,2049,2050,2053,2071,2105,3012,3015,4005,4006,4009,4011,4026,4027,4030,4032,4035,4047,4051,4053,4057,4060,4062,4063,4064,4070,4101,4104,4106,4107,4108,4110,4112,4117,4119,4128,4135,4138,4163,4165,4188,4193,4224,4240,4249,4250,4281,4297,4298,4318,4321,4323,4324,4337,4341,4343,4370,4371,4372,4390
66
enable_xhp_class_modifier=true
77
disable_xhp_element_mangling=true
88

hhast-lint.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"builtinLinters": "all",
44
"extraLinters": ["Facebook\\HHAST\\Linters\\PreferLambdasLinter"],
55
"disabledLinters": [
6+
"Facebook\\HHAST\\Linters\\DontHaveTwoEmptyLinesInARowLinter",
7+
"Facebook\\HHAST\\Linters\\NoNewlineAtStartOfControlFlowBlockLinter",
68
"Facebook\\HHAST\\Linters\\LicenseHeaderLinter",
79
"Facebook\\HHAST\\Linters\\NoStringInterpolationLinter",
810
"Facebook\\HHAST\\Linters\\NoPHPEqualityLinter",

src/Codegen/Constraints/StringBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function getCheckMethod(): CodegenMethod {
9494
}
9595

9696
$hb
97-
->addAssignment('$sanitize_string', "fun('\\$sanitization_func')", HackBuilderValues::literal())
97+
->addAssignment('$sanitize_string', "\\$sanitization_func<>", HackBuilderValues::literal())
9898
->addAssignment('$typed', '$sanitize_string($typed)', HackBuilderValues::literal())
9999
->ensureEmptyLine();
100100
}

src/Codegen/JsonSchemaCodegenConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public function getTypeNameSuffix(): string {
1212
}
1313

1414
public function getClassNameFormatFunction(): (function(string...): string) {
15-
return fun('\Slack\Hack\JsonSchema\Codegen\format');
15+
return format<>;
1616
}
1717

1818
public function getTypeNameFormatFunction(): (function(string...): string) {
19-
return fun('\Slack\Hack\JsonSchema\Codegen\format');
19+
return format<>;
2020
}
2121

2222
public function getFileNameFormatFunction(): (function(string...): string) {
23-
return fun('\Slack\Hack\JsonSchema\Codegen\format');
23+
return format<>;
2424
}
2525
}

src/Codegen/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function sanitize(string $input): string {
2727
}
2828

2929
function format(string ...$parts): string {
30-
return Vec\map($parts, fun('\Slack\Hack\JsonSchema\Codegen\sanitize'))
30+
return Vec\map($parts, sanitize<>)
3131
|> Str\join($$, '');
3232
}
3333

tests/CodegenForPathsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function testGenerateWithPaths(): void {
2424
),
2525
),
2626
'sanitize_string' => shape(
27-
'uniline' => fun('\Slack\Hack\JsonSchema\Tests\_string_schema_validator_test_uniline'),
28-
'multiline' => fun('\Slack\Hack\JsonSchema\Tests\_string_schema_validator_test_multiline'),
27+
'uniline' => _string_schema_validator_test_uniline<>,
28+
'multiline' => _string_schema_validator_test_multiline<>,
2929
),
3030
),
3131
'generatedFrom' => '`make test`',

tests/CustomCodegenConfigTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function testCustomConfig(): void {
1414
'CustomCodegenConfigValidator',
1515
shape(
1616
'sanitize_string' => shape(
17-
'uniline' => fun('\Slack\Hack\JsonSchema\Codegen\format'),
18-
'multiline' => fun('\Slack\Hack\JsonSchema\Codegen\format'),
17+
'uniline' => \Slack\Hack\JsonSchema\Codegen\format<>,
18+
'multiline' => \Slack\Hack\JsonSchema\Codegen\format<>,
1919
),
2020
'json_schema_codegen_config' => $config,
2121
),
@@ -38,7 +38,7 @@ public function getTypeNameSuffix(): string {
3838
}
3939

4040
public function getClassNameFormatFunction(): (function(string...): string) {
41-
return fun('\Slack\Hack\JsonSchema\Codegen\format');
41+
return \Slack\Hack\JsonSchema\Codegen\format<>;
4242
}
4343

4444
public function getTypeNameFormatFunction(): (function(string...): string) {
@@ -49,15 +49,15 @@ public function getTypeNameFormatFunction(): (function(string...): string) {
4949
}
5050

5151
public function getFileNameFormatFunction(): (function(string...): string) {
52-
return fun('\Slack\Hack\JsonSchema\Codegen\format');
52+
return \Slack\Hack\JsonSchema\Codegen\format<>;
5353
}
5454

5555
public function sanitize(string $input): string {
5656
return $input
5757
|> Str\replace_every($$, dict['_' => ' ', '-' => ' ', '.' => ' '])
5858
|> \preg_split('/(?=[A-Z])/', $$)
5959
|> \array_filter($$)
60-
|> Vec\map($$, fun('\HH\Lib\Str\lowercase'))
60+
|> Vec\map($$, Str\lowercase<>)
6161
|> Str\join($$, ' ')
6262
|> \preg_replace('/[^A-Za-z0-9 ]/', ' nan ', $$)
6363
|> Str\replace($$, ' ', '_');

tests/StringSchemaValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final class StringSchemaValidatorTest extends BaseCodegenTestCase {
2626
'StringSchemaValidator',
2727
shape(
2828
'sanitize_string' => shape(
29-
'uniline' => fun('\Slack\Hack\JsonSchema\Tests\_string_schema_validator_test_uniline'),
30-
'multiline' => fun('\Slack\Hack\JsonSchema\Tests\_string_schema_validator_test_multiline'),
29+
'uniline' => _string_schema_validator_test_uniline<>,
30+
'multiline' => _string_schema_validator_test_multiline<>,
3131
),
3232
),
3333
);

tests/UntypedSchemaValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ final class UntypedSchemaValidatorTest extends BaseCodegenTestCase {
2828
'UntypedSchemaValidator',
2929
shape(
3030
'sanitize_string' => shape(
31-
'uniline' => fun('\Slack\Hack\JsonSchema\Tests\_untyped_schema_validator_test_uniline'),
32-
'multiline' => fun('\Slack\Hack\JsonSchema\Tests\_untyped_schema_validator_test_multiline'),
31+
'uniline' => _untyped_schema_validator_test_uniline<>,
32+
'multiline' => _untyped_schema_validator_test_multiline<>,
3333
),
3434
),
3535
);

0 commit comments

Comments
 (0)