Use PHP native html parsing (drops support for PHP < 8.4)#24
Merged
Conversation
The original test data for this feature had invalid HTML (the `<time>` element was not actually in a cell).
When we switched to using masterminds/html5 for table parsing, the parse error detection & handling was not updated. This is partly because there are actually very few cases in which input is actually *invalid* as html (as opposed to being non-conformant, which isn't checked). And we did not have test cases proving these examples. Fixed the handling of this ahead of moving to native html parsing in 1.4 (which is treated differently anyway).
We will be dropping support for older PHP versions, so that we can (in the next commit) switch to using native html5 parsing instead of having a masterminds/html5 dependency.
The newer native library would also allow us to refactor more of the HTMLStringTableParser, but this would mean BC breaks to our public API since the old code is written with protected methods and non-final classes.
5d5bc3c to
23b87f0
Compare
acoulton
commented
Mar 10, 2026
| sprintf("Expected html root element but got %s\n\n===HTML===\n%s", get_debug_type($table_elem), $html), | ||
| ); | ||
| } | ||
| $table = \simplexml_import_dom($table_elem); |
Member
Author
There was a problem hiding this comment.
We could in theory drop a bunch of the to/from simplexml stuff, the problem is we'd need a 2.0 release as the internal API of this class is all protected rather than private and the implementation expects to be passing simplexml nodes around.
There's a bigger set of tidying / refactoring we'd need to do for a 2.0 so I've gone with just the minimum to use the native parser without breaking BC.
craig410
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates our supported PHP versions so that we can use the native HTML5 parser in php >= 8.4 instead of having a dependency on masterminds/html5.