Author: Christoph M. Becker (cmb69)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-12-08T19:44:47+01:00

Commit: 
https://github.com/php/web-php/commit/2782af2f26f4a5f71cf59caa0cb9680c938fb836
Raw diff: 
https://github.com/php/web-php/commit/2782af2f26f4a5f71cf59caa0cb9680c938fb836.diff

Fix trait constant example

As has been pointed out by Robert Landers[1], the PHP 8.2 example does
not error.  And even the pre PHP 8.2 example does not error where
indicated.  It does not appear to be useful to show the pre PHP 8.2
behavior (where it was not allowed to declare constants in traits); so
instead we show only a PHP 8.2 example which matches the description.

[1] <https://externals.io/message/119096#119100>

Closes GH-732.

Changed paths:
  M  releases/8.2/release.inc


Diff:

diff --git a/releases/8.2/release.inc b/releases/8.2/release.inc
index d679de914..e9fe8e767 100644
--- a/releases/8.2/release.inc
+++ b/releases/8.2/release.inc
@@ -256,32 +256,7 @@ PHP
                     ) ?></a>
             </h2>
             <div class="php8-compare__main">
-                <div class="php8-compare__block example-contents">
-                    <div class="php8-compare__label">PHP &lt; 8.2</div>
-                    <div class="php8-code phpcode">
-                        <?php highlight_php_trimmed(
-                            <<<'PHP'
-trait Foo
-{
-    public const CONSTANT = 1;
-
-    public function bar(): int
-    {
-        return self::CONSTANT; // Fatal error
-    }
-}
-
-class Bar
-{
-    use Foo;
-}
-PHP
-
-                        ); ?>
-                    </div>
-                </div>
-                <div class="php8-compare__arrow"></div>
-                <div class="php8-compare__block example-contents">
+                <div class="example-contents example-contents-full">
                     <div class="php8-compare__label 
php8-compare__label_new">PHP 8.2</div>
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
@@ -289,11 +264,6 @@ PHP
 trait Foo
 {
     public const CONSTANT = 1;
-
-    public function bar(): int
-    {
-        return self::CONSTANT; // Fatal error
-    }
 }
 
 class Bar
@@ -302,6 +272,7 @@ class Bar
 }
 
 var_dump(Bar::CONSTANT); // 1
+var_dump(Foo::CONSTANT); // Error
 PHP
                         ); ?>
                     </div>

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to