-
|
Hi, I'm trying to use property hooks in my projects, and currently I'm having the issue that phpcs (Generic.WhiteSpace.ScopeIndent) incorrectly seems to handle control structures inside the hooks. Is there anyone else who has been running into this issue and found a working solution? Using the full example from the php manual <?php
class Example
{
private bool $modified = false;
public string $foo = 'default value' {
get {
if ($this->modified) {
return $this->foo . ' (modified)';
}
return $this->foo;
}
set(string $value) {
$this->foo = strtolower($value);
$this->modified = true;
}
}
}
$example = new Example();
$example->foo = 'changed';
print $example->foo;
?>phpcs thinks it should be formatted the following way: <?php
class Example
{
private bool $modified = false;
public string $foo = 'default value' {
get {
if ($this->modified) {
return $this->foo . ' (modified)';
}
return $this->foo;
}
set(string $value) {
$this->foo = strtolower($value);
$this->modified = true;
}
}
}
$example = new Example();
$example->foo = 'changed';
print $example->foo;
?>Reported error from |
Beta Was this translation helpful? Give feedback.
Answered by
jrfnl
Apr 16, 2026
Replies: 1 comment 4 replies
-
|
See #734. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dcolt Before development can start, it needs an (approved) design on how property hooks should be tokenized for PHPCS to not break existing sniffs. Submitting a PR for this, is not the way to do things as it will hinder the discussion about the design.