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: fixed extending final class (DomException) #81

Merged
merged 1 commit into from
Dec 21, 2022
Merged

fix: fixed extending final class (DomException) #81

merged 1 commit into from
Dec 21, 2022

Conversation

AmraniCh
Copy link
Contributor

CHANGES

  • Exception\InvalidMarkupException is now extend the RuntimeException instead of DomException.

EXPLAINATION

DomException is a final class, I think It exist because PHP use this exception internally when working with the DOM extension.

// Change libxml config
$libxmlCurrent = libxml_use_internal_errors(true);

$loaded = $dom->loadHTML($this->fixContentEncoding($content));

// Restore libxml config
libxml_use_internal_errors($libxmlCurrent);

if (!$loaded) {
    throw new InvalidMarkupException("Can't load the given HTML via DomDocument");
}

Here in your code, if the $loaded variable is false, a fatal error will be raised as the following:

Fatal error: Class JoliTypo\Exception\InvalidMarkupException may not inherit from final class (DOMException) in /workspaces/JoliTypo/src/JoliTypo/Exception/InvalidMarkupException.php on line 15

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

Very good catch.

Thanks

@AmraniCh
Copy link
Contributor Author

Very glad to help, thank you too!

@AmraniCh AmraniCh closed this Dec 21, 2022
@AmraniCh AmraniCh reopened this Dec 21, 2022
@lyrixx lyrixx merged commit 5b1abc0 into jolicode:master Dec 21, 2022
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.

None yet

2 participants