Improved behavior support, fixes #2550

call hasMethod() instead of using method_exists
This commit is contained in:
Carsten Brandt
2014-02-26 14:18:24 +01:00
parent 6f9e9cd5b0
commit 33d6acba25
3 changed files with 4 additions and 4 deletions

View File

@@ -136,13 +136,13 @@ trait ActiveRelationTrait
* Finds the related records for the specified primary record.
* This method is invoked when a relation of an ActiveRecord is being accessed in a lazy fashion.
* @param string $name the relation name
* @param ActiveRecordInterface $model the primary model
* @param ActiveRecordInterface|BaseActiveRecord $model the primary model
* @return mixed the related record(s)
* @throws InvalidParamException if the relation is invalid
*/
public function findFor($name, $model)
{
if (method_exists($model, 'get' . $name)) {
if ($model->hasMethod('get' . $name)) {
$method = new \ReflectionMethod($model, 'get' . $name);
$realName = lcfirst(substr($method->getName(), 3));
if ($realName !== $name) {