From 16e53559ad5dc17fc71458943988ce20be7e53ec Mon Sep 17 00:00:00 2001 From: Pere Orga Date: Sat, 11 Jan 2025 00:30:28 +0100 Subject: [PATCH 1/2] describe behavior of static variables in anonymous functions --- language/variables.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/language/variables.xml b/language/variables.xml index bb92d638b8a7..28f7fcfeac3c 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -527,6 +527,37 @@ function foo(){ + + Static variables inside anonymous functions persist only within that + specific function instance. If the anonymous function is recreated on each + call, the static variable will be reinitialized. + + + + Static variables in anonymous functions + + +]]> + + + + As of PHP 8.1.0, when a method using static variables is inherited (but not overridden), the inherited method will now share static variables with the parent method. From 7bd6549d02989e957aa41e91f4555bb6e899b631 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 27 Jan 2025 14:47:26 +0000 Subject: [PATCH 2/2] Markup nit --- language/variables.xml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/language/variables.xml b/language/variables.xml index 28f7fcfeac3c..f38b9210b7df 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -532,10 +532,9 @@ function foo(){ specific function instance. If the anonymous function is recreated on each call, the static variable will be reinitialized. - - - Static variables in anonymous functions - + + Static variables in anonymous functions + ]]> - - - + + As of PHP 8.1.0, when a method using static variables is inherited (but not overridden),