Bug #81675 [NEW]: Undocumented change in get_class_vars behaviour with static properties in 8.1

From: Date: Tue, 30 Nov 2021 10:56:38 +0000
Subject: Bug #81675 [NEW]: Undocumented change in get_class_vars behaviour with static properties in 8.1
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238054@lists.php.net to get a copy of this message
From:             diede at yoast dot com
Operating system: 
PHP version:      8.1.0
Package:          *General Issues
Bug Type:         Bug
Bug description:Undocumented change in get_class_vars behaviour with static properties in 8.1

Description:
------------
I have a feeling that get_class_vars() received a bugfix. Previously
it included the current value of a static property, but now returns the
default/initial value instead. This now matches the documentation, but
the behaviour of previous PHP versions didn't match the documentation.

I can't find anything in the changelogs, docs and RFCs. Here's where we
looked:
- https://github.com/php/php-src/blob/php-8.1.0/UPGRADING
- https://www.php.net/manual/en/migration81.php
- https://www.php.net/manual/en/function.get-class-vars.php
- https://wiki.php.net/rfc#php_81
- https://github.com/php/php-src/blob/php-8.1.0/NEWS


This could at the very least be considered a breaking change and should
be documented.


Test script:
---------------
<?php
// https://3v4l.org/RjVk0
class MyClass {
    public static $myProperty;
}

MyClass::$myProperty = 3;
var_dump( get_class_vars( MyClass::class ) );

Expected result:
----------------
// Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13
array(1) {
  ["myProperty"]=>
  int(3)
}

Actual result:
--------------
// Output for 8.1.0
array(1) {
  ["myProperty"]=>
  NULL
}


-- 
Edit bug report at https://bugs.php.net/bug.php?id=81675&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81675&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81675&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81675&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81675&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81675&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81675&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81675&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81675&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81675&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81675&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81675&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81675&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81675&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81675&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81675&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81675&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81675&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#238054) next »