Skip to content

Commit

Permalink
for review
Browse files Browse the repository at this point in the history
  • Loading branch information
ytake committed Dec 3, 2016
1 parent 8ce0b20 commit 7da9b1e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/Matcher/AnnotationScanMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ public function __construct()
*/
public function matchesClass(\ReflectionClass $class, array $arguments)
{
$i = 0;
$count = 0;
$annotation = $arguments[0];
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
$match = $this->reader->getMethodAnnotation($reflectionMethod, $annotation);
if ($match) {
$i++;
$count++;
}
}

if ($i > 1) {
if ($count > 1) {
return false;
}

Expand All @@ -64,16 +63,16 @@ public function matchesClass(\ReflectionClass $class, array $arguments)
*/
public function matchesMethod(\ReflectionMethod $method, array $arguments)
{
$i = 0;
$count = 0;
$annotation = $arguments[0];
$reflectionClass = new \ReflectionClass($method->class);
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
$match = $this->reader->getMethodAnnotation($reflectionMethod, $annotation);
if ($match) {
$i++;
$count++;
}
}
if ($i > 1) {
if ($count > 1) {
return false;
}

Expand Down
12 changes: 6 additions & 6 deletions tests/src/AspectPostConstruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
class AspectPostConstruct
{
/** @var int */
protected $a;
protected $index;

/**
* AspectPostConstruct constructor.
*
* @param int $a
* @param int $index
*/
public function __construct($a = 1)
public function __construct($index = 1)
{
$this->a = $a;
$this->index = $index;
}

/**
* @PostConstruct
*/
public function initialize()
{
$this->a += 1;
$this->index += 1;
}

/**
* @return int
*/
public function getA()
{
return $this->a;
return $this->index;
}
}
12 changes: 6 additions & 6 deletions tests/src/FailedPostConstruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
class FailedPostConstruct
{
/** @var int */
protected $a;
protected $index;

/**
* FailedPostConstruct constructor.
*
* @param int $a
* @param int $index
*/
public function __construct($a = 1)
public function __construct($index = 1)
{
$this->a = $a;
$this->index = $index;
}

/**
* @PostConstruct
*/
public function initialize()
{
$this->a += 1;
$this->index += 1;
}

/**
Expand All @@ -46,6 +46,6 @@ public function initializeTwo()
*/
public function getA()
{
return $this->a;
return $this->index;
}
}

0 comments on commit 7da9b1e

Please sign in to comment.