> Le 13 déc. 2022 à 16:34, Claude Pache <claude.pa...@gmail.com> a écrit : > > > Hi, > > As of today, the following declarations are rejected as syntax errors: > > ```php > class C { > $a; > int $b; > } > ``` > > while the following declarations are accepted with implicit `public` > visibility: > > ```php > class C { > static $c; > readonly int $d; > } > ``` > > It would be reasonable to propose to allow to consistently omit the `public` > keyword. But allowing to omit it in some cases (including the most > controversial one: `protected(set)`) and not in other cases...? Because of > this inconsistency, people are incited to always write explicitly `public` > anyway. > > —Claude
However, I’m just realising that omitting `public` in declarations like `public $a` and `public int $b` is probably not a good idea, because it is incompatible with constructor property promotion, as `function __construct(public int $b) { }`, and `function __construct(int $b) { }` have different meanings. —Claude