8000 Fix PHP Doc Comments (#1410) · mockery/mockery@c731bf3 · GitHub
[go: up one dir, main page]

Skip to content

Commit c731bf3

Browse files
authored
Fix PHP Doc Comments (#1410)
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
1 parent a7c2001 commit c731bf3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1123
-1075
lines changed

library/Mockery.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ public static function ducktype(...$args)
229229
/**
230230
* Static fetching of a mock associated with a name or explicit class poser.
231231
*
232-
* @template TMock of object
232+
* @template TFetchMock of object
233233
*
234-
* @param class-string<TMock> $name
234+
* @param class-string<TFetchMock> $name
235235
*
236-
* @return LegacyMockInterface&MockInterface&TMock
236+
* @return null|(LegacyMockInterface&MockInterface&TFetchMock)
237237
*/
238238
public static function fetchMock($name)
239239
{
@@ -466,9 +466,9 @@ public static function isSame($expected): IsSame
466466
/**
467467
* Static shortcut to Container::mock().
468468
*
469-
* @template TMock
469+
* @template TMock of object
470470
*
471-
* @param array<class-string<TMock>|TMock|array<mixed>> $args
471+
* @param array<class-string<TMock>|TMock|Closure(LegacyMockInterface&MockInterface&TMock):LegacyMockInterface&MockInterface&TMock|array<TMock>> $args
472472
*
473473
* @return LegacyMockInterface&MockInterface&TMock
474474
*/
@@ -561,7 +561,7 @@ public static function on($closure)
561561
* @template TReturnArgs
562562
*
563563
* @param TReturnArgs ...$args
564-
* @param Closure $add
564+
* @param Closure $add
565565
*
566566
* @return CompositeExpectation
567567
*/
@@ -668,13 +668,13 @@ public static function setLoader(Loader $loader)
668668
*
669669
* @template TSpy
670670
*
671-
* @param array<class-string<TSpy>|TSpy|array<mixed>> $args
671+
* @param array<class-string<TSpy>|TSpy|Closure(LegacyMockInterface&MockInterface&TSpy):LegacyMockInterface&MockInterface&TSpy|array<TSpy>> $args
672672
*
673673
* @return LegacyMockInterface&MockInterface&TSpy
674674
*/
675675
public static function spy(...$args)
676676
{
677-
if (\count($args) && $args[0] instanceof Closure) {
677+
if ($args !== [] && $args[0] instanceof Closure) {
678678
$args[0] = new ClosureWrapper($args[0]);
679679
}
680680

@@ -711,7 +711,7 @@ public static function type($expected)
711711
* Sets up expectations on the members of the CompositeExpectation and
712712
* builds up any demeter chain that was passed to shouldReceive.
713713
*
714-
* @param string $arg
714+
* @param string $arg
715715
* @param Closure $add
716716
*
717717
* @throws MockeryException
@@ -780,7 +780,7 @@ protected static function buildDemeterChain(LegacyMockInterface $mock, $arg, $ad
780780
* @template TArray or array
781781
*
782782
* @param TArray $argument
783-
* @param int $nesting
783+
* @param int $nesting
784784
*
785785
* @return TArray
786786
*/
@@ -812,7 +812,7 @@ private static function cleanupArray($argument, $nesting = 3)
812812
* @template TArgument
813813
*
814814
* @param TArgument $argument
815-
* @param int $nesting
815+
* @param int $nesting
816816
*
817817
* @return mixed
818818
*/
@@ -847,10 +847,10 @@ private static function declareType($fqn, $type): void
847847
$shortName = \trim(\array_pop($parts));
848848
$namespace = \implode('\\', $parts);
849849

850-
$targetCode.= "namespace {$namespace};\n";
850+
$targetCode .= "namespace {$namespace};\n";
851851
}
852852

853-
$targetCode.= \sprintf('%s %s {} ', $type, $shortName);
853+
$targetCode .= \sprintf('%s %s {} ', $type, $shortName);
854854

855855
/*
856856
* We could eval here, but it doesn't play well with the way
@@ -870,7 +870,7 @@ private static function declareType($fqn, $type): void
870870
* Returns all public instance properties.
871871
*
872872
* @param object $object
873-
* @param int $nesting
873+
* @param int $nesting
874874
*
875875
* @return array<string, mixed>
876876
*/
@@ -899,7 +899,7 @@ private static function extractInstancePublicProperties($object, $nesting)
899899
* of any passed argument.
900900
*
901901
* @param mixed $argument
902-
* @param int $depth
902+
* @param int $depth
903903
*
904904
* @return mixed
905905
*/
@@ -956,7 +956,7 @@ private static function formatArgument($argument, $depth = 0)
956956
*
957957
* @param class-string<TMock> $demeterMockKey
958958
*
959-
* @return LegacyMockInterface&MockInterface&TMock
959+
* @return null|(LegacyMockInterface&MockInterface&TMock)
960960
*/
961961
private static function getExistingDemeterMock(Container $container, $demeterMockKey)
962962
{
@@ -1032,7 +1032,7 @@ private static function noMoreElementsInChain(array $methodNames)
10321032
* Utility function to turn public properties and public get* and is* method values into an array.
10331033
*
10341034
* @param object $object
1035-
* @param int $nesting
1035+
* @param int $nesting
10361036
*
10371037
* @return array
10381038
*/

library/Mockery/Adapter/Phpunit/TestListenerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TestListenerTrait
2929
* endTest is called after each test and checks if \Mockery::close() has
3030
* been called, and will let the test fail if it hasn't.
3131
*
32-
* @param Test $test
32+
* @param Test $test
3333
* @param float $time
3434
*/
3535
public function endTest(Test $test, $time)

library/Mockery/Configuration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function getDefaultMatcher($class)
208208
* Get the parameter map of an internal PHP class method
209209
*
210210
* @param class-string $class
211-
* @param string $method
211+
* @param string $method
212212
*
213213
* @return null|array
214214
*/
@@ -241,7 +241,7 @@ public function getInternalClassMethodParamMaps()
241241
* Get the object formatter for a class
242242
*
243243
* @param class-string $class
244-
* @param Closure $defaultFormatter
244+
* @param Closure $defaultFormatter
245245
*
246246
* @return Closure
247247
*/
@@ -367,7 +367,7 @@ public function setDefaultMatcher($class, $matcherClass)
367367
* Set a parameter map (array of param signature strings) for the method of an internal PHP class.
368368
*
369369
* @param class-string $class
370-
* @param string $method
370+
* @param string $method
371371
* @param list<string> $map
372372
*
373373
* @throws LogicException
@@ -395,7 +395,7 @@ public function setInternalClassMethodParamMap($class, $method, array $map)
395395
* Set a custom object formatter for a class
396396
*
397397
* @param class-string $class
398-
* @param Closure $formatterCallback
398+
* @param Closure $formatterCallback
399399
*
400400
* @return void
401401
*/

library/Mockery/Container.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
use function substr;
5151
use function trait_exists;
5252

53+
/**
54+
* Container for mock objects
55+
*
56+
* @template TMockObject of object
57+
*/
5358
class Container
5459
{
5560
public const BLOCKS = Mockery::BLOCKS;
@@ -88,7 +93,7 @@ class Container
8893
/**
8994
* Store of mock objects
9095
*
91-
* @var array<class-string<LegacyMockInterface&MockInterface>|int,LegacyMockInterface&MockInterface>
96+
* @var array<class-string<LegacyMockInterface&MockInterface&TMockObject>|array-key,LegacyMockInterface&MockInterface&TMockObject>
9297
*/
9398
protected $_mocks = [];
9499

@@ -163,7 +168,8 @@ public function getLoader()
163168
}
164169

165170
/**
166-
* @return array<class-string<LegacyMockInterface&MockInterface>|int,LegacyMockInterface&MockInterface>
171+
* @template TMock of object
172+
* @return array<class-string<LegacyMockInterface&MockInterface&TMockObject>|array-key,LegacyMockInterface&MockInterface&TMockObject>
167173
*/
168174
public function getMocks()
169175
{
@@ -207,13 +213,13 @@ static function ($name): bool {
207213
* names or partials - just so long as it's something that can be mocked.
208214
* I'll refactor it one day so it's easier to follow.
209215
*
210-
* @template TMock of LegacyMockInterface&MockInterface&object
216+
* @template TMock of object
211217
*
212-
* @param array|string[]|Closure ...$args
218+
* @param array<class-string<TMock>|TMock|Closure(LegacyMockInterface&MockInterface&TMock):LegacyMockInterface&MockInterface&TMock|array<TMock>> $args
213219
*
214220
* @throws ReflectionException|RuntimeException
215221
*
216-
* @return TMock
222+
* @return LegacyMockInterface&MockInterface&TMock
217223
*/
218224
public function mock(...$args)
219225
{
@@ -409,7 +415,9 @@ public function mock(...$args)
409415
}
410416
}
411417

418+
// if the last parameter passed to mock() is a closure,
412419
if ($expectationClosure instanceof Closure) {
420+
// call the closure with the mock object
413421
$expectationClosure($mock);
414422
}
415423

@@ -491,7 +499,7 @@ public function mockery_setCurrentOrder($order)
491499
* Set ordering for a group
492500
*
493501
* @param string $group
494-
* @param int $order
502+
* @param int $order
495503
*
496504
* @return void
497505
*/
@@ -539,7 +547,7 @@ public function mockery_thrownExceptions()
539547
* Validate the current mock's ordering
540548
*
541549
* @param string $method
542-
* @param int $order
550+
* @param int $order
543551
*
544552
* @throws Exception
545553
*/
@@ -579,9 +587,11 @@ public function mockery_verify()
579587
/**
580588
* Store a mock and set its container reference
581589
*
582-
* @param LegacyMockInterface|MockInterface $mock
590+
* @template TRememberMock of object
583591
*
584-
* @return LegacyMockInterface|MockInterface
592+
* @param LegacyMockInterface&MockInterface&TRememberMock $mock
593+
*
594+
* @return LegacyMockInterface&MockInterface&TRememberMock
585595
*/
586596
public function rememberMock(LegacyMockInterface $mock)
587597
{
@@ -614,11 +624,12 @@ public function self()
614624

615625
/**
616626
* @template TMock of object
627+
* @template TMixed
617628
*
618629
* @param class-string<TMock> $mockName
619-
* @param null|array<int,mixed> $constructorArgs
630+
* @param null|array<TMixed> $constructorArgs
620631
*
621-
* @return LegacyMockInterface&MockInterface&TMock
632+
* @return TMock
622633
*/
623634
protected function _getInstance($mockName, $constructorArgs = null)
624635
{

library/Mockery/CountValidator/AtLeast.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function isEligible($n)
3333
*
3434
* @param int $n
3535
*
36+
* @throws InvalidCountException
3637
* @return bool
3738
*/
3839
public function validate($n)
@@ -45,6 +46,7 @@ public function validate($n)
4546
. ' at least ' . $this->_limit . ' times but called ' . $n
4647
. ' times.'
4748
);
49+
4850
$exception->setMock($this->_expectation->getMock())
4951
->setMethodName((string) $this->_expectation)
5052
->setExpectedCountComparative('>=')

library/Mockery/CountValidator/AtMost.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AtMost extends CountValidatorAbstract
2121
*
2222
* @param int $n
2323
*
24+
* @throws InvalidCountException
2425
* @return bool
2526
*/
2627
public function validate($n)

library/Mockery/CountValidator/Exact.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Exact extends CountValidatorAbstract
2121
*
2222
* @param int $n
2323
*
24+
* @throws InvalidCountException
2425
* @return bool
2526
*/
2627
public function validate($n)

library/Mockery/Exception/BadMethodCallException.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
namespace Mockery\Exception;
1212

13-
use Throwable;
14-
1513
class BadMethodCallException extends \BadMethodCallException implements MockeryExceptionInterface
1614
{
15+
/**
16+
* @var bool
17+
*/
1718
private $dismissed = false;
1819

1920
public function dismiss()
@@ -28,6 +29,9 @@ public function dismiss()
2829
$previous->dismiss();
2930
}
3031

32+
/**
33+
* @return bool
34+
*/
3135
public function dismissed()
3236
{
3337
return $this->dismissed;

0 commit comments

Comments
 (0)
0