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 issue with intepreting unbounded sequences as having a max limit of 2 #76

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

jbuncle
Copy link
Contributor

@jbuncle jbuncle commented Nov 29, 2023

Fix for issue as described in goetas-webservices/xsd2php#135 where sequences with unbounded maxOccurs are being treated as having a limit of 2 when generating validation rules.

<xs:sequence maxOccurs="unbounded">
</xs:sequence>

Was generating validation rules as:

            -
                Count:
                    max: 2
                    groups:
                        - xsd_rules

Where they should be unlimited

Copy link
Collaborator

@Guite Guite left a comment

Choose a reason for hiding this comment

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

I am not sure but for me it looks like it should be something like:

        $max =
            (
                (is_int($max) && (bool) $max) ||
                0 < $node->getAttribute('maxOccurs')
            ) && ('unbounded' !== $node->getAttribute('maxOccurs'))
                ? (int) min((int) $max, $node->getAttribute('maxOccurs'))
                : null;

similarly as it is done with $min further below.

Can you please review this proposal?

@Guite
Copy link
Collaborator

Guite commented Nov 29, 2023

@goetas can you also maybe take a look at this?

@goetas
Copy link
Member

goetas commented Nov 29, 2023

@jbuncle can you please add a test for this?

@Guite
Copy link
Collaborator

Guite commented Dec 11, 2023

@jbuncle I like that you extracted the logic into a dedicated method loadMaxFromNode. Would you please invest a few more minutes in order to do the same with the min value (introduce loadMinFromNode as well)? Thank you very much!

@Guite
Copy link
Collaborator

Guite commented Jan 12, 2024

do the same with the min value (introduce loadMinFromNode as well)

will do that in a separate step

thanks for your contribution

@Guite Guite merged commit 47866e8 into goetas-webservices:master Jan 12, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants