Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion language/oop5/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,42 @@ Fatal error: Uncaught Error: Cannot access private const Foo::BAZ in …
As of PHP 7.1.0 visibility modifiers are allowed for class constants.
</para>
</note>
<example>
<title>Class constant visibility variance check, as of PHP 8.3.0</title>
<programlisting role="php">
<![CDATA[
<?php

interface MyInterface
{
public const VALUE = 42;
}

class MyClass implements MyInterface
{
protected const VALUE = 42;
}
?>
]]>
</programlisting>
&example.outputs.83;
<screen>
<![CDATA[
Fatal error: Access level to MyClass::VALUE must be public (as in interface MyInterface) …
]]>
</screen>
</example>
<note>
<simpara>
As of PHP 8.3.0 visibility variance is checked more strictly.
Prior to this version, the visibility of a class constant could be different
from the visibility of the constant in the implemented interface.
</simpara>
</note>
<example>
<title>Fetch class constant syntax, as of PHP 8.3.0</title>
<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
class Foo {
public const BAR = 'bar';
Expand Down