Skip to content

Instantly share code, notes, and snippets.

@rande
Created May 23, 2011 22:13
Show Gist options
  • Save rande/987737 to your computer and use it in GitHub Desktop.
Save rande/987737 to your computer and use it in GitHub Desktop.
Validation issue
<?php
class Model
{
protected $name = 'toto';
public function getName()
{
return $this->name;
}
}
class ModelProxy extends Model
{
public function getName()
{
var_dump('Catch');
return parent::getName();
}
}
$proxy = new ModelProxy;
var_dump($proxy->getName());
$reflectionMethod = new \ReflectionMethod('Model', 'getName');
var_dump($reflectionMethod->invoke($proxy));
$reflectionMethod = new \ReflectionMethod('ModelProxy', 'getName');
var_dump($reflectionMethod->invoke($proxy));
/*
output :
string(5) "Catch"
string(4) "toto"
string(4) "toto"
string(5) "Catch"
string(4) "toto"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment