File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,42 @@ Fatal error: Uncaught Error: Cannot access private const Foo::BAZ in …
120120 As of PHP 7.1.0 visibility modifiers are allowed for class constants.
121121 </para >
122122 </note >
123+ <example >
124+ <title >Class constant visibility variance check, as of PHP 8.3.0</title >
125+ <programlisting role =" php" >
126+ <![CDATA[
127+ <?php
128+
129+ interface MyInterface
130+ {
131+ public const VALUE = 42;
132+ }
133+
134+ class MyClass implements MyInterface
135+ {
136+ protected const VALUE = 42;
137+ }
138+ ?>
139+ ]]>
140+ </programlisting >
141+ &example.outputs.83;
142+ <screen >
143+ <![CDATA[
144+ Fatal error: Access level to MyClass::VALUE must be public (as in interface MyInterface) …
145+ ]]>
146+ </screen >
147+ </example >
148+ <note >
149+ <simpara >
150+ As of PHP 8.3.0 visibility variance is checked more strictly.
151+ Prior to this version, the visibility of a class constant could be different
152+ from the visibility of the constant in the implemented interface.
153+ </simpara >
154+ </note >
123155 <example >
124156 <title >Fetch class constant syntax, as of PHP 8.3.0</title >
125157 <programlisting role =" php" >
126- <![CDATA[
158+ <![CDATA[
127159<?php
128160class Foo {
129161 public const BAR = 'bar';
You can’t perform that action at this time.
0 commit comments