Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ca1fdd

Browse files
committed
Apply PSR12 standard and short array syntax
1 parent0816e1e commit8ca1fdd

File tree

178 files changed

+1272
-1457
lines changed

Some content is hidden

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

178 files changed

+1272
-1457
lines changed

‎src/Phake.php

Lines changed: 50 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ class Phake
7878
*/
7979
privatestatic$classGenerator;
8080

81-
/**
82-
* @var \Phake\Matchers\Factory|null
83-
*/
84-
privatestatic$matchersFactory;
81+
/**
82+
* @var \Phake\Matchers\Factory|null
83+
*/
84+
privatestatic$matchersFactory;
8585

8686
/**
8787
* Constants identifying supported clients
8888
*/
89-
constCLIENT_DEFAULT ='DEFAULT';
90-
constCLIENT_PHPUNIT ='PHPUNIT';
91-
constCLIENT_PHPUNIT6 ='PHPUNIT6';
92-
constCLIENT_PHPUNIT7 ='PHPUNIT7';
93-
constCLIENT_PHPUNIT8 ='PHPUNIT8';
94-
constCLIENT_PHPUNIT9 ='PHPUNIT9';
89+
publicconstCLIENT_DEFAULT ='DEFAULT';
90+
publicconstCLIENT_PHPUNIT ='PHPUNIT';
91+
publicconstCLIENT_PHPUNIT6 ='PHPUNIT6';
92+
publicconstCLIENT_PHPUNIT7 ='PHPUNIT7';
93+
publicconstCLIENT_PHPUNIT8 ='PHPUNIT8';
94+
publicconstCLIENT_PHPUNIT9 ='PHPUNIT9';
9595

