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

Add support for generating hack enums from json def #81

Merged
merged 12 commits into from
Jan 4, 2024

Conversation

scobb
Copy link
Collaborator

@scobb scobb commented Dec 19, 2023

When users provide enum, hackEnum, and generateHackEnum: true, we'll generate a class they can use.

Known issues:

  • white space - my dev box was using tabs instead of two spaces. i resolved this using one liner:
git diff --name-only master | xargs sed -i $'s/\t/  /g'

Copy link

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Steven Cobb <s***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

@scobb scobb changed the title Add support for generating hack enums from json def 🚧 Add support for generating hack enums from json def Dec 19, 2023
@scobb scobb changed the title 🚧 Add support for generating hack enums from json def Add support for generating hack enums from json def Jan 3, 2024
Copy link
Collaborator

@ianhoffman ianhoffman left a comment

Choose a reason for hiding this comment

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

LGTM, ty for doing this.

@@ -146,6 +168,9 @@ protected function getCheckMethod(): CodegenMethod {
<<__Override>>
public function getType(): string {
if (Shapes::keyExists($this->typed_schema, 'hackEnum')) {
if ($this->typed_schema['generateHackEnum'] ?? false) {
return $this->typed_schema['hackEnum'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm it’s a bummer that we have to fork here. I bet we could update the pre-existing branch to drop the leading \ without causing issues, though it would require regenerating a lot of code.

public function testStringEnum(): void {
$cases = vec[
shape(
'input' => darray['enum_string' => 'one'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: we should use dicts not darrays, darrays are legacy.

@scobb scobb merged commit 54f3ad2 into master Jan 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants