Skip to content

Commit

Permalink
Fix ReadOnly method proxy return when parent return type is void
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed Feb 14, 2018
1 parent d1fd4e5 commit 35e6249
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Hydrator/ReadOnlyHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function getProxyDirectory()
/**
* @param \ReflectionMethod $reflectionMethod
* @param array $properties
* @return string|false
* @return array
*/
protected function getUsedProperties(\ReflectionMethod $reflectionMethod, $properties)
{
Expand Down Expand Up @@ -276,19 +276,24 @@ protected function getPhpForMethod(\ReflectionMethod $reflectionMethod, array $p
case 'parent':
throw new \Exception('Function with return type parent can\'t be overloaded.');
default:
$returnType = $this->getFullQualifiedClassName(static::extractNameFromReflexionType($reflectionMethod->getReturnType()));
$returnType = $this->getFullQualifiedClassName(
static::extractNameFromReflexionType($reflectionMethod->getReturnType())
);
}
}
$returnKeyWord = ($returnType === 'void') ? null : 'return ';

$signature .= $returnType;
} else {
$returnKeyWord = 'return ';
}

$php = <<<PHP
$signature
{
\$this->assertReadOnlyPropertiesAreLoaded(array($propertiesToAssert));

return call_user_func_array(array('parent', '$method'), func_get_args());
${returnKeyWord}call_user_func_array(array('parent', '$method'), func_get_args());
}
PHP;

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![version](https://img.shields.io/badge/version-2.2.1-green.svg)](https://github.com/steevanb/doctrine-read-only-hydrator/tree/2.2.1)
[![version](https://img.shields.io/badge/version-2.2.2-green.svg)](https://github.com/steevanb/doctrine-read-only-hydrator/tree/2.2.2)
[![doctrine](https://img.shields.io/badge/doctrine/orm-^2.4.8-blue.svg)](http://www.doctrine-project.org)
[![php](https://img.shields.io/badge/php-^5.4.6%20||%20^7.0-blue.svg)](http://www.doctrine-project.org)
![Lines](https://img.shields.io/badge/code%20lines-1227-green.svg)
![Lines](https://img.shields.io/badge/code%20lines-1226-green.svg)
![Total Downloads](https://poser.pugx.org/steevanb/doctrine-read-only-hydrator/downloads)
[![SensionLabsInsight](https://img.shields.io/badge/SensionLabsInsight-platinum-brightgreen.svg)](https://insight.sensiolabs.com/projects/bd1b7a42-6a2c-4918-9986-3361dd40cc86/analyses/27)
[![SensionLabsInsight](https://img.shields.io/badge/SensionLabsInsight-platinum-brightgreen.svg)](https://insight.sensiolabs.com/projects/bd1b7a42-6a2c-4918-9986-3361dd40cc86/analyses/30)
[![Scrutinizer](https://scrutinizer-ci.com/g/steevanb/doctrine-read-only-hydrator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/steevanb/doctrine-read-only-hydrator/)

doctrine-read-only-hydrator
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### [2.2.2](../../compare/2.2.1...2.2.2) (2018-02-14)

- Fix ReadOnly method proxy return when parent return type is void

### [2.2.1](../../compare/2.2.0...2.2.1) (2017-09-04)

- Fix ReadOnlyProxy not added to classMetadata list, you can now use $queryBuilder->getParameter('foo', $foo) instead of $queryBuilder->getParameter('foo', $foo->getId()
Expand Down

0 comments on commit 35e6249

Please sign in to comment.