9696
/**
9797
* Returns a new mock object based on the given class name.
@@ -103,7 +103,7 @@ class Phake
103103
*/
104104
publicstaticfunctionmock($className,\Phake\Stubber\IAnswerContainer$defaultAnswer =null)
105105
{
106-
if ($defaultAnswer ===null) {
106+
if (null ===$defaultAnswer) {
107107
$answer =new \Phake\Stubber\Answers\SmartDefaultAnswer();
108108
}else {
109109
$answer =$defaultAnswer->getAnswer();
@@ -156,21 +156,20 @@ public static function partMock($className, ...$args)
156156
returnself::partialMock($className, ...$args);
157157
}
158158

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-
privatestaticfunctiongetMatchersFactory ()
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+
privatestaticfunctiongetMatchersFactory()
166+
{
167+
if (!self::$matchersFactory) {
168+
self::$matchersFactory =new \Phake\Matchers\Factory();
169+
}
171170

172-
returnself::$matchersFactory;
173-
}
171+
returnself::$matchersFactory;
172+
}
174173

175174
/**
176175
* Creates a new verifier for the given mock object.
@@ -224,7 +223,7 @@ public static function verifyStatic(\Phake\IMock $mock, \Phake\CallRecorder\IVer
224223
*/
225224
publicstaticfunctionverifyCallMethodWith(...$arguments)
226225
{
227-
$factory=self::getMatchersFactory();
226+
$factory =self::getMatchersFactory();
228227
returnnew \Phake\Proxies\CallVerifierProxy($factory->createMatcherChain(
229228
$arguments
230229
),self::getClient(),false);
@@ -239,7 +238,7 @@ public static function verifyCallMethodWith(...$arguments)
239238
*/
240239
publicstaticfunctionverifyStaticCallMethodWith(...$arguments)
241240
{
242-
$factory=self::getMatchersFactory();
241+
$factory =self::getMatchersFactory();
243242
returnnew \Phake\Proxies\CallVerifierProxy($factory->createMatcherChain(
244243
$arguments
245244
),self::getClient(),true);
@@ -255,7 +254,7 @@ public static function inOrder(...$calls)
255254
$orderVerifier =new \Phake\CallRecorder\OrderVerifier();
256255

257256
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');
259258
self::getClient()->processVerifierResult($result);
260259
}
261260
}
@@ -322,9 +321,9 @@ public static function verifyNoOtherInteractions(\Phake\IMock $mock)
322321
*/
323322
privatestaticfunctionpullPositionsFromCallInfos(array$calls)
324323
{
325-
$transformed =array();
324+
$transformed =[];
326325
foreach ($callsas$callList) {
327-
$transformedList =array();
326+
$transformedList =[];
328327
foreach ($callListas$call) {
329328
$transformedList[] =$call->getPosition();
330329
}
@@ -366,7 +365,7 @@ public static function whenStatic(\Phake\IMock $mock)
366365
*/
367366
publicstaticfunctionwhenCallMethodWith(...$arguments)
368367
{
369-
$factory=self::getMatchersFactory();
368+
$factory =self::getMatchersFactory();
370369
returnnew \Phake\Proxies\CallStubberProxy($factory->createMatcherChain($arguments),false);
371370
}
372371

@@ -379,7 +378,7 @@ public static function whenCallMethodWith(...$arguments)
379378
*/
380379
publicstaticfunctionwhenStaticCallMethodWith(...$arguments)
381380
{
382-
$factory=self::getMatchersFactory();
381+
$factory =self::getMatchersFactory();
383382
returnnew \Phake\Proxies\CallStubberProxy($factory->createMatcherChain($arguments),true);
384383
}
385384

@@ -525,7 +524,7 @@ public static function setReference($value)
525524
*/
526525
publicstaticfunctiontimes($count)
527526
{
528-
returnnew \Phake\CallRecorder\VerifierMode\Times((int)$count);
527+
returnnew \Phake\CallRecorder\VerifierMode\Times((int)$count);
529528
}
530529

531530
/**
@@ -548,7 +547,7 @@ public static function never()
548547
*/
549548
publicstaticfunctionatLeast($count)
550549
{
551-
returnnew \Phake\CallRecorder\VerifierMode\AtLeast((int)$count);
550+
returnnew \Phake\CallRecorder\VerifierMode\AtLeast((int)$count);
552551
}
553552

554553
/**
@@ -562,7 +561,7 @@ public static function atLeast($count)
562561
*/
563562
publicstaticfunctionatMost($count)
564563
{
565-
returnnew \Phake\CallRecorder\VerifierMode\AtMost((int)$count);
564+
returnnew \Phake\CallRecorder\VerifierMode\AtMost((int)$count);
566565
}
567566

568567
/**
@@ -593,23 +592,21 @@ public static function ignoreRemaining()
593592
publicstaticfunctiongetClient()
594593
{
595594
if (!isset(self::$client)) {
596-
if (class_exists('PHPUnit\Framework\TestCase')) {
595+
if (class_exists(\PHPUnit\Framework\TestCase::class)) {
597596
if (9 <= \PHPUnit\Runner\Version::id()) {
598597
returnself::$client =new \Phake\Client\PHPUnit9();
599598
}elseif (8 <= \PHPUnit\Runner\Version::id()) {
600599
returnself::$client =new \Phake\Client\PHPUnit8();
601600
}elseif (7 <= \PHPUnit\Runner\Version::id()) {
602601
returnself::$client =new \Phake\Client\PHPUnit7();
603-
}else {
604-
returnself::$client =new \Phake\Client\PHPUnit6();
605602
}
603+
returnself::$client =new \Phake\Client\PHPUnit6();
606604
}elseif (class_exists('PHPUnit_Framework_TestCase')) {
607605
returnself::$client =new \Phake\Client\PHPUnit();
608606
}
609607
returnself::$client =new \Phake\Client\DefaultClient();
610-
}else {
611-
returnself::$client;
612608
}
609+
returnself::$client;
613610
}
614611

615612
/**
@@ -624,15 +621,15 @@ public static function setClient($client)
624621
{
625622
if ($clientinstanceof \Phake\Client\IClient) {
626623
self::$client =$client;
627-
}elseif ($client ==self::CLIENT_PHPUNIT) {
624+
}elseif (self::CLIENT_PHPUNIT ==$client) {
628625
self::$client =new \Phake\Client\PHPUnit();
629-
}elseif ($client ==self::CLIENT_PHPUNIT6) {
626+
}elseif (self::CLIENT_PHPUNIT6 ==$client) {
630627
self::$client =new \Phake\Client\PHPUnit6();
631-
}elseif ($client ==self::CLIENT_PHPUNIT7) {
628+
}elseif (self::CLIENT_PHPUNIT7 ==$client) {
632629
self::$client =new \Phake\Client\PHPUnit7();
633-
}elseif ($client ==self::CLIENT_PHPUNIT8) {
630+
}elseif (self::CLIENT_PHPUNIT8 ==$client) {
634631
self::$client =new \Phake\Client\PHPUnit8();
635-
}elseif ($client ==self::CLIENT_PHPUNIT9) {
632+
}elseif (self::CLIENT_PHPUNIT9 ==$client) {
636633
self::$client =new \Phake\Client\PHPUnit9();
637634
}else {
638635
self::$client =new \Phake\Client\DefaultClient();
@@ -719,16 +716,13 @@ public static function initAnnotations($obj)
719716
*/
720717
publicstaticfunctionassertValidMock($mock)
721718
{
722-
if ($mockinstanceof \Phake\IMock)
723-
{
719+
if ($mockinstanceof \Phake\IMock) {
724720
return;
725721
}
726722

727-
if (is_string($mock) &&class_exists($mock,false))
728-
{
723+
if (is_string($mock) &&class_exists($mock,false)) {
729724
$reflClass =new \ReflectionClass($mock);
730-
if ($reflClass->implementsInterface(\Phake\IMock::class))
731-
{
725+
if ($reflClass->implementsInterface(\Phake\IMock::class)) {
732726
return;
733727
}
734728
}
@@ -764,16 +758,14 @@ public static function getName($mock)
764758
publicstaticfunctiongetInfo($mock)
765759
{
766760
static::assertValidMock($mock);
767-
if ($mockinstanceof \Phake\IMock)
768-
{
761+
if ($mockinstanceof \Phake\IMock) {
769762
assert(isset($mock->__PHAKE_info));
770763
return$mock->__PHAKE_info;
771764
}
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;
777769
}
778770

779771
/**

‎src/Phake/Annotation/LegacyReader.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public function getMockType(ReflectionProperty $property): ?string
7474
$mockedClass =null;
7575
$annotations =$this->getPropertyAnnotations($property);
7676

77-
if ($annotations['Mock'] !==true) {
78-
$mockedClass =$annotations['Mock'];
79-
}elseif (isset($annotations['var'])) {
80-
$mockedClass =$annotations['var'];
81-
}
77+
if (true !==$annotations['Mock']) {
78+
$mockedClass =$annotations['Mock'];
79+
}elseif (isset($annotations['var'])) {
80+
$mockedClass =$annotations['var'];
81+
}
8282

83-
if ($mockedClass &&substr($mockedClass,0,1) !=='\\' &&$this->useDoctrineParser()) {
84-
$parser =new \Doctrine\Common\Annotations\PhpParser();
83+
if ($mockedClass &&'\\' !==substr($mockedClass,0,1) &&$this->useDoctrineParser()) {
84+
$parser =new \Doctrine\Common\Annotations\PhpParser();
8585

8686
$reflectionClass =$property->getDeclaringClass();
8787
$useStatements =$parser->parseClass($reflectionClass);
@@ -92,7 +92,7 @@ public function getMockType(ReflectionProperty $property): ?string
9292
}elseif ($reflectionClass->getNamespaceName() &&$this->definedUnderTestNamespace($mockedClass,$reflectionClass->getNamespaceName())) {
9393
$mockedClass =$reflectionClass->getNamespaceName() .'\\' .$mockedClass;
9494
}
95-
}
95+
}
9696

9797
return$mockedClass;
9898
}
@@ -110,7 +110,7 @@ private function getPropertyAnnotations(\ReflectionProperty $property)
110110
if ($comment =$property->getDocComment()) {
111111
foreach (explode("\n",$comment)as$line) {
112112
if (preg_match('#^\s+\*\s*@(\w+)(?:\s+(.*))?\s*$#',$line,$matches)) {
113-
$annotations[$matches[1]] =isset($matches[2]) ?$matches[2] :true;
113+
$annotations[$matches[1]] =$matches[2] ??true;
114114
}
115115
}
116116
}
@@ -119,7 +119,7 @@ private function getPropertyAnnotations(\ReflectionProperty $property)
119119

120120
privatefunctionuseDoctrineParser():bool
121121
{
122-
returnclass_exists('Doctrine\Common\Annotations\PhpParser');
122+
returnclass_exists(\Doctrine\Common\Annotations\PhpParser::class);
123123
}
124124

125125
/**

‎src/Phake/Annotation/MockInitializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct(IReader $reader = null)
9595
*/
9696
publicfunctioninitialize($object)
9797
{
98-
$class=new \ReflectionClass($object);
98+
$class =new \ReflectionClass($object);
9999

100100
foreach ($this->reader->getPropertiesWithMockAnnotation($class)as$property) {
101101
$mockedClass =$this->reader->getMockType($property);

‎src/Phake/Annotation/NativeReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getPropertiesWithMockAnnotation(ReflectionClass $class): iterabl
7575

7676
publicfunctiongetMockType(ReflectionProperty$property): ?string
7777
{
78-
foreach($property->getAttributes(self::ANNOTATION_NAME)as$attribute) {
78+
foreach($property->getAttributes(self::ANNOTATION_NAME)as$attribute) {
7979
$args =$attribute->getArguments();
8080

8181
return$args[0] ??$args['class'] ??null;

‎src/Phake/CallRecorder/Call.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
<?php
22

33
namespacePhake\CallRecorder;
4-
/*
4+
5+
/*
56
* Phake - Mocking Framework
6-
*
7+
*
78
* Copyright (c) 2010-2021, Mike Lively <m@digitalsandwich.com>
89
* All rights reserved.
9-
*
10+
*
1011
* Redistribution and use in source and binary forms, with or without
1112
* modification, are permitted provided that the following conditions
1213
* are met:
13-
*
14+
*
1415
* * Redistributions of source code must retain the above copyright
1516
* notice, this list of conditions and the following disclaimer.
16-
*
17+
*
1718
* * Redistributions in binary form must reproduce the above copyright
1819
* notice, this list of conditions and the following disclaimer in
1920
* the documentation and/or other materials provided with the
2021
* distribution.
21-
*
22+
*
2223
* * Neither the name of Mike Lively nor the names of his
2324
* contributors may be used to endorse or promote products derived
2425
* from this software without specific prior written permission.
25-
*
26+
*
2627
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2728
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2829
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -35,7 +36,7 @@
3536
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
3637
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3738
* POSSIBILITY OF SUCH DAMAGE.
38-
*
39+
*
3940
* @category Testing
4041
* @package Phake
4142
* @author Mike Lively <m@digitalsandwich.com>
@@ -108,13 +109,13 @@ public function getArguments()
108109
publicfunction__toString()
109110
{
110111
$converter =new \Phake\String\Converter();
111-
$arguments =array();
112+
$arguments =[];
112113
foreach ($this->argumentsas$argument) {
113114
$arguments[] =$converter->convertToString($argument);
114115
}
115116

116117
$name = \Phake::getName($this->object);
117118
$access =is_string($this->object) ?'::' :'->';
118-
return"{$name}{$access}{$this->method}(" .implode(',',$arguments) .")";
119+
return"{$name}{$access}{$this->method}(" .implode(',',$arguments) .')';
119120
}
120121
}

‎src/Phake/CallRecorder/CallExpectation.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ public function getVerifierMode()
122122

123123
publicfunction__toString()
124124
{
125-
$arguments =array();
125+
$arguments =[];
126126

127127
$argumentMatcher =$this->argumentMatcher;
128128

129-
while (!empty($argumentMatcher))
130-
{
129+
while (!empty($argumentMatcher)) {
131130
$arguments[] =$argumentMatcher->__toString();
132131
$argumentMatcher =$argumentMatcher->getNextMatcher();
133132
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp