php / php/doc-en

undocumented change in `get_class_vars` from php 8.0 to php 8.1

Open
#1,913 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

It appears that the behavior of get_class_vars has changed between 8.0 and 8.1

  • 8.0: get_class_vars yields the current value of the static variables (even if documentation says, it is the default value)
  • 8.1: get_class_vars yields the default value according to the documentation

try it out in https://onlinephp.io/c/5779d

<?php

class Foo {
	static $bar = "bar";
}

echo Foo::$bar;
var_dump(get_class_vars(Foo::class));

Foo::$bar = "foobar";
var_dump(get_class_vars(Foo::class));
image image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the get_class_vars documentation and reproduce the linked PHP 8.0 and 8.1 example first. Verify the distinction between current and default static values, then update the relevant documentation with the PHP 8.1 behavior and a version note; done means the documented behavior matches the verified result.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.