krakjoe / uopz

User Operations for Zend
Other
358 stars 47 forks source link

PHP 8.3: uopz_get_static() may no longer retrieve initializer values #176

Closed cmb69 closed 3 months ago

cmb69 commented 3 months ago

Since arbitrary static variable initializers have been implemented, uopz_get_static() may no longer retrieve initializer values of static variables, because these may now be only initialized when the function is called the first time. ReflectionFunction::getStaticVariables() has exactly the same BC breaking behavior, as outlined in the RFC. For example, see tests/007.phpt (aka. my name is Bond, Broken Bond), which now fails with the following diff:

         int(5)
       }
       ["bar"]=>
016-   string(3) "bar"
016+   NULL
     }
     array(2) {
       ["vars"]=>

As you see, for static initializers which cannot be evaluated at compile time, NULL is reported as initial value, same as for unitialized static variables.

Since this cannot be fixed, we should fix the test, and document the issue.

cmb69 commented 3 months ago

The test is supposed to be fixed via https://github.com/krakjoe/uopz/commit/9e8a044589cf2ac998e4f018d5e3af0ed6792426.

cmb69 commented 3 months ago

Documented via https://github.com/php/doc-en/commit/b5e484908859c4d96e212fb4ec6f5af2526db288.