seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
76 stars 39 forks source link

Additional `cs:info` properties throw warning on PHP 8.2 #174

Closed adam-vessey closed 11 months ago

adam-vessey commented 1 year ago

Please follow the general troubleshooting steps first:

Bug reports:

Warnings emitted under PHP 8.2 due to other CSL 1.0.1 properties.

Used CSL stylesheet:

http://www.zotero.org/styles/chicago-fullnote-bibliography

chicago-fullnote-bibliography.csl

Used CSL metadata

Please replace these lines with your used metadata, for instance:

Not relevant for the issue, any will do.


The warnings in particular:

Deprecated function: Creation of dynamic property Seboettg\CiteProc\Root\Info::$category is deprecated in Seboettg\CiteProc\Root\Info->__construct() (line 62 of /var/www/html/vendor/seboettg/citeproc-php/src/Root/Info.php). 
Deprecated function: Creation of dynamic property Seboettg\CiteProc\Root\Info::$summary is deprecated in Seboettg\CiteProc\Root\Info->__construct() (line 62 of /var/www/html/vendor/seboettg/citeproc-php/src/Root/Info.php). 
Deprecated function: Creation of dynamic property Seboettg\CiteProc\Root\Info::$updated is deprecated in Seboettg\CiteProc\Root\Info->__construct() (line 62 of /var/www/html/vendor/seboettg/citeproc-php/src/Root/Info.php). 
Deprecated function: Creation of dynamic property Seboettg\CiteProc\Root\Info::$rights is deprecated in Seboettg\CiteProc\Root\Info->__construct() (line 62 of /var/www/html/vendor/seboettg/citeproc-php/src/Root/Info.php). 

It appears that chicago-fullnote-bibliography defines cs:info/cs:category elements as per the 1.0.1 spec, which throws this warning.

In the warnings, it's flagging:

However, it appears that this could pop for other allowed properties, such as:

Naively, these could probably be stashed in something like:

diff --git a/src/Root/Info.php b/src/Root/Info.php
index 50a4666..2656c99 100644
--- a/src/Root/Info.php
+++ b/src/Root/Info.php
@@ -34,6 +34,8 @@ class Info
      */
     private $links;

+    private $misc = [];
+
     public function __construct(SimpleXMLElement $node)
     {
         $this->authors = [];
@@ -95,4 +97,13 @@ class Info
     {
         return $this->links;
     }
+
+    public function __get(string $name) {
+      return $this->misc[$name] ?? NULL;
+    }
+
+    public function __set(string $name, $value) : void {
+      $this->misc[$name][] = $value;
+    }
+
 }