Visibility MUST be declared on all properties and methods; abstract
and
final
MUST be declared before the visibility; static
MUST be declared
after the visibility.
The structural elements to fix (PHP >= 7.1 required for const
).
Allowed values: a subset of ['property', 'method', 'const']
Default value: ['property', 'method', 'const']
Default configuration.
--- Original
+++ New
<?php
class Sample
{
- var $a;
- static protected $var_foo2;
+ public $a;
+ protected static $var_foo2;
- function A()
+ public function A()
{
}
}
With configuration: ['elements' => ['const']]
.
--- Original
+++ New
<?php
class Sample
{
- const SAMPLE = 1;
+ public const SAMPLE = 1;
}
The rule is part of the following rule sets:
- @PHP71Migration
- Using the @PHP71Migration rule set will enable the
visibility_required
rule with the default config. - @PHP73Migration
- Using the @PHP73Migration rule set will enable the
visibility_required
rule with the default config. - @PHP74Migration
- Using the @PHP74Migration rule set will enable the
visibility_required
rule with the default config. - @PHP80Migration
- Using the @PHP80Migration rule set will enable the
visibility_required
rule with the default config. - @PHP81Migration
- Using the @PHP81Migration rule set will enable the
visibility_required
rule with the default config. - @PSR12
- Using the @PSR12 rule set will enable the
visibility_required
rule with the default config. - @PSR2
Using the @PSR2 rule set will enable the
visibility_required
rule with the config below:['elements' => ['method', 'property']]
- @PhpCsFixer
- Using the @PhpCsFixer rule set will enable the
visibility_required
rule with the default config. - @Symfony
- Using the @Symfony rule set will enable the
visibility_required
rule with the default config.