Skip to content

Commit 7462d5f

Browse files
authored
Merge pull request #95 from orklah/coding-standard
bump CS on master
2 parents 70d7abb + 3100228 commit 7462d5f

File tree

5 files changed

+17
-78
lines changed

5 files changed

+17
-78
lines changed

.github/workflows/push.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
all-build-${{ hashFiles('**/composer.lock') }}
132132
all-build-
133133
- name: Code style check
134-
uses: phpDocumentor/coding-standard@v1.0.0
134+
uses: phpDocumentor/coding-standard@master
135135
with:
136136
args: -s
137137

src/TypeResolver.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
use phpDocumentor\Reflection\Types\Object_;
2727
use phpDocumentor\Reflection\Types\String_;
2828
use RuntimeException;
29-
use const PREG_SPLIT_DELIM_CAPTURE;
30-
use const PREG_SPLIT_NO_EMPTY;
3129
use function array_keys;
3230
use function array_pop;
3331
use function class_exists;
@@ -40,6 +38,8 @@
4038
use function strtolower;
4139
use function substr;
4240
use function trim;
41+
use const PREG_SPLIT_DELIM_CAPTURE;
42+
use const PREG_SPLIT_NO_EMPTY;
4343

4444
final class TypeResolver
4545
{
@@ -295,6 +295,7 @@ private function resolveSingleType(string $type, Context $context)
295295
return $this->resolveTypedObject($type);
296296
case $this->isPartialStructuralElementName($type):
297297
return $this->resolveTypedObject($type, $context);
298+
298299
// @codeCoverageIgnoreStart
299300
default:
300301
// I haven't got the foggiest how the logic would come here but added this as a defense.
@@ -381,6 +382,7 @@ private function resolveTypedArray(string $type, Context $context) : Array_
381382
private function resolveKeyword(string $type) : Type
382383
{
383384
$className = $this->keywords[strtolower($type)];
385+
384386
return new $className();
385387
}
386388

src/Types/ContextFactory.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
use Reflector;
2424
use RuntimeException;
2525
use UnexpectedValueException;
26+
use function array_merge;
27+
use function file_exists;
28+
use function file_get_contents;
29+
use function get_class;
30+
use function is_string;
31+
use function token_get_all;
32+
use function trim;
2633
use const T_AS;
2734
use const T_CLASS;
2835
use const T_CURLY_OPEN;
@@ -31,13 +38,6 @@
3138
use const T_NS_SEPARATOR;
3239
use const T_STRING;
3340
use const T_USE;
34-
use function array_merge;
35-
use function file_exists;
36-
use function file_get_contents;
37-
use function get_class;
38-
use function is_string;
39-
use function token_get_all;
40-
use function trim;
4141

4242
/**
4343
* Convenience class to create a Context for DocBlocks when not using the Reflection Component of phpDocumentor.
@@ -172,11 +172,13 @@ public function createForNamespace(string $namespace, string $fileContents) : Co
172172

173173
$tokens->next();
174174
}
175+
175176
break;
176177
case T_USE:
177178
if ($currentNamespace === $namespace) {
178179
$useStatements = array_merge($useStatements, $this->parseUseStatement($tokens));
179180
}
181+
180182
break;
181183
}
182184

@@ -282,6 +284,7 @@ private function extractUseStatements(ArrayIterator $tokens) : array
282284
default:
283285
break;
284286
}
287+
285288
break;
286289
case 'start-alias':
287290
switch ($tokenId) {
@@ -295,6 +298,7 @@ private function extractUseStatements(ArrayIterator $tokens) : array
295298
default:
296299
break;
297300
}
301+
298302
break;
299303
case 'grouped':
300304
switch ($tokenId) {
@@ -318,6 +322,7 @@ private function extractUseStatements(ArrayIterator $tokens) : array
318322
default:
319323
break;
320324
}
325+
321326
break;
322327
case 'grouped-alias':
323328
switch ($tokenId) {

tests/unit/CollectionResolverTest.php

-25
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515

1616
use phpDocumentor\Reflection\Types\Array_;
1717
use phpDocumentor\Reflection\Types\Collection;
18-
use phpDocumentor\Reflection\Types\Compound;
1918
use phpDocumentor\Reflection\Types\Context;
20-
use phpDocumentor\Reflection\Types\Object_;
21-
use phpDocumentor\Reflection\Types\String_;
2219
use PHPUnit\Framework\TestCase;
2320

2421
/**
@@ -40,18 +37,15 @@ public function testResolvingCollection() : void
4037
{
4138
$fixture = new TypeResolver();
4239

43-
/** @var Collection $resolvedType */
4440
$resolvedType = $fixture->resolve('ArrayObject<string>', new Context(''));
4541

4642
$this->assertInstanceOf(Collection::class, $resolvedType);
4743
$this->assertSame('\\ArrayObject<string>', (string) $resolvedType);
4844

4945
$this->assertEquals('\\ArrayObject', (string) $resolvedType->getFqsen());
5046

51-
/** @var String_ $valueType */
5247
$valueType = $resolvedType->getValueType();
5348

54-
/** @var Compound $keyType */
5549
$keyType = $resolvedType->getKeyType();
5650

5751
$this->assertInstanceOf(Types\String_::class, $valueType);
@@ -71,18 +65,15 @@ public function testResolvingCollectionWithKeyType() : void
7165
{
7266
$fixture = new TypeResolver();
7367

74-
/** @var Collection $resolvedType */
7568
$resolvedType = $fixture->resolve('ArrayObject<string[],Iterator>', new Context(''));
7669

7770
$this->assertInstanceOf(Collection::class, $resolvedType);
7871
$this->assertSame('\\ArrayObject<string[],\\Iterator>', (string) $resolvedType);
7972

8073
$this->assertEquals('\\ArrayObject', (string) $resolvedType->getFqsen());
8174

82-
/** @var Object_ $valueType */
8375
$valueType = $resolvedType->getValueType();
8476

85-
/** @var Array_ $keyType */
8677
$keyType = $resolvedType->getKeyType();
8778

8879
$this->assertInstanceOf(Types\Object_::class, $valueType);
@@ -104,16 +95,13 @@ public function testResolvingArrayCollection() : void
10495
{
10596
$fixture = new TypeResolver();
10697

107-
/** @var Collection $resolvedType */
10898
$resolvedType = $fixture->resolve('array<string>', new Context(''));
10999

110100
$this->assertInstanceOf(Array_::class, $resolvedType);
111101
$this->assertSame('string[]', (string) $resolvedType);
112102

113-
/** @var Array_ $valueType */
114103
$valueType = $resolvedType->getValueType();
115104

116-
/** @var Compound $keyType */
117105
$keyType = $resolvedType->getKeyType();
118106

119107
$this->assertInstanceOf(Types\String_::class, $valueType);
@@ -133,16 +121,13 @@ public function testResolvingArrayCollectionWithKey() : void
133121
{
134122
$fixture = new TypeResolver();
135123

136-
/** @var Collection $resolvedType */
137124
$resolvedType = $fixture->resolve('array<string,object|array>', new Context(''));
138125

139126
$this->assertInstanceOf(Array_::class, $resolvedType);
140127
$this->assertSame('array<string,object|array>', (string) $resolvedType);
141128

142-
/** @var Array_ $valueType */
143129
$valueType = $resolvedType->getValueType();
144130

145-
/** @var Compound $keyType */
146131
$keyType = $resolvedType->getKeyType();
147132

148133
$this->assertInstanceOf(Types\String_::class, $keyType);
@@ -162,16 +147,13 @@ public function testResolvingArrayCollectionWithKeyAndWhitespace() : void
162147
{
163148
$fixture = new TypeResolver();
164149

165-
/** @var Collection $resolvedType */
166150
$resolvedType = $fixture->resolve('array<string, object|array>', new Context(''));
167151

168152
$this->assertInstanceOf(Array_::class, $resolvedType);
169153
$this->assertSame('array<string,object|array>', (string) $resolvedType);
170154

171-
/** @var Array_ $valueType */
172155
$valueType = $resolvedType->getValueType();
173156

174-
/** @var Compound $keyType */
175157
$keyType = $resolvedType->getKeyType();
176158

177159
$this->assertInstanceOf(Types\String_::class, $keyType);
@@ -208,24 +190,20 @@ public function testResolvingCollectionOfCollection() : void
208190
{
209191
$fixture = new TypeResolver();
210192

211-
/** @var Collection $resolvedType */
212193
$resolvedType = $fixture->resolve('ArrayObject<string|integer|double,ArrayObject<DateTime>>', new Context(''));
213194

214195
$this->assertInstanceOf(Collection::class, $resolvedType);
215196
$this->assertSame('\\ArrayObject<string|int|float,\\ArrayObject<\\DateTime>>', (string) $resolvedType);
216197

217198
$this->assertEquals('\\ArrayObject', (string) $resolvedType->getFqsen());
218199

219-
/** @var Collection $valueType */
220200
$valueType = $resolvedType->getValueType();
221-
/** @var Object_ $collectionValueType */
222201
$collectionValueType = $valueType->getValueType();
223202
$this->assertInstanceOf(Types\Collection::class, $valueType);
224203
$this->assertInstanceOf(Types\Object_::class, $valueType->getValueType());
225204
$this->assertEquals('\\ArrayObject', (string) $valueType->getFqsen());
226205
$this->assertEquals('\\DateTime', (string) $collectionValueType->getFqsen());
227206

228-
/** @var Compound $keyType */
229207
$keyType = $resolvedType->getKeyType();
230208
$this->assertInstanceOf(Types\Compound::class, $keyType);
231209
$this->assertInstanceOf(Types\String_::class, $keyType->get(0));
@@ -294,16 +272,13 @@ public function testResolvingCollectionAsArray() : void
294272
{
295273
$fixture = new TypeResolver();
296274

297-
/** @var Collection $resolvedType */
298275
$resolvedType = $fixture->resolve('array<string,float>', new Context(''));
299276

300277
$this->assertInstanceOf(Array_::class, $resolvedType);
301278
$this->assertSame('array<string,float>', (string) $resolvedType);
302279

303-
/** @var Array_ $valueType */
304280
$valueType = $resolvedType->getValueType();
305281

306-
/** @var Compound $keyType */
307282
$keyType = $resolvedType->getKeyType();
308283

309284
$this->assertInstanceOf(Types\Float_::class, $valueType);

0 commit comments

Comments
 (0)