rspec/rules/S1765/php/rule.adoc

40 lines
926 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
The PHP 4 method of declaring a variable, using the ``++var++`` keyword, was deprecated in early versions of PHP 5. Even though it's not considered deprecated in the most recent versions, it's nonetheless not best practice to use it. When ``++var++`` does appear, it is interpreted as a synonym for ``++public++`` and treated as such. Therefore ``++public++`` should be used instead.
From the PHP Manual:
____
The PHP 4 method of declaring a variable with the var keyword is still supported for compatibility reasons (as a synonym for the public keyword). In PHP 5 before 5.1.3, its usage would generate an E_STRICT warning.
____
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
<?php
class Foo
{
var $bar = 1;
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
<?php
class Foo
{
public $bar = 1;
}
----
ifdef::rspecator-view[]
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::rspecator-view[]