Skip to content

Commit e4583ac

Browse files
committed
Add tests for Multibyte characters and fix style
1 parent d369678 commit e4583ac

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
parameters:
2+
checkGenericClassInNonGenericObjectType: false
3+
checkMissingIterableValueType: false

src/TypeResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ private function resolveSingleType(string $type, Context $context)
302302

303303
/**
304304
* Adds a keyword to the list of Keywords and associates it with a specific Value Object.
305+
*
306+
* @psalm-param class-string<Type> $typeClassName
305307
*/
306308
public function addKeyword(string $keyword, string $typeClassName) : void
307309
{

src/Types/Compound.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace phpDocumentor\Reflection\Types;
1515

1616
use ArrayIterator;
17-
use InvalidArgumentException;
1817
use IteratorAggregate;
1918
use phpDocumentor\Reflection\Type;
2019
use function implode;
@@ -66,7 +65,7 @@ public function has(int $index) : bool
6665
/**
6766
* Tests if this compound type contains the given type.
6867
*/
69-
public function contains(Type $type): bool
68+
public function contains(Type $type) : bool
7069
{
7170
foreach ($this->types as $typePart) {
7271
// if the type is duplicate; do not add it
@@ -94,7 +93,7 @@ public function getIterator()
9493
return new ArrayIterator($this->types);
9594
}
9695

97-
private function add(Type $type): void
96+
private function add(Type $type) : void
9897
{
9998
// if the type is duplicate; do not add it
10099
if ($this->contains($type)) {

tests/unit/FqsenResolverTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @coversDefaultClass \phpDocumentor\Reflection\FqsenResolver
2121
* @covers ::<private>
2222
*/
23-
class FqsenResolverTest extends TestCase
23+
final class FqsenResolverTest extends TestCase
2424
{
2525
/**
2626
* @covers ::resolve
@@ -32,7 +32,20 @@ public function testResolveFqsen() : void
3232
$context = new Context('', []);
3333

3434
$result = $fqsenResolver->resolve('\DocBlock', $context);
35-
static::assertEquals('\DocBlock', (string) $result);
35+
static::assertSame('\DocBlock', (string) $result);
36+
}
37+
38+
/**
39+
* @covers ::resolve
40+
*/
41+
public function testResolveFqsenWithEmoji() : void
42+
{
43+
$fqsenResolver = new FqsenResolver();
44+
45+
$context = new Context('', []);
46+
47+
$result = $fqsenResolver->resolve('\My😁DocBlock', $context);
48+
static::assertSame('\My😁DocBlock', (string) $result);
3649
}
3750

3851
/**
@@ -43,7 +56,7 @@ public function testResolveWithoutContext() : void
4356
$fqsenResolver = new FqsenResolver();
4457

4558
$result = $fqsenResolver->resolve('\DocBlock');
46-
static::assertEquals('\DocBlock', (string) $result);
59+
static::assertSame('\DocBlock', (string) $result);
4760
}
4861

4962
/**
@@ -56,7 +69,7 @@ public function testResolveFromAlias() : void
5669
$context = new Context('somens', ['ns' => 'some\other\ns']);
5770

5871
$result = $fqsenResolver->resolve('ns', $context);
59-
static::assertEquals('\some\other\ns', (string) $result);
72+
static::assertSame('\some\other\ns', (string) $result);
6073
}
6174

6275
/**
@@ -69,7 +82,7 @@ public function testResolveFromPartialAlias() : void
6982
$context = new Context('somens', ['other' => 'some\other']);
7083

7184
$result = $fqsenResolver->resolve('other\ns', $context);
72-
static::assertEquals('\some\other\ns', (string) $result);
85+
static::assertSame('\some\other\ns', (string) $result);
7386
}
7487

7588
public function testResolveThrowsExceptionWhenGarbageInputIsPassed() : void

tests/unit/TypeResolverTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class TypeResolverTest extends TestCase
3333
{
3434
/**
3535
* Call Mockery::close after each test.
36-
*
37-
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint
3836
*/
3937
public function tearDown() : void
4038
{
@@ -669,6 +667,7 @@ public function provideFqcn() : array
669667
return [
670668
'namespace' => ['\phpDocumentor\Reflection'],
671669
'class' => ['\phpDocumentor\Reflection\DocBlock'],
670+
'class with emoji' => ['\My😁Class'],
672671
];
673672
}
674673
}

tests/unit/Types/CompoundTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace phpDocumentor\Reflection\Types;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use TypeError;
18+
use function iterator_to_array;
1719

1820
/**
1921
* @coversDefaultClass \phpDocumentor\Reflection\Types\Compound
@@ -25,7 +27,7 @@ final class CompoundTest extends TestCase
2527
*/
2628
public function testCompoundCannotBeConstructedFromType() : void
2729
{
28-
$this->expectException(\TypeError::class);
30+
$this->expectException(TypeError::class);
2931
new Compound(['foo']);
3032
}
3133

0 commit comments

Comments
 (0)