[TYPO3-core] Can't we drop all those "@todo Define visibility" annotations?
Steffen Müller
typo3 at t3node.com
Fri Jan 18 18:48:32 CET 2013
Hi.
On 18.01.2013 17:46 Christian Müller wrote:
> I lately tried to do exactly that, indeed pretty difficult... One way
> would be to make the properties protected add a magic get method and
> deprecation log there.
>
Lot of overhead, but seems to work:
<?php
class PublicTestClass {
public $prop = 'foo';
public function __get($propName) {
// Trigger deprecationLog
if (isset($this->$propName)) {
return $this->$propName;
}
}
public function __set($propName, $value) {
// Trigger deprecationLog
$this->$propName = $value;
}
}
class ProtectedTestClass {
// API has changed from public to protected
protected $prop = 'foo';
public function __get($propName) {
// Trigger deprecationLog
if (isset($this->$propName)) {
return $this->$propName;
}
}
public function __set($propName, $value) {
// Trigger deprecationLog
$this->$propName = $value;
}
}
$public = new PublicTestClass();
echo $public->prop;
$public->prop = 'bar';
echo $public->prop;
$protected = new ProtectedTestClass();
echo $protected->prop;
$protected->prop = 'bar';
echo $protected->prop;
--
cheers,
Steffen
TYPO3 Blog: http://www.t3node.com/
Twitter: @t3node - http://twitter.com/t3node
More information about the TYPO3-team-core
mailing list