-
Notifications
You must be signed in to change notification settings - Fork 94
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
CucumberND table headers might be missing #286
Comments
Well, is this property actually optional in the Cucumber format that we want to load here ? That's the first question. If it is not actually optional, we should fix the type (option 1). If it is indeed optional, we should fix the code (option 2 is bad in any case: if phpstan tells us that our code is broken, ignoring it still makes our code broken) |
I cannot fully answer that because this was the first time I'm looking at the code and I haven't in fact even used it before (as far as I know). The link I posted seemed authoritative - or at least, that seemed to be the point of the https://github.com/cucumber/messages repo. The generated typescript also seems to make example table headers optional: https://github.com/cucumber/messages/blob/e1537b07e511feb6405ed9aa00261ff79d8a9710/javascript/src/messages.ts#L174 as well as the spec here: https://github.com/cucumber/messages/blob/main/messages.md#examples (honestly I don't fully understand the reasoning, it seems to me that examples must have a header - otherwise how would it map the values to placeholders? and additionally, how can it determine when a row is a header and when it isn't? afaik the top row was always considered as the header) |
Making the PHPStan part required would technically break spec parity (option 1). On the other hand, putting the header parsing in a condition (option 3) might put us in a bind, seeing as we do not distinguish between a header row and a table without a header (we just keep rows). |
The cucumber parsers no longer populate TableHeader - I believe it's still in the JSON schema for BC reasons If this class is only being used for parsing the testData (I can't recall) it's fine to assume it'll never be set. |
The following line:
Gherkin/src/Behat/Gherkin/Loader/CucumberNDJsonAstLoader.php
Line 160 in e016902
assumes that
tableHeader
is always set, but according to the spec schema, tableHeader is not required, and therefore optional.I discovered this while implementing PHPStan fixes, using hand-written schema in PHPStan types DSL:
What shall we do about this?
?
) and generally ignore the code.@phpstan-ignore-next-line
)I think option 3 sounds reasonable, but we need to be sure it doesn't change behaviour.
The text was updated successfully, but these errors were encountered: