1.2.1007. Property Invasion

Property invasion exports a reference from an object, for external and direct modifications.

With a method that returns a reference, a link is created between an external variable and the private property. That way, it is possible to modify the object, without calling a property, or a method.

<?php

class x {
     private $p = 1;

     function &get() {
             return $this->p;
     }
}

$x = new x;
$y = &$x->get();
$y = 2;

print $x->get(); // 2

?>

1.2.1007.1. Connex PHP features

1.2.1007.1.1. Suggestions

1.2.1007.1.2. Specs

Short name

Classes/PropertyInvasion

Rulesets

All, Changed Behavior, Class Review

Exakat since

2.5.1

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud