Skip to content

Commit

Permalink
Fix CS/WS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 8, 2018
1 parent cca308e commit 5d61b04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
8 changes: 6 additions & 2 deletions src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
$isClass = false;
$isInterface = false;
$class = null;
$mockMethods = new MockMethodSet();
$mockMethods = new MockMethodSet;

if (\is_array($type)) {
$interfaceMethods = [];
Expand All @@ -676,16 +676,19 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
)
);
}

$methodReflection = $typeClass->getMethod($method);

if ($this->canMockMethod($methodReflection)) {
$mockMethods->addMethods(
MockMethod::fromReflection($methodReflection, $callOriginalMethods, $cloneArguments)
);

$interfaceMethods[] = $method;
}
}
}

unset($interfaceMethods);
}

Expand Down Expand Up @@ -744,6 +747,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
!$class->implementsInterface(Iterator::class) &&
!$class->implementsInterface(IteratorAggregate::class)) {
$additionalInterfaces[] = Iterator::class;

$mockMethods->addMethods(
...$this->mockClassMethods(Iterator::class, $callOriginalMethods, $cloneArguments)
);
Expand Down Expand Up @@ -801,7 +805,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
$configurable = [];

/** @var MockMethod $mockMethod */
foreach ($mockMethods->getMethods() as $mockMethod) {
foreach ($mockMethods->asArray() as $mockMethod) {
$mockedMethods .= $mockMethod->generateCode();
$configurable[] = \strtolower($mockMethod->getName());
}
Expand Down
16 changes: 2 additions & 14 deletions src/Framework/MockObject/MockMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,8 @@ public static function fromName(string $fullClassName, string $methodName, bool
);
}

public function __construct(
string $className,
string $methodName,
bool $cloneArguments,
string $modifier,
string $argumentsForDeclaration,
string $argumentsForCall,
string $returnType,
string $reference,
bool $callOriginalMethod,
bool $static,
?string $deprecation,
bool $allowsReturnNull
) {
public function __construct(string $className, string $methodName, bool $cloneArguments, string $modifier, string $argumentsForDeclaration, string $argumentsForCall, string $returnType, string $reference, bool $callOriginalMethod, bool $static, ?string $deprecation, bool $allowsReturnNull)
{
$this->className = $className;
$this->methodName = $methodName;
$this->cloneArguments = $cloneArguments;
Expand Down
9 changes: 6 additions & 3 deletions src/Framework/MockObject/MockMethodSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
*/
namespace PHPUnit\Framework\MockObject;

class MockMethodSet
final class MockMethodSet
{
/**
* @var MockMethod[]
*/
private $methods = [];

public function addMethods(MockMethod...$methods): void
public function addMethods(MockMethod ...$methods): void
{
foreach ($methods as $method) {
$this->methods[\strtolower($method->getName())] = $method;
}
}

public function getMethods(): array
public function asArray(): array
{
return \array_values($this->methods);
}
Expand Down

0 comments on commit 5d61b04

Please sign in to comment.