Skip to content

fdomdocument issue on PHP 8.2 #424

Description

@dereckson

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions