Is there a way to disable adding properties into a class from an instance of the class.
What I mean is this:
Consider this class:
class a {
private $v1;
public $v2;
function func(){
...
}
}
If I do this:
$ins = new a;
$ins->temp = "A variable created from outside the class! C*ap!";
var_dump($ins);
The output:
object(a)#1 (3) {
["v1":"a":private]=>
NULL
["v2"]=>
NULL
["temp"]=>
string(48) "A variable created from outside the class! C*ap!"
}
Can this be disabled?`
Perhaps you can implement
__set()and throw an exception from there: