Skip to content

Commit 7d0bede

Browse files
committed
Add Typed class constants examples
1 parent 199f58e commit 7d0bede

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

releases/8.3/release.inc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ PHP
7979
<div class="php8-code phpcode">
8080
<?php highlight_php_trimmed(
8181
<<<'PHP'
82-
// TODO
82+
interface I {
83+
// We may naively assume that the PHP constant is always a string
84+
const PHP = 'PHP 8.2';
85+
}
86+
87+
class Foo implements I {
88+
const PHP = []; // But it may be an array...
89+
}
90+
91+
// Parse error
8392
PHP
8493

8594
); ?>
@@ -91,7 +100,15 @@ PHP
91100
<div class="php8-code phpcode">
92101
<?php highlight_php_trimmed(
93102
<<<'PHP'
94-
// TODO
103+
interface I {
104+
const string PHP = 'PHP 8.3';
105+
}
106+
107+
class Foo implements I {
108+
const string PHP = [];
109+
}
110+
111+
// Fatal error: Cannot use array as value for class constant Foo::PHP of type string
95112
PHP
96113
); ?>
97114
</div>
@@ -141,7 +158,6 @@ PHP
141158
<div class="php8-code phpcode">
142159
<?php highlight_php_trimmed(
143160
<<<'PHP'
144-
// TODO
145161
use PHPUnit\Framework\TestCase;
146162
147163
final class MyTest extends TestCase
@@ -359,7 +375,8 @@ PHP
359375
<li>Negative indices in arrays.</li>
360376
<li>Changes to the <code>range</code> function.</li>
361377
<li>Traits and static properties.</li>
362-
<li>The <code>U_MULTIPLE_DECIMAL_SEPERATORS</code> constant had been deprecated in favor of <code>U_MULTIPLE_DECIMAL_SEPARATORS</code>.</li>
378+
<li>The <code>U_MULTIPLE_DECIMAL_SEPERATORS</code> constant had been deprecated in favor of <code>U_MULTIPLE_DECIMAL_SEPARATORS</code>.
379+
</li>
363380
<li>The <code>MT_RAND_PHP</code> Mt19937 variant is deprecated.</li>
364381
<li><code>ReflectionClass::getStaticProperties</code> is no longer nullable.</li>
365382
</ul>

0 commit comments

Comments
 (0)