cakephp-codesniffer icon indicating copy to clipboard operation
cakephp-codesniffer copied to clipboard

Problems with Property Hooks

Open LordSimal opened this issue 1 year ago • 3 comments

Doing a simple

class ConfigChecker
{
    public FTPInterface $ftpCheckObject {
        get {
            return $this->ftpCheckObject;
        }
        set(FTPInterface $value) {
            $this->ftpCheckObject = $value;
        }
    }
}

causes the following errors:

--------------------------------------------------------------------------------
FOUND 10 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------
 10 | ERROR   | There must not be more than one property declared per statement
 12 | ERROR   | Visibility must be declared on property "$this"
 12 | ERROR   | Scope modifier not specified for member variable "$this"
 14 | WARNING | Code after the RETURN statement on line 12 cannot be executed
 14 | ERROR   | There must not be more than one property declared per statement
 14 | ERROR   | Visibility must be declared on property "$value"
 14 | ERROR   | Scope modifier not specified for member variable "$value"
 15 | WARNING | Code after the RETURN statement on line 12 cannot be executed
 15 | ERROR   | There must not be more than one property declared per statement
 15 | ERROR   | Visibility must be declared on property "$this"
 15 | ERROR   | Scope modifier not specified for member variable "$this"
 15 | ERROR   | Scope modifier not specified for member variable "$value"
--------------------------------------------------------------------------------

LordSimal avatar Dec 28 '24 17:12 LordSimal

Seems like PHP_Codesniffer is not 8.4 ready yet

https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/734

LordSimal avatar Dec 28 '24 18:12 LordSimal

phpcs v4 beta1 is out. Hoping by the time it's stable it will have support for property hooks.

ADmad avatar May 18 '25 10:05 ADmad

4.0.0 was released yesterday

mirko-pagliai avatar Sep 17 '25 06:09 mirko-pagliai