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 ability to set lib xml parameters #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bytestream
Copy link

@bytestream bytestream commented May 20, 2021

Motivation

This library fails to parse documents with high nesting levels. Use of LIBXML_PARSEHUGE is required in such cases.

Resolves another unmerged PR #204
Closes #200

@bytestream bytestream changed the title Add LIBXML_PARSEHUGE Add ability to set lib xml parameters May 21, 2021
@bytestream
Copy link
Author

@stof any thoughts on my three PRs? They should all be pretty harmless (new methods, previous functionality unchanged)

@Thorry84
Copy link

@stof Any update on this? I need this as well.

Copy link

@Imran-imtiaz48 Imran-imtiaz48 left a comment

Choose a reason for hiding this comment

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

Positive Aspects:

  1. Constructor Logic: The constructor effectively checks for the existence of the CssSelectorConverter class before instantiating it. This is good practice for maintaining compatibility and preventing runtime errors when the class is not available.
  2. Setter Method: The setLibXmlOptions() method follows a clean approach for setting the libXmlOptions parameter and returning the instance (self), which allows for method chaining. This is a useful design pattern that promotes cleaner code and better readability.

Suggestions for Improvement:

  1. Type Hinting in Constructor: You could consider adding type hinting for the $cssConverter property by declaring it explicitly as a type or interface. It will improve code readability and IDE support.

    private ?CssSelectorConverter $cssConverter = null;

    This also initializes it as null by default, which can help avoid uninitialized property warnings.

  2. LibXml Options Parameter Type: You could add a type declaration for the $options parameter in the setLibXmlOptions() method. Since PHP 7.0, scalar type declarations like int can be used:

    public function setLibXmlOptions(int $options): self
  3. DocBlock Enhancements: Adding a DocBlock comment for the constructor would improve the documentation and clarify the purpose of the $cssConverter. It could describe what the CssSelectorConverter is and why it's being conditionally instantiated.

    /**
     * Constructor method.
     * Initializes CssSelectorConverter if available.
     */
  4. Error Handling for Non-Existence of CssSelectorConverter: Although you check if the class exists, it might be helpful to either log a message or throw a custom exception if it doesn’t, depending on the context of the application.

Conclusion:

This code demonstrates good object-oriented practices. With the addition of type hinting and better documentation, it will be even more robust and maintainable. Consider adding error handling for potential edge cases such as the absence of the CssSelectorConverter class. Great work overall!

@Thorry84
Copy link

Thorry84 commented Oct 1, 2024

Did you just review a patch from 3.5 years ago using AI? Why?

@oliverklee
Copy link

@Thorry84 My best guess is that this might be related to Hacktoberfest, which started today Or because @Imran-imtiaz48 gamifies their GitHub contributions, which encourages reviews (and sounds like fun!). 🙂

Anyway, I welcome this review, even if the PR is a bit on the stale side and the PR probably needs an update. (We still should review this PR as humans, though.)

@bytestream
Copy link
Author

I will update the PR if @stof explicitly says he will merge it

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.

Adds doctypes when not needed/requested
4 participants