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

fdomdocument issue on PHP 8.2 #424

Open
dereckson opened this issue Mar 26, 2023 · 2 comments
Open

fdomdocument issue on PHP 8.2 #424

dereckson opened this issue Mar 26, 2023 · 2 comments

Comments

@dereckson
Copy link
Contributor

PHP 8.2 adds a new deprecation to the archive fdomdocument library, which breaks phpdox:

PHP Version: 8.2.4 (Linux)
PHPDox Version: eb943cb-dirty
ErrorException: E_DEPRECATED
Location: /opt/phpdox/vendor/theseer/fdomdocument/src/fDOMDocument.php (Line 251)

DOMDocument::save(): Passing null to parameter #2 ($options) of type int is deprecated

No stacktrace available

The DOMDocument::save signature is:

public DOMDocument::save(string $filename, int $options = 0): int|false

Library is documented to still work on PHP 7, so this isn't a proper fix, but last year I used this code on a development server to fix all deprecations:

            $tmp = match ($options) {
                NULL => parent::save($filename),
                default => parent::save($filename, $options),
            };

To stay compatible with PHP 7, and as 0 is the default value for $options, could we have more simply this instead?

diff --git a/src/fDOMDocument.php b/src/fDOMDocument.php
index 52f9df0..9ca04a6 100644
--- a/src/fDOMDocument.php
+++ b/src/fDOMDocument.php
@@ -247,7 +247,7 @@ namespace TheSeer\fDOM {
          * @return integer bytes saved
          */
         #[\ReturnTypeWillChange]
-        public function save($filename, $options = NULL) {
+        public function save($filename, $options = 0) {
             $tmp = parent::save($filename, $options);
             if (!$tmp) {
                 throw new fDOMException("Saving XML to file '$filename' failed", fDOMException::SaveError);

@dereckson
Copy link
Contributor Author

Tested on our CI infrastructure the second simplest solution, seems to work well.

@theseer
Copy link
Owner

theseer commented Mar 26, 2023

I'll have a look upcoming week. Sounds like something we could be doing.

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

No branches or pull requests

2 participants