Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid go generation #121

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/OutputGenerator/Go/GoEnumResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function convertEnumToGoEnumProperties(array $properties, string $enum):
}
$this->usedConstantsStore[] = $const;

$spaces = str_repeat(' ', $maxEnumPropNameLength - strlen($prop->getName()) + 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix 1 err

$spaces = str_repeat(' ', $maxEnumPropNameLength - strlen($const) + 1);

$value = $prop->isNumeric() ? $prop->getValue() : sprintf('"%s"', $prop->getValue());
$string .= sprintf("\n\t%s$spaces%s = %s", $const, $enum, $value);
Expand Down
4 changes: 2 additions & 2 deletions src/OutputGenerator/Go/GoTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ private function resolveBase(PhpBaseType $type, ?DtoType $dto): string
$type->equalsTo(PhpBaseType::string()) => 'string',
$type->equalsTo(PhpBaseType::bool()) => 'bool',
$type->equalsTo(PhpBaseType::mixed()),
$type->equalsTo(PhpBaseType::object()) => 'interface{}',
$type->equalsTo(PhpBaseType::object()),
$type->equalsTo(PhpBaseType::array()),
$type->equalsTo(PhpBaseType::iterable()) => '[]interface{}',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix 2 err

$type->equalsTo(PhpBaseType::iterable()) => 'interface{}',
$type->equalsTo(PhpBaseType::null()) => 'null',
$type->equalsTo(PhpBaseType::self()) => "*{$dto->getName()}", // * for prevent recursive definition
default => throw new Exception('Unknown base PHP type: %s' . json_encode($type))
Expand Down
6 changes: 3 additions & 3 deletions src/OutputGenerator/Go/OutputFilesProcessorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static function provide(?OutputFilesProcessor $outputFilesProcessor = nul
[
new PrependAutogeneratedNoticeFileProcessor(
text: <<<TEXT
// THE FILE WAS AUTOGENERATED USING PHP-CONVERTER. PLEASE DO NOT EDIT IT!
// THE FILE WAS AUTOGENERATED USING PHP-CONVERTER. PLEASE DO NOT EDIT IT!
// THE FILE WAS AUTOGENERATED USING PHP-CONVERTER. PLEASE DO NOT EDIT IT!
// Code generated by php-converter. DO NOT EDIT.
// Code generated by php-converter. DO NOT EDIT.
// Code generated by php-converter. DO NOT EDIT.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix 3 err


package gen

Expand Down
2 changes: 2 additions & 0 deletions tests/OutputGenerator/Fixtures/NestedDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ final class PermissionsEnum extends Enum
private const VIEW = 'view';

private const EDIT = 'edit';

private const CREATE_EXTRA_SUPER_FILE = 'create-extra-super-file';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created to detect err 2

}

class FullName
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
{
"name": "EDIT",
"value": "edit"
},
{
"name": "CREATE_EXTRA_SUPER_FILE",
"value": "create-extra-super-file"
}
],
"generics": []
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
{
"name": "EDIT",
"value": "edit"
},
{
"name": "CREATE_EXTRA_SUPER_FILE",
"value": "create-extra-super-file"
}
],
"generics": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum NumberEnum {
export enum PermissionsEnum {
VIEW = 'view',
EDIT = 'edit',
CREATE_EXTRA_SUPER_FILE = 'create-extra-super-file',
}

export type Profile = {
Expand Down
Loading