Voting

: two plus seven?
(Example: nine)

The Note You're Voting On

Anonymous
10 years ago
Using magic methods, especially __get(), __set(), and __call() will effectively disable autocomplete in most IDEs (eg.: IntelliSense) for the affected classes.

To overcome this inconvenience, use phpDoc to let the IDE know about these magic methods and properties: @method, @property, @property-read, @property-write.

/**
* @property-read name
* @property-read price
*/
class MyClass
{
private $properties = array('name' => 'IceFruit', 'price' => 2.49)

public function __get($name)
{
return $this->properties($name);
}
}

<< Back to user notes page

To Top