From: jevgeni at geimanen dot com
Operating system: Any
PHP version: 5.3.0beta1
PHP Bug Type: Feature/Change Request
Bug description: New magic method __setValue for REAL type checking.
Description:
------------
It's a feature request for a new magic method named __setValue (could be
other more suitable name)
There is already magic method named __set, which is called when
inaccessible MEMBER is called. The one I propose should be called when
Object is called, receive the value that this object is being set to, and
return new value. For example:
class Int32 {
function __setValue($value) {
if (!is_int($value)) throw new Exception("Type checking...");
return $value;
}
}
class A {
public $intVar;
public function __construct() {
$this->intVar = new Int32();
}
}
$a = new A();
$a->intVar = 12; //is ok
$a->intVar = "asdf"; //throws exception
That feature would give TONES of new possibilities, type checking is one
of them.
--
Edit bug report at http://bugs.php.net/?id=47301&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47301&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47301&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47301&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47301&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47301&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47301&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47301&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47301&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47301&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47301&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47301&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47301&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47301&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47301&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47301&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47301&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47301&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47301&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47301&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47301&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47301&r=mysqlcfg