@@ -78,20 +78,20 @@ class Phake
78
78
*/
79
79
private static $ classGenerator ;
80
80
81
- /**
82
- * @var \Phake\Matchers\Factory|null
83
- */
84
- private static $ matchersFactory ;
81
+ /**
82
+ * @var \Phake\Matchers\Factory|null
83
+ */
84
+ private static $ matchersFactory ;
85
85
86
86
/**
87
87
* Constants identifying supported clients
88
88
*/
89
- const CLIENT_DEFAULT ='DEFAULT ' ;
90
- const CLIENT_PHPUNIT ='PHPUNIT ' ;
91
- const CLIENT_PHPUNIT6 ='PHPUNIT6 ' ;
92
- const CLIENT_PHPUNIT7 ='PHPUNIT7 ' ;
93
- const CLIENT_PHPUNIT8 ='PHPUNIT8 ' ;
94
- const CLIENT_PHPUNIT9 ='PHPUNIT9 ' ;
89
+ public const CLIENT_DEFAULT ='DEFAULT ' ;
90
+ public const CLIENT_PHPUNIT ='PHPUNIT ' ;
91
+ public const CLIENT_PHPUNIT6 ='PHPUNIT6 ' ;
92
+ public const CLIENT_PHPUNIT7 ='PHPUNIT7 ' ;
93
+ public const CLIENT_PHPUNIT8 ='PHPUNIT8 ' ;
94
+ public const CLIENT_PHPUNIT9 ='PHPUNIT9 ' ;
95
95
96
96
/**
97
97
* Returns a new mock object based on the given class name.
@@ -103,7 +103,7 @@ class Phake
103
103
*/
104
104
public static function mock ($ className ,\Phake \Stubber \IAnswerContainer $ defaultAnswer =null )
105
105
{
106
- if ($ defaultAnswer ===null ) {
106
+ if (null ===$ defaultAnswer ) {
107
107
$ answer =new \Phake \Stubber \Answers \SmartDefaultAnswer ();
108
108
}else {
109
109
$ answer =$ defaultAnswer ->getAnswer ();
@@ -156,21 +156,20 @@ public static function partMock($className, ...$args)
156
156
return self ::partialMock ($ className , ...$ args );
157
157
}
158
158
159
- /**
160
- * Create a \Phake\Matchers\Factory that we can re-use multiple times. Creating too many
161
- * instances of this object is expensive.
162
- *
163
- * @return \Phake\Matchers\Factory
164
- */
165
- private static function getMatchersFactory ()
166
- {
167
- if (!self ::$ matchersFactory )
168
- {
169
- self ::$ matchersFactory =new \Phake \Matchers \Factory ();
170
- }
159
+ /**
160
+ * Create a \Phake\Matchers\Factory that we can re-use multiple times. Creating too many
161
+ * instances of this object is expensive.
162
+ *
163
+ * @return \Phake\Matchers\Factory
164
+ */
165
+ private static function getMatchersFactory ()
166
+ {
167
+ if (!self ::$ matchersFactory ) {
168
+ self ::$ matchersFactory =new \Phake \Matchers \Factory ();
169
+ }
171
170
172
- return self ::$ matchersFactory ;
173
- }
171
+ return self ::$ matchersFactory ;
172
+ }
174
173
175
174
/**
176
175
* Creates a new verifier for the given mock object.
@@ -224,7 +223,7 @@ public static function verifyStatic(\Phake\IMock $mock, \Phake\CallRecorder\IVer
224
223
*/
225
224
public static function verifyCallMethodWith (...$ arguments )
226
225
{
227
- $ factory =self ::getMatchersFactory ();
226
+ $ factory =self ::getMatchersFactory ();
228
227
return new \Phake \Proxies \CallVerifierProxy ($ factory ->createMatcherChain (
229
228
$ arguments
230
229
),self ::getClient (),false );
@@ -239,7 +238,7 @@ public static function verifyCallMethodWith(...$arguments)
239
238
*/
240
239
public static function verifyStaticCallMethodWith (...$ arguments )
241
240
{
242
- $ factory =self ::getMatchersFactory ();
241
+ $ factory =self ::getMatchersFactory ();
243
242
return new \Phake \Proxies \CallVerifierProxy ($ factory ->createMatcherChain (
244
243
$ arguments
245
244
),self ::getClient (),true );
@@ -255,7 +254,7 @@ public static function inOrder(...$calls)
255
254
$ orderVerifier =new \Phake \CallRecorder \OrderVerifier ();
256
255
257
256
if (!$ orderVerifier ->verifyCallsInOrder (self ::pullPositionsFromCallInfos ($ calls ))) {
258
- $ result =new \Phake \CallRecorder \VerifierResult (false ,array (), " Calls not made in order " );
257
+ $ result =new \Phake \CallRecorder \VerifierResult (false ,[], ' Calls not made in order ' );
259
258
self ::getClient ()->processVerifierResult ($ result );
260
259
}
261
260
}
@@ -322,9 +321,9 @@ public static function verifyNoOtherInteractions(\Phake\IMock $mock)
322
321
*/
323
322
private static function pullPositionsFromCallInfos (array $ calls )
324
323
{
325
- $ transformed =array () ;
324
+ $ transformed =[] ;
326
325
foreach ($ callsas $ callList ) {
327
- $ transformedList =array () ;
326
+ $ transformedList =[] ;
328
327
foreach ($ callListas $ call ) {
329
328
$ transformedList [] =$ call ->getPosition ();
330
329
}
@@ -366,7 +365,7 @@ public static function whenStatic(\Phake\IMock $mock)
366
365
*/
367
366
public static function whenCallMethodWith (...$ arguments )
368
367
{
369
- $ factory =self ::getMatchersFactory ();
368
+ $ factory =self ::getMatchersFactory ();
370
369
return new \Phake \Proxies \CallStubberProxy ($ factory ->createMatcherChain ($ arguments ),false );
371
370
}
372
371
@@ -379,7 +378,7 @@ public static function whenCallMethodWith(...$arguments)
379
378
*/
380
379
public static function whenStaticCallMethodWith (...$ arguments )
381
380
{
382
- $ factory =self ::getMatchersFactory ();
381
+ $ factory =self ::getMatchersFactory ();
383
382
return new \Phake \Proxies \CallStubberProxy ($ factory ->createMatcherChain ($ arguments ),true );
384
383
}
385
384
@@ -525,7 +524,7 @@ public static function setReference($value)
525
524
*/
526
525
public static function times ($ count )
527
526
{
528
- return new \Phake \CallRecorder \VerifierMode \Times ((int )$ count );
527
+ return new \Phake \CallRecorder \VerifierMode \Times ((int )$ count );
529
528
}
530
529
531
530
/**
@@ -548,7 +547,7 @@ public static function never()
548
547
*/
549
548
public static function atLeast ($ count )
550
549
{
551
- return new \Phake \CallRecorder \VerifierMode \AtLeast ((int )$ count );
550
+ return new \Phake \CallRecorder \VerifierMode \AtLeast ((int )$ count );
552
551
}
553
552
554
553
/**
@@ -562,7 +561,7 @@ public static function atLeast($count)
562
561
*/
563
562
public static function atMost ($ count )
564
563
{
565
- return new \Phake \CallRecorder \VerifierMode \AtMost ((int )$ count );
564
+ return new \Phake \CallRecorder \VerifierMode \AtMost ((int )$ count );
566
565
}
567
566
568
567
/**
@@ -593,23 +592,21 @@ public static function ignoreRemaining()
593
592
public static function getClient ()
594
593
{
595
594
if (!isset (self ::$ client )) {
596
- if (class_exists (' PHPUnit\Framework\TestCase ' )) {
595
+ if (class_exists (\ PHPUnit \Framework \TestCase::class )) {
597
596
if (9 <= \PHPUnit \Runner \Version::id ()) {
598
597
return self ::$ client =new \Phake \Client \PHPUnit9 ();
599
598
}elseif (8 <= \PHPUnit \Runner \Version::id ()) {
600
599
return self ::$ client =new \Phake \Client \PHPUnit8 ();
601
600
}elseif (7 <= \PHPUnit \Runner \Version::id ()) {
602
601
return self ::$ client =new \Phake \Client \PHPUnit7 ();
603
- }else {
604
- return self ::$ client =new \Phake \Client \PHPUnit6 ();
605
602
}
603
+ return self ::$ client =new \Phake \Client \PHPUnit6 ();
606
604
}elseif (class_exists ('PHPUnit_Framework_TestCase ' )) {
607
605
return self ::$ client =new \Phake \Client \PHPUnit ();
608
606
}
609
607
return self ::$ client =new \Phake \Client \DefaultClient ();
610
- }else {
611
- return self ::$ client ;
612
608
}
609
+ return self ::$ client ;
613
610
}
614
611
615
612
/**
@@ -624,15 +621,15 @@ public static function setClient($client)
624
621
{
625
622
if ($ clientinstanceof \Phake \Client \IClient) {
626
623
self ::$ client =$ client ;
627
- }elseif ($ client == self ::CLIENT_PHPUNIT ) {
624
+ }elseif (self ::CLIENT_PHPUNIT == $ client ) {
628
625
self ::$ client =new \Phake \Client \PHPUnit ();
629
- }elseif ($ client == self ::CLIENT_PHPUNIT6 ) {
626
+ }elseif (self ::CLIENT_PHPUNIT6 == $ client ) {
630
627
self ::$ client =new \Phake \Client \PHPUnit6 ();
631
- }elseif ($ client == self ::CLIENT_PHPUNIT7 ) {
628
+ }elseif (self ::CLIENT_PHPUNIT7 == $ client ) {
632
629
self ::$ client =new \Phake \Client \PHPUnit7 ();
633
- }elseif ($ client == self ::CLIENT_PHPUNIT8 ) {
630
+ }elseif (self ::CLIENT_PHPUNIT8 == $ client ) {
634
631
self ::$ client =new \Phake \Client \PHPUnit8 ();
635
- }elseif ($ client == self ::CLIENT_PHPUNIT9 ) {
632
+ }elseif (self ::CLIENT_PHPUNIT9 == $ client ) {
636
633
self ::$ client =new \Phake \Client \PHPUnit9 ();
637
634
}else {
638
635
self ::$ client =new \Phake \Client \DefaultClient ();
@@ -719,16 +716,13 @@ public static function initAnnotations($obj)
719
716
*/
720
717
public static function assertValidMock ($ mock )
721
718
{
722
- if ($ mockinstanceof \Phake \IMock)
723
- {
719
+ if ($ mockinstanceof \Phake \IMock) {
724
720
return ;
725
721
}
726
722
727
- if (is_string ($ mock ) &&class_exists ($ mock ,false ))
728
- {
723
+ if (is_string ($ mock ) &&class_exists ($ mock ,false )) {
729
724
$ reflClass =new \ReflectionClass ($ mock );
730
- if ($ reflClass ->implementsInterface (\Phake \IMock::class))
731
- {
725
+ if ($ reflClass ->implementsInterface (\Phake \IMock::class)) {
732
726
return ;
733
727
}
734
728
}
@@ -764,16 +758,14 @@ public static function getName($mock)
764
758
public static function getInfo ($ mock )
765
759
{
766
760
static ::assertValidMock ($ mock );
767
- if ($ mockinstanceof \Phake \IMock)
768
- {
761
+ if ($ mockinstanceof \Phake \IMock) {
769
762
assert (isset ($ mock ->__PHAKE_info ));
770
763
return $ mock ->__PHAKE_info ;
771
764
}
772
- else
773
- {
774
- assert (isset ($ mock ::$ __PHAKE_staticInfo ));
775
- return $ mock ::$ __PHAKE_staticInfo ;
776
- }
765
+
766
+
767
+ assert (isset ($ mock ::$ __PHAKE_staticInfo ));
768
+ return $ mock ::$ __PHAKE_staticInfo ;
777
769
}
778
770
779
771
/**