Skip to content

Commit

Permalink
only validates __callStatic methods now
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnstonCode committed Aug 3, 2018
1 parent 9f45510 commit 6e0ae41
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 126 deletions.
77 changes: 0 additions & 77 deletions src/Reflection/Money/MoneyMethodReflection.php

This file was deleted.

13 changes: 2 additions & 11 deletions src/Reflection/Money/MoneyMethodsReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):

$currencies = Currency::getCurrencies();

return ($classReflection->getNativeReflection()->hasMethod($methodName) || array_key_exists($methodName, $currencies));
return array_key_exists($methodName, $currencies);
}

public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
{
$currencies = Currency::getCurrencies();

if (array_key_exists($methodName, $currencies)) {
return new MoneyStaticMethodReflection($classReflection, $methodName);
}

$method = $classReflection->getNativeReflection()->getMethod($methodName);

return new MoneyMethodReflection($classReflection, $methodName, $method->isStatic(), $method->isPrivate());
return new MoneyStaticMethodReflection($classReflection, $methodName);
}

}
38 changes: 0 additions & 38 deletions tests/Reflection/Money/MoneyMethodsReflectionExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ protected function setUp(): void
$this->extension = new MoneyMethodsReflectionExtension();
}

public function testHasMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
$this->assertTrue($this->extension->hasMethod($classReflection, 'getUnits'));
}

public function testHasStaticMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
Expand All @@ -34,38 +28,6 @@ public function testInvalidMethod(): void
$this->assertFalse($this->extension->hasMethod($classReflection, 'ZZZ'));
}

public function testHasPrivateMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
$this->assertTrue($this->extension->hasMethod($classReflection, 'assertSameCurrency'));
}

public function testGetPublicMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
$methodReflection = $this->extension->getMethod($classReflection, 'getUnits');

$this->assertEquals('getUnits', $methodReflection->getName());
$this->assertEquals($classReflection, $methodReflection->getDeclaringClass());
$this->assertFalse($methodReflection->isStatic());
$this->assertFalse($methodReflection->isVariadic());
$this->assertFalse($methodReflection->isPrivate());
$this->assertTrue($methodReflection->isPublic());
}

public function testGetPrivateMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
$methodReflection = $this->extension->getMethod($classReflection, 'assertSameCurrency');

$this->assertEquals('assertSameCurrency', $methodReflection->getName());
$this->assertEquals($classReflection, $methodReflection->getDeclaringClass());
$this->assertFalse($methodReflection->isStatic());
$this->assertFalse($methodReflection->isVariadic());
$this->assertTrue($methodReflection->isPrivate());
$this->assertFalse($methodReflection->isPublic());
}

public function testGetStaticMethod(): void
{
$classReflection = $this->broker->getClass('Money\Money');
Expand Down

0 comments on commit 6e0ae41

Please sign in to comment.