コード例 #1
0
ファイル: Field.php プロジェクト: bugadani/orminy
 /**
  * @param $object
  * @param $value
  *
  * @return mixed The new value
  */
 public function set($object, $value)
 {
     $this->setter->set($object, $value);
     return $value;
 }
コード例 #2
0
ファイル: SetterTest.php プロジェクト: michaelmoussa/maam
 public function testHasCorrectShortName()
 {
     $setter = new Setter([]);
     $this->assertSame('Setter', $setter->getShortName());
 }
コード例 #3
0
ファイル: lcfirst.php プロジェクト: badlamer/hhvm
        }
    }
    public function __set($key, $value)
    {
        if (array_key_exists($key, $this->vars)) {
            $this->vars[$key] = $value;
        }
    }
    public function __get($key)
    {
        if (array_key_exists($key, $this->vars)) {
            return $this->vars[$key];
        }
    }
}
$class = new Setter();
$class->setPartnerName('partnerName');
var_dump($class->partnerName);
echo "\n--- Testing objects ---\n";
/* we get "Catchable fatal error: saying Object of class could not be converted
        to string" by default when an object is passed instead of string:
The error can be  avoided by choosing the __toString magix method as follows: */
class string
{
    function __toString()
    {
        return "Hello world";
    }
}
$obj_string = new string();
var_dump(lcfirst("{$obj_string}"));