Duplicate Static Definition

PHP reports when the same static variable has been declared twice in the same context.

PHP code

<?php

namespace a {
     function foo() {
        static $s;
        $s = 1;

        static $s;
        echo $s;
    }
}

Before

11

After

Duplicate declaration of static variable $s

PHP version change

This behavior changed in 8.3

Error Messages