Skip to content

Commit

Permalink
Support scalar types
Browse files Browse the repository at this point in the history
  • Loading branch information
dakorpar committed Oct 10, 2017
1 parent b832cb6 commit 1db03d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Kdyby/Aop/PhpGenerator/PointcutMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ public static function expandTypeHints(\ReflectionMethod $from, Code\Method $met

foreach ($from->getParameters() as $paramRefl) {
try {
$parameters[$paramRefl->getName()]->setTypeHint($paramRefl->isArray() ? 'array' : ($paramRefl->getClass() ? '\\' . $paramRefl->getClass()->getName() : ''));
if(!in_array($parameters[$paramRefl->getName()]->getTypeHint(),['boolean', 'integer', 'float', 'string', 'object', 'int', 'bool', ])) {
$parameters[$paramRefl->getName()]->setTypeHint($paramRefl->isArray() ? 'array' : ($paramRefl->getClass() ? '\\' . $paramRefl->getClass()->getName() : ''));
}
} catch (\ReflectionException $e) {
if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
$parameters[$paramRefl->getName()]->setTypeHint('\\' . $m[1]);
Expand Down
3 changes: 1 addition & 2 deletions tests/KdybyTests/Aop/AdvisedClassType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ class AdvisedClassTypeTest extends Tester\TestCase
$testClass = ClassType::from(TestClass::class);

$method = Kdyby\Aop\PhpGenerator\AdvisedClassType::setMethodInstance($testClass, $testClass->getMethod('first'));
$string = $methodCode = $method->__toString();
Assert::count(2, $method->getParameters());
}


}

class TestClass
Expand Down

0 comments on commit 1db03d8

Please sign in to comment.