Skip to content

Commit 5d61b04

Browse files
Fix CS/WS issues
1 parent cca308e commit 5d61b04

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

src/Framework/MockObject/Generator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
649649
$isClass = false;
650650
$isInterface = false;
651651
$class = null;
652-
$mockMethods = new MockMethodSet();
652+
$mockMethods = new MockMethodSet;
653653

654654
if (\is_array($type)) {
655655
$interfaceMethods = [];
@@ -676,16 +676,19 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
676676
)
677677
);
678678
}
679+
679680
$methodReflection = $typeClass->getMethod($method);
680681

681682
if ($this->canMockMethod($methodReflection)) {
682683
$mockMethods->addMethods(
683684
MockMethod::fromReflection($methodReflection, $callOriginalMethods, $cloneArguments)
684685
);
686+
685687
$interfaceMethods[] = $method;
686688
}
687689
}
688690
}
691+
689692
unset($interfaceMethods);
690693
}
691694

@@ -744,6 +747,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
744747
!$class->implementsInterface(Iterator::class) &&
745748
!$class->implementsInterface(IteratorAggregate::class)) {
746749
$additionalInterfaces[] = Iterator::class;
750+
747751
$mockMethods->addMethods(
748752
...$this->mockClassMethods(Iterator::class, $callOriginalMethods, $cloneArguments)
749753
);
@@ -801,7 +805,7 @@ private function generateMock($type, $explicitMethods, $mockClassName, $callOrig
801805
$configurable = [];
802806

803807
/** @var MockMethod $mockMethod */
804-
foreach ($mockMethods->getMethods() as $mockMethod) {
808+
foreach ($mockMethods->asArray() as $mockMethod) {
805809
$mockedMethods .= $mockMethod->generateCode();
806810
$configurable[] = \strtolower($mockMethod->getName());
807811
}

src/Framework/MockObject/MockMethod.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,8 @@ public static function fromName(string $fullClassName, string $methodName, bool
151151
);
152152
}
153153

154-
public function __construct(
155-
string $className,
156-
string $methodName,
157-
bool $cloneArguments,
158-
string $modifier,
159-
string $argumentsForDeclaration,
160-
string $argumentsForCall,
161-
string $returnType,
162-
string $reference,
163-
bool $callOriginalMethod,
164-
bool $static,
165-
?string $deprecation,
166-
bool $allowsReturnNull
167-
) {
154+
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)
155+
{
168156
$this->className = $className;
169157
$this->methodName = $methodName;
170158
$this->cloneArguments = $cloneArguments;

src/Framework/MockObject/MockMethodSet.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
*/
1111
namespace PHPUnit\Framework\MockObject;
1212

13-
class MockMethodSet
13+
final class MockMethodSet
1414
{
15+
/**
16+
* @var MockMethod[]
17+
*/
1518
private $methods = [];
1619

17-
public function addMethods(MockMethod...$methods): void
20+
public function addMethods(MockMethod ...$methods): void
1821
{
1922
foreach ($methods as $method) {
2023
$this->methods[\strtolower($method->getName())] = $method;
2124
}
2225
}
2326

24-
public function getMethods(): array
27+
public function asArray(): array
2528
{
2629
return \array_values($this->methods);
2730
}

0 commit comments

Comments
 (0)