From 116353990cf21edf8b25814d998d30822311c4e7 Mon Sep 17 00:00:00 2001 From: Jacob de Keizer Date: Tue, 12 Mar 2024 20:29:37 +0100 Subject: [PATCH] Add PHP 8.3 --- src/dto/Settings.ts | 2 +- src/enums/PhpVersion.ts | 1 + ...ll_types_json_php_8_3_with_constructor.txt | 57 ++++ ...th_constructor_and_readonly_properties.txt | 57 ++++ ...romoted_properties_getters_and_setters.txt | 153 +++++++++ ...nly_properties_and_promoted_properties.txt | 31 ++ ..._properties_and_from_json_array_method.txt | 54 ++++ ...omoted_properties_and_from_json_method.txt | 54 ++++ ...romoted_properties_getters_and_setters.txt | 92 ++++++ ...space_root_class_name_and_strict_types.txt | 32 ++ ...al_classes_and_all_properties_nullable.txt | 24 ++ ...es_for_properties_and_from_json_method.txt | 293 ++++++++++++++++++ ...ith_setters_and_from_json_array_method.txt | 108 +++++++ ..._8_3_with_setters_and_from_json_method.txt | 108 +++++++ ...types_json_php_8_3_without_constructor.txt | 24 ++ ...thout_constructor_and_readonly_classes.txt | 24 ++ ...ut_constructor_and_readonly_properties.txt | 24 ++ ...nested_arrays_php_8_3_with_constructor.txt | 51 +++ ...th_constructor_and_readonly_properties.txt | 51 +++ ...romoted_properties_getters_and_setters.txt | 109 +++++++ ...nly_properties_and_promoted_properties.txt | 33 ++ ..._properties_and_from_json_array_method.txt | 60 ++++ ...omoted_properties_and_from_json_method.txt | 60 ++++ ...romoted_properties_getters_and_setters.txt | 71 +++++ ...space_root_class_name_and_strict_types.txt | 37 +++ ...al_classes_and_all_properties_nullable.txt | 25 ++ ...es_for_properties_and_from_json_method.txt | 214 +++++++++++++ ...ith_setters_and_from_json_array_method.txt | 90 ++++++ ..._8_3_with_setters_and_from_json_method.txt | 90 ++++++ ...ted_arrays_php_8_3_without_constructor.txt | 25 ++ ...thout_constructor_and_readonly_classes.txt | 25 ++ ...ut_constructor_and_readonly_properties.txt | 25 ++ ...ple_json_data_php_8_3_with_constructor.txt | 11 + ...th_constructor_and_readonly_properties.txt | 11 + ...romoted_properties_getters_and_setters.txt | 18 ++ ...nly_properties_and_promoted_properties.txt | 8 + ..._properties_and_from_json_array_method.txt | 15 + ...omoted_properties_and_from_json_method.txt | 15 + ...romoted_properties_getters_and_setters.txt | 13 + ...space_root_class_name_and_strict_types.txt | 10 + ...al_classes_and_all_properties_nullable.txt | 6 + ...es_for_properties_and_from_json_method.txt | 38 +++ ...ith_setters_and_from_json_array_method.txt | 18 ++ ..._8_3_with_setters_and_from_json_method.txt | 18 ++ ..._json_data_php_8_3_without_constructor.txt | 6 + ...thout_constructor_and_readonly_classes.txt | 6 + ...ut_constructor_and_readonly_properties.txt | 6 + tests/converter/json-to-php-converter.spec.ts | 9 +- 48 files changed, 2310 insertions(+), 2 deletions(-) create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_and_readonly_properties.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_final_classes_and_all_properties_nullable.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_getters_fluent_setters_all_docblocks_extra_new_lines_for_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor_and_readonly_classes.txt create mode 100644 tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor_and_readonly_properties.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_and_readonly_properties.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_final_classes_and_all_properties_nullable.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_getters_fluent_setters_all_docblocks_extra_new_lines_for_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor_and_readonly_classes.txt create mode 100644 tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor_and_readonly_properties.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_and_readonly_properties.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_final_classes_and_all_properties_nullable.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_getters_fluent_setters_all_docblocks_extra_new_lines_for_properties_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_array_method.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_method.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor_and_readonly_classes.txt create mode 100644 tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor_and_readonly_properties.txt diff --git a/src/dto/Settings.ts b/src/dto/Settings.ts index 3b87c06..52504fa 100644 --- a/src/dto/Settings.ts +++ b/src/dto/Settings.ts @@ -79,7 +79,7 @@ export const supportsReadonlyClasses = (settings: Settings): boolean => { export const createDefaultSettings = (): Settings => { return { - phpVersion: PhpVersion.PHP82, + phpVersion: PhpVersion.PHP83, classCase: StringCase.PascalCase, propertyCase: StringCase.CamelCase, diff --git a/src/enums/PhpVersion.ts b/src/enums/PhpVersion.ts index 88bff07..b96e7ad 100644 --- a/src/enums/PhpVersion.ts +++ b/src/enums/PhpVersion.ts @@ -4,4 +4,5 @@ export enum PhpVersion { PHP80 = 'PHP 8.0', PHP81 = 'PHP 8.1', PHP82 = 'PHP 8.2', + PHP83 = 'PHP 8.3', } \ No newline at end of file diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor.txt new file mode 100644 index 0000000..1da870b --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor.txt @@ -0,0 +1,57 @@ +stringArray = $stringArray; + $this->mixedArray = $mixedArray; + $this->nullArray = $nullArray; + $this->unknownArray = $unknownArray; + $this->boolean = $boolean; + $this->float = $float; + $this->int = $int; + $this->null = $null; + $this->nestedClass = $nestedClass; + $this->string = $string; + } +} + +var = $var; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_and_readonly_properties.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_and_readonly_properties.txt new file mode 100644 index 0000000..5549cf7 --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_and_readonly_properties.txt @@ -0,0 +1,57 @@ +stringArray = $stringArray; + $this->mixedArray = $mixedArray; + $this->nullArray = $nullArray; + $this->unknownArray = $unknownArray; + $this->boolean = $boolean; + $this->float = $float; + $this->int = $int; + $this->null = $null; + $this->nestedClass = $nestedClass; + $this->string = $string; + } +} + +var = $var; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..c8c2590 --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt @@ -0,0 +1,153 @@ +stringArray; + } + + /** + * @return (string|int|null)[] + */ + public function getMixedArray(): array + { + return $this->mixedArray; + } + + public function getNullArray(): array + { + return $this->nullArray; + } + + public function getUnknownArray(): array + { + return $this->unknownArray; + } + + public function getBoolean(): bool + { + return $this->boolean; + } + + public function getFloat(): float + { + return $this->float; + } + + public function getInt(): int + { + return $this->int; + } + + public function getNull(): null + { + return $this->null; + } + + public function getNestedClass(): NestedClass + { + return $this->nestedClass; + } + + public function getString(): string + { + return $this->string; + } + + /** + * @param string[] $stringArray + */ + public function setStringArray(array $stringArray): void + { + $this->stringArray = $stringArray; + } + + /** + * @param (string|int|null)[] $mixedArray + */ + public function setMixedArray(array $mixedArray): void + { + $this->mixedArray = $mixedArray; + } + + public function setNullArray(array $nullArray): void + { + $this->nullArray = $nullArray; + } + + public function setUnknownArray(array $unknownArray): void + { + $this->unknownArray = $unknownArray; + } + + public function setBoolean(bool $boolean): void + { + $this->boolean = $boolean; + } + + public function setFloat(float $float): void + { + $this->float = $float; + } + + public function setInt(int $int): void + { + $this->int = $int; + } + + public function setNull(null $null): void + { + $this->null = $null; + } + + public function setNestedClass(NestedClass $nestedClass): void + { + $this->nestedClass = $nestedClass; + } + + public function setString(string $string): void + { + $this->string = $string; + } +} + +var; + } + + public function setVar(int $var): void + { + $this->var = $var; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt new file mode 100644 index 0000000..39a9f0b --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt @@ -0,0 +1,31 @@ +string_array, + $data->mixed_array, + $data->null_array, + $data->unknown_array, + $data->boolean, + $data->float, + $data->int, + $data->null ?? null, + NestedClass::fromJson($data->nested_class), + $data->string + ); + } +} + +var + ); + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..50de24b --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt @@ -0,0 +1,92 @@ +stringArray; + } + + /** + * @return (string|int|null)[] + */ + public function getMixedArray(): array + { + return $this->mixedArray; + } + + public function getNullArray(): array + { + return $this->nullArray; + } + + public function getUnknownArray(): array + { + return $this->unknownArray; + } + + public function getBoolean(): bool + { + return $this->boolean; + } + + public function getFloat(): float + { + return $this->float; + } + + public function getInt(): int + { + return $this->int; + } + + public function getNull(): null + { + return $this->null; + } + + public function getNestedClass(): NestedClass + { + return $this->nestedClass; + } + + public function getString(): string + { + return $this->string; + } +} + +var; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt new file mode 100644 index 0000000..e5cfed3 --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt @@ -0,0 +1,32 @@ +stringArray; + } + + /** + * @return (string|int|null)[] + */ + public function getMixedArray(): array + { + return $this->mixedArray; + } + + /** + * @return array + */ + public function getNullArray(): array + { + return $this->nullArray; + } + + /** + * @return array + */ + public function getUnknownArray(): array + { + return $this->unknownArray; + } + + /** + * @return bool + */ + public function getBoolean(): bool + { + return $this->boolean; + } + + /** + * @return float + */ + public function getFloat(): float + { + return $this->float; + } + + /** + * @return int + */ + public function getInt(): int + { + return $this->int; + } + + /** + * @return |null + */ + public function getNull(): null + { + return $this->null; + } + + /** + * @return NestedClass + */ + public function getNestedClass(): NestedClass + { + return $this->nestedClass; + } + + /** + * @return string + */ + public function getString(): string + { + return $this->string; + } + + /** + * @param string[] $stringArray + * @return self + */ + public function setStringArray(array $stringArray): self + { + $this->stringArray = $stringArray; + return $this; + } + + /** + * @param (string|int|null)[] $mixedArray + * @return self + */ + public function setMixedArray(array $mixedArray): self + { + $this->mixedArray = $mixedArray; + return $this; + } + + /** + * @param array $nullArray + * @return self + */ + public function setNullArray(array $nullArray): self + { + $this->nullArray = $nullArray; + return $this; + } + + /** + * @param array $unknownArray + * @return self + */ + public function setUnknownArray(array $unknownArray): self + { + $this->unknownArray = $unknownArray; + return $this; + } + + /** + * @param bool $boolean + * @return self + */ + public function setBoolean(bool $boolean): self + { + $this->boolean = $boolean; + return $this; + } + + /** + * @param float $float + * @return self + */ + public function setFloat(float $float): self + { + $this->float = $float; + return $this; + } + + /** + * @param int $int + * @return self + */ + public function setInt(int $int): self + { + $this->int = $int; + return $this; + } + + /** + * @param |null $null + * @return self + */ + public function setNull(null $null): self + { + $this->null = $null; + return $this; + } + + /** + * @param NestedClass $nestedClass + * @return self + */ + public function setNestedClass(NestedClass $nestedClass): self + { + $this->nestedClass = $nestedClass; + return $this; + } + + /** + * @param string $string + * @return self + */ + public function setString(string $string): self + { + $this->string = $string; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setStringArray($data['string_array']); + $instance->setMixedArray($data['mixed_array']); + $instance->setNullArray($data['null_array']); + $instance->setUnknownArray($data['unknown_array']); + $instance->setBoolean($data['boolean']); + $instance->setFloat($data['float']); + $instance->setInt($data['int']); + $instance->setNull($data['null'] ?? null); + $instance->setNestedClass(NestedClass::fromJson($data['nested_class'])); + $instance->setString($data['string']); + return $instance; + } +} + +var; + } + + /** + * @param int $var + * @return self + */ + public function setVar(int $var): self + { + $this->var = $var; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setVar($data['var']); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_array_method.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_array_method.txt new file mode 100644 index 0000000..5f1d124 --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_array_method.txt @@ -0,0 +1,108 @@ +stringArray = $stringArray; + } + + /** + * @param (string|int|null)[] $mixedArray + */ + public function setMixedArray(array $mixedArray): void + { + $this->mixedArray = $mixedArray; + } + + public function setNullArray(array $nullArray): void + { + $this->nullArray = $nullArray; + } + + public function setUnknownArray(array $unknownArray): void + { + $this->unknownArray = $unknownArray; + } + + public function setBoolean(bool $boolean): void + { + $this->boolean = $boolean; + } + + public function setFloat(float $float): void + { + $this->float = $float; + } + + public function setInt(int $int): void + { + $this->int = $int; + } + + public function setNull(null $null): void + { + $this->null = $null; + } + + public function setNestedClass(NestedClass $nestedClass): void + { + $this->nestedClass = $nestedClass; + } + + public function setString(string $string): void + { + $this->string = $string; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setStringArray($data['string_array']); + $instance->setMixedArray($data['mixed_array']); + $instance->setNullArray($data['null_array']); + $instance->setUnknownArray($data['unknown_array']); + $instance->setBoolean($data['boolean']); + $instance->setFloat($data['float']); + $instance->setInt($data['int']); + $instance->setNull($data['null'] ?? null); + $instance->setNestedClass(NestedClass::fromJson($data['nested_class'])); + $instance->setString($data['string']); + return $instance; + } +} + +var = $var; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setVar($data['var']); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_method.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_method.txt new file mode 100644 index 0000000..8e06e05 --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_with_setters_and_from_json_method.txt @@ -0,0 +1,108 @@ +stringArray = $stringArray; + } + + /** + * @param (string|int|null)[] $mixedArray + */ + public function setMixedArray(array $mixedArray): void + { + $this->mixedArray = $mixedArray; + } + + public function setNullArray(array $nullArray): void + { + $this->nullArray = $nullArray; + } + + public function setUnknownArray(array $unknownArray): void + { + $this->unknownArray = $unknownArray; + } + + public function setBoolean(bool $boolean): void + { + $this->boolean = $boolean; + } + + public function setFloat(float $float): void + { + $this->float = $float; + } + + public function setInt(int $int): void + { + $this->int = $int; + } + + public function setNull(null $null): void + { + $this->null = $null; + } + + public function setNestedClass(NestedClass $nestedClass): void + { + $this->nestedClass = $nestedClass; + } + + public function setString(string $string): void + { + $this->string = $string; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setStringArray($data->string_array); + $instance->setMixedArray($data->mixed_array); + $instance->setNullArray($data->null_array); + $instance->setUnknownArray($data->unknown_array); + $instance->setBoolean($data->boolean); + $instance->setFloat($data->float); + $instance->setInt($data->int); + $instance->setNull($data->null ?? null); + $instance->setNestedClass(NestedClass::fromJson($data->nested_class)); + $instance->setString($data->string); + return $instance; + } +} + +var = $var; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setVar($data->var); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor.txt b/tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor.txt new file mode 100644 index 0000000..3d06c5f --- /dev/null +++ b/tests/converter/fixtures/results/all_types_json_php_8_3_without_constructor.txt @@ -0,0 +1,24 @@ +simpleNesting = $simpleNesting; + } +} + +alwaysPresent = $alwaysPresent; + $this->string = $string; + $this->object = $object; + $this->number = $number; + } +} + +test = $test; + $this->anotherTest = $anotherTest; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_and_readonly_properties.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_and_readonly_properties.txt new file mode 100644 index 0000000..92b88a5 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_and_readonly_properties.txt @@ -0,0 +1,51 @@ +simpleNesting = $simpleNesting; + } +} + +alwaysPresent = $alwaysPresent; + $this->string = $string; + $this->object = $object; + $this->number = $number; + } +} + +test = $test; + $this->anotherTest = $anotherTest; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..e07f04d --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt @@ -0,0 +1,109 @@ +simpleNesting; + } + + /** + * @param SimpleNesting[] $simpleNesting + */ + public function setSimpleNesting(array $simpleNesting): void + { + $this->simpleNesting = $simpleNesting; + } +} + +alwaysPresent; + } + + public function getString(): ?string + { + return $this->string; + } + + public function getObject(): ?Object + { + return $this->object; + } + + public function getNumber(): ?int + { + return $this->number; + } + + public function setAlwaysPresent(float $alwaysPresent): void + { + $this->alwaysPresent = $alwaysPresent; + } + + public function setString(?string $string): void + { + $this->string = $string; + } + + public function setObject(?Object $object): void + { + $this->object = $object; + } + + public function setNumber(?int $number): void + { + $this->number = $number; + } +} + +test; + } + + public function getAnotherTest(): ?int + { + return $this->anotherTest; + } + + public function setTest(?int $test): void + { + $this->test = $test; + } + + public function setAnotherTest(?int $anotherTest): void + { + $this->anotherTest = $anotherTest; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt new file mode 100644 index 0000000..483ad12 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt @@ -0,0 +1,33 @@ +simple_nesting) + ); + } +} + +always_present, + $data->string ?? null, + ($data->object ?? null) !== null ? Object::fromJson($data->object) : null, + $data->number ?? null + ); + } +} + +test ?? null, + $data->another_test ?? null + ); + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..b4a384a --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt @@ -0,0 +1,71 @@ +simpleNesting; + } +} + +alwaysPresent; + } + + public function getString(): ?string + { + return $this->string; + } + + public function getObject(): ?Object + { + return $this->object; + } + + public function getNumber(): ?int + { + return $this->number; + } +} + +test; + } + + public function getAnotherTest(): ?int + { + return $this->anotherTest; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt new file mode 100644 index 0000000..f8e8238 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt @@ -0,0 +1,37 @@ +simpleNesting; + } + + /** + * @param SimpleNesting[] $simpleNesting + * @return self + */ + public function setSimpleNesting(array $simpleNesting): self + { + $this->simpleNesting = $simpleNesting; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setSimpleNesting(array_map(static function($data) { + return SimpleNesting::fromJson($data); + }, $data['simple_nesting'])); + return $instance; + } +} + +alwaysPresent; + } + + /** + * @return string|null + */ + public function getString(): ?string + { + return $this->string; + } + + /** + * @return Object|null + */ + public function getObject(): ?Object + { + return $this->object; + } + + /** + * @return int|null + */ + public function getNumber(): ?int + { + return $this->number; + } + + /** + * @param float $alwaysPresent + * @return self + */ + public function setAlwaysPresent(float $alwaysPresent): self + { + $this->alwaysPresent = $alwaysPresent; + return $this; + } + + /** + * @param string|null $string + * @return self + */ + public function setString(?string $string): self + { + $this->string = $string; + return $this; + } + + /** + * @param Object|null $object + * @return self + */ + public function setObject(?Object $object): self + { + $this->object = $object; + return $this; + } + + /** + * @param int|null $number + * @return self + */ + public function setNumber(?int $number): self + { + $this->number = $number; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setAlwaysPresent($data['always_present']); + $instance->setString($data['string'] ?? null); + $instance->setObject(($data['object'] ?? null) !== null ? Object::fromJson($data['object']) : null); + $instance->setNumber($data['number'] ?? null); + return $instance; + } +} + +test; + } + + /** + * @return int|null + */ + public function getAnotherTest(): ?int + { + return $this->anotherTest; + } + + /** + * @param int|null $test + * @return self + */ + public function setTest(?int $test): self + { + $this->test = $test; + return $this; + } + + /** + * @param int|null $anotherTest + * @return self + */ + public function setAnotherTest(?int $anotherTest): self + { + $this->anotherTest = $anotherTest; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setTest($data['test'] ?? null); + $instance->setAnotherTest($data['another_test'] ?? null); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_array_method.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_array_method.txt new file mode 100644 index 0000000..edc9224 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_array_method.txt @@ -0,0 +1,90 @@ +simpleNesting = $simpleNesting; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setSimpleNesting(array_map(static function($data) { + return SimpleNesting::fromJson($data); + }, $data['simple_nesting'])); + return $instance; + } +} + +alwaysPresent = $alwaysPresent; + } + + public function setString(?string $string): void + { + $this->string = $string; + } + + public function setObject(?Object $object): void + { + $this->object = $object; + } + + public function setNumber(?int $number): void + { + $this->number = $number; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setAlwaysPresent($data['always_present']); + $instance->setString($data['string'] ?? null); + $instance->setObject(($data['object'] ?? null) !== null ? Object::fromJson($data['object']) : null); + $instance->setNumber($data['number'] ?? null); + return $instance; + } +} + +test = $test; + } + + public function setAnotherTest(?int $anotherTest): void + { + $this->anotherTest = $anotherTest; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setTest($data['test'] ?? null); + $instance->setAnotherTest($data['another_test'] ?? null); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_method.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_method.txt new file mode 100644 index 0000000..a107723 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_with_setters_and_from_json_method.txt @@ -0,0 +1,90 @@ +simpleNesting = $simpleNesting; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setSimpleNesting(array_map(static function($data) { + return SimpleNesting::fromJson($data); + }, $data->simple_nesting)); + return $instance; + } +} + +alwaysPresent = $alwaysPresent; + } + + public function setString(?string $string): void + { + $this->string = $string; + } + + public function setObject(?Object $object): void + { + $this->object = $object; + } + + public function setNumber(?int $number): void + { + $this->number = $number; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setAlwaysPresent($data->always_present); + $instance->setString($data->string ?? null); + $instance->setObject(($data->object ?? null) !== null ? Object::fromJson($data->object) : null); + $instance->setNumber($data->number ?? null); + return $instance; + } +} + +test = $test; + } + + public function setAnotherTest(?int $anotherTest): void + { + $this->anotherTest = $anotherTest; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setTest($data->test ?? null); + $instance->setAnotherTest($data->another_test ?? null); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor.txt b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor.txt new file mode 100644 index 0000000..0d70367 --- /dev/null +++ b/tests/converter/fixtures/results/merges_nested_arrays_php_8_3_without_constructor.txt @@ -0,0 +1,25 @@ +test = $test; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_and_readonly_properties.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_and_readonly_properties.txt new file mode 100644 index 0000000..06ac1a6 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_and_readonly_properties.txt @@ -0,0 +1,11 @@ +test = $test; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..5ed5577 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_promoted_properties_getters_and_setters.txt @@ -0,0 +1,18 @@ +test; + } + + public function setTest(int $test): void + { + $this->test = $test; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt new file mode 100644 index 0000000..6fe1304 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_and_promoted_properties.txt @@ -0,0 +1,8 @@ +test + ); + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt new file mode 100644 index 0000000..dabbca4 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_constructor_readonly_properties_promoted_properties_getters_and_setters.txt @@ -0,0 +1,13 @@ +test; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt new file mode 100644 index 0000000..0c6ffda --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_custom_namespace_root_class_name_and_strict_types.txt @@ -0,0 +1,10 @@ +test; + } + + /** + * @param int $test + * @return self + */ + public function setTest(int $test): self + { + $this->test = $test; + return $this; + } + + /** + * @param array $data + * @return self + */ + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setTest($data['test']); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_array_method.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_array_method.txt new file mode 100644 index 0000000..c3662b3 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_array_method.txt @@ -0,0 +1,18 @@ +test = $test; + } + + public static function fromJson(array $data): self + { + $instance = new self(); + $instance->setTest($data['test']); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_method.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_method.txt new file mode 100644 index 0000000..ff0c283 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_with_setters_and_from_json_method.txt @@ -0,0 +1,18 @@ +test = $test; + } + + public static function fromJson(\stdClass $data): self + { + $instance = new self(); + $instance->setTest($data->test); + return $instance; + } +} diff --git a/tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor.txt b/tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor.txt new file mode 100644 index 0000000..9f9b9f9 --- /dev/null +++ b/tests/converter/fixtures/results/simple_json_data_php_8_3_without_constructor.txt @@ -0,0 +1,6 @@ + = [ ], ] -const versions = [PhpVersion.PHP73, PhpVersion.PHP74, PhpVersion.PHP80, PhpVersion.PHP81, PhpVersion.PHP82]; +const versions = [ + PhpVersion.PHP73, + PhpVersion.PHP74, + PhpVersion.PHP80, + PhpVersion.PHP81, + PhpVersion.PHP82, + PhpVersion.PHP83, +]; const settingCases = versions.map((version) => { const value: Array<[string, Settings]> = [