0

Source: https://www.php-fig.org/psr/psr-12/#43-properties-and-constants

In the 4.3 Properties and Constants section of PSR-12 there is a following example:

A property declaration looks like the following:

    <?php
    namespace Vendor\Package;
    class ClassName
    {
        public $foo = null;
        public static int $bar = 0;
    }

But when i try to run this it causes syntax error like this:

PHP Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) on line 6

Is this a syntax error in the PSR-12 example?

P.S. For Praveen Kumar Purushothaman. My question is about why in the PSR-12 there is a code example that doesn't work in current release of PHP? So right now this is an error in the PSR? Or it was done intentionally by the author? PHP 7.4 is still a candidate release and officially this code is not working.

cofirazak
  • 562
  • 6
  • 16

0 Answers0