-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Increase type safety #87
base: master
Are you sure you want to change the base?
Commits on Mar 18, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 6f6cff0 - Browse repository at this point
Copy the full SHA 6f6cff0View commit details -
Fix missing return value in grabArticle
Not sure if this is expected but at least it works the same as before.
Configuration menu - View commit details
-
Copy full SHA for dfa7cb0 - Browse repository at this point
Copy the full SHA dfa7cb0View commit details -
Use helpers for content score manipulation
`DOMAttr::$value` must be a `string`. Let’s add helpers for manipulating the `readability` attribute so that we do not have to keep casting it from and to `string` in order to appease `strict_types`.
Configuration menu - View commit details
-
Copy full SHA for c83d337 - Browse repository at this point
Copy the full SHA c83d337View commit details -
Use PHP type hints instead of PHPDoc
PHP 7.4 supports property type hints. - `getInnerText` actually accepts `DOMNode`, not `DOMElement`, since it can be e.g. `DOMText`. Really, we just need the `textContent` property. - Since we now use property type hints, we can drop the `no_null_property_initialization` PHP-CS-Fixer rule.
Configuration menu - View commit details
-
Copy full SHA for 7a2ae65 - Browse repository at this point
Copy the full SHA 7a2ae65View commit details -
Use JSLikeHTMLElement in type hints
It is more specific then DOMElement. This allows us to get rid of the assertions in tests.
Configuration menu - View commit details
-
Copy full SHA for 1acfc6f - Browse repository at this point
Copy the full SHA 1acfc6fView commit details -
JSLikeHTMLElement: Get rid of magic properties
Will make it easier to statically analyze with PHPStan. This is a BC break.
Configuration menu - View commit details
-
Copy full SHA for e9c9dbc - Browse repository at this point
Copy the full SHA e9c9dbcView commit details -
Configuration menu - View commit details
-
Copy full SHA for b9fdf04 - Browse repository at this point
Copy the full SHA b9fdf04View commit details -
Nothing affecting correctness, just stuff making it easier for PHPStan to reason about the code. Remove `$errcontext` argument in `set_error_handler` since it is removed in PHP 8.
Configuration menu - View commit details
-
Copy full SHA for a12629e - Browse repository at this point
Copy the full SHA a12629eView commit details -
Configuration menu - View commit details
-
Copy full SHA for d2d7dcd - Browse repository at this point
Copy the full SHA d2d7dcdView commit details -
Fix hasSingleTagInsideElement method
It would fail for e.g. `<div> <p>foo</p> </div>`. mozilla/readability uses children for the tag lookup, which return only elements. PHP does not have children property so b580cf2 mistakenly used `childNodes` instead, but that can return any node type. Let’s filter the children ourselves. Also add comments from mozilla/readability’s `_hasSingleTagInsideElement`.
Configuration menu - View commit details
-
Copy full SHA for 273a95a - Browse repository at this point
Copy the full SHA 273a95aView commit details -
Converting `hasSingleTagInsideElement` into a type-safe getter will allow PHPStan to know the type of `newNode` is `DOMElement`.
Configuration menu - View commit details
-
Copy full SHA for ccdd166 - Browse repository at this point
Copy the full SHA ccdd166View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8cbb8a8 - Browse repository at this point
Copy the full SHA 8cbb8a8View commit details