From 4f981172395bbef1f97cdfa5c000b618a40a7fa8 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Mon, 6 Jun 2022 17:03:15 +0000 Subject: [PATCH 1/2] Fix lint errors --- examples/dorm/CodegenDorm.php | 2 +- examples/dorm/CodegenMutator.php | 4 ++-- examples/dorm/core/DormField.php | 2 +- examples/dorm/demo/DormUserMutator.php | 4 ++-- examples/dorm/demo/DormUserSchema.php | 2 +- src/CodegenFile.hack | 1 - src/_Private/StrBuffer.hack | 2 +- .../HackBuilderNativeValueCollectionRenderer.hack | 4 ++-- tests/TestLib/OnExit.hack | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/dorm/CodegenDorm.php b/examples/dorm/CodegenDorm.php index 09ca706e..c0208b10 100644 --- a/examples/dorm/CodegenDorm.php +++ b/examples/dorm/CodegenDorm.php @@ -17,7 +17,7 @@ * that will allow to read the data from a database and store it * in the object. */ -class CodegenDorm { +final class CodegenDorm { private ICodegenFactory $codegen; diff --git a/examples/dorm/CodegenMutator.php b/examples/dorm/CodegenMutator.php index 6c7eec8b..b987c944 100644 --- a/examples/dorm/CodegenMutator.php +++ b/examples/dorm/CodegenMutator.php @@ -16,7 +16,7 @@ * For a given DormSchema, this class generates code for a class * that will allow to insert rows in a database. */ -class CodegenMutator { +final class CodegenMutator { private HackCodegenFactory $codegen; @@ -211,7 +211,7 @@ private function getCheckRequiredFieldsMethod(): CodegenMethod { ->closeStatement() ->addAssignment( '$missing', - '$required->removeAll($this->data->keys());', + '$required->removeAll($this->data->keys())', HackBuilderValues::literal(), ) ->addMultilineCall( diff --git a/examples/dorm/core/DormField.php b/examples/dorm/core/DormField.php index d4e9b556..cecc3faa 100644 --- a/examples/dorm/core/DormField.php +++ b/examples/dorm/core/DormField.php @@ -10,7 +10,7 @@ namespace Facebook\HackCodegen; -class DormField { +final class DormField { private bool $optional = false; private bool $manual = false; diff --git a/examples/dorm/demo/DormUserMutator.php b/examples/dorm/demo/DormUserMutator.php index b9a27b3e..1013f8b1 100644 --- a/examples/dorm/demo/DormUserMutator.php +++ b/examples/dorm/demo/DormUserMutator.php @@ -6,7 +6,7 @@ * To re-generate this file run codegen.php DormUserSchema * * - * @partially-generated SignedSource<> + * @partially-generated SignedSource<<9a620c7d596d01640d6d302a4bdfae46>> */ final class DormUserMutator { @@ -59,7 +59,7 @@ public function checkRequiredFields(): void { 'last_name', 'is_active', }; - $missing = $required->removeAll($this->data->keys());; + $missing = $required->removeAll($this->data->keys()); invariant( $missing->isEmpty(), 'The following required fields are missing: %s', diff --git a/examples/dorm/demo/DormUserSchema.php b/examples/dorm/demo/DormUserSchema.php index 5e5deb91..1e5ab0ed 100644 --- a/examples/dorm/demo/DormUserSchema.php +++ b/examples/dorm/demo/DormUserSchema.php @@ -10,7 +10,7 @@ namespace Facebook\HackCodegen; -class DormUserSchema implements DormSchema { +final class DormUserSchema implements DormSchema { public function getFields(): Map { return Map { 'FirstName' => string_field('first_name'), diff --git a/src/CodegenFile.hack b/src/CodegenFile.hack index 40c4cbf2..ddc7d0c8 100644 --- a/src/CodegenFile.hack +++ b/src/CodegenFile.hack @@ -17,7 +17,6 @@ enum CodegenFileResult: int { UPDATE = 1; CREATE = 2; } -; enum CodegenFileType: int { PHP = 0; diff --git a/src/_Private/StrBuffer.hack b/src/_Private/StrBuffer.hack index 0a14a95d..c6507435 100644 --- a/src/_Private/StrBuffer.hack +++ b/src/_Private/StrBuffer.hack @@ -13,7 +13,7 @@ namespace Facebook\HackCodegen\_Private; * * The string can be retrived once via the `detach()` method. */ -class StrBuffer { +final class StrBuffer { private string $str = ''; private bool $detached = false; diff --git a/src/key-value-render/HackBuilderNativeValueCollectionRenderer.hack b/src/key-value-render/HackBuilderNativeValueCollectionRenderer.hack index bd8a8918..a101ec6e 100644 --- a/src/key-value-render/HackBuilderNativeValueCollectionRenderer.hack +++ b/src/key-value-render/HackBuilderNativeValueCollectionRenderer.hack @@ -16,7 +16,7 @@ use type Facebook\HackCodegen\{ IHackCodegenConfig, }; -class HackBuilderNativeValueCollectionRenderer> +final class HackBuilderNativeValueCollectionRenderer> implements IHackBuilderValueRenderer { public function __construct( private ContainerType $container, @@ -24,7 +24,7 @@ class HackBuilderNativeValueCollectionRenderer> ) { } - final public function render(IHackCodegenConfig $config, T $values): string { + public function render(IHackCodegenConfig $config, T $values): string { $value_renderer = $this->valueRenderer; $builder = (new HackBuilder($config))->openContainer($this->container); foreach ($values as $value) { diff --git a/tests/TestLib/OnExit.hack b/tests/TestLib/OnExit.hack index 900b12e2..841ac93f 100644 --- a/tests/TestLib/OnExit.hack +++ b/tests/TestLib/OnExit.hack @@ -9,7 +9,7 @@ namespace Facebook\HackCodegen; -class OnExit implements \IDisposable { +final class OnExit implements \IDisposable { const type TCallback = (function():void); public function __construct(private self::TCallback $cb) { } From a2d6efc3268642762cb556dd387c35e3b7167f1f Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Fri, 3 Jun 2022 17:33:36 -0700 Subject: [PATCH 2/2] Add `.hack` extension to the temporary file --- src/HackfmtFormatter.hack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HackfmtFormatter.hack b/src/HackfmtFormatter.hack index 20071832..1b7df0b7 100644 --- a/src/HackfmtFormatter.hack +++ b/src/HackfmtFormatter.hack @@ -19,7 +19,7 @@ final class HackfmtFormatter implements ICodegenFormatter { $output = vec[]; $exit_code = null; - $tempnam = \tempnam(\sys_get_temp_dir(), 'hack-codegen-hackfmt'); + $tempnam = \tempnam(\sys_get_temp_dir(), 'hack-codegen-hackfmt').'.hack'; $options = $this->getFormattedOptions();