1.2.1412. Var Keyword

Var was used in PHP 4 to mark properties as public. Nowadays, new keywords are available : public, protected, private. Var is equivalent to public.

It is recommended to avoid using var, and explicitly use the new keywords.

<?php

class foo {
    public $bar = 1;
    // Avoid var
    //var $bar = 1;
}

?>

See also Visibility.

1.2.1412.1. Suggestions

  • It is recommended to avoid using var, and explicitly use the new keywords : private, protected, public

1.2.1412.2. Specs

Short name

Classes/OldStyleVar

Rulesets

All, Analyze

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

visibility

ClearPHP

no-php4-class-syntax

Examples

xataface

Available in

Entreprise Edition, Exakat Cloud