Skip to content

Commit b65188e

Browse files
committed
psalm fixed
1 parent 6d18818 commit b65188e

File tree

7 files changed

+30
-11
lines changed

7 files changed

+30
-11
lines changed

src/Common/DNSAddressResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace Laudis\Neo4j\Common;
1515

16+
use Generator;
17+
use Traversable;
1618
use function array_filter;
1719
use function array_map;
1820
use function array_unique;
@@ -29,9 +31,9 @@
2931
class DNSAddressResolver implements AddressResolverInterface
3032
{
3133
/**
32-
* @return iterable<string>
34+
* @return Generator<string>
3335
*/
34-
public function getAddresses(string $host): iterable
36+
public function getAddresses(string $host): Generator
3537
{
3638
// By using the generator pattern we make sure to call the heavy DNS IO operations
3739
// as late as possible

src/Contracts/AddressResolverInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313

1414
namespace Laudis\Neo4j\Contracts;
1515

16+
use Generator;
17+
1618
interface AddressResolverInterface
1719
{
1820
/**
1921
* Returns the addresses.
2022
*
21-
* @return iterable<string>
23+
* @return Generator<string>
2224
*/
23-
public function getAddresses(string $host): iterable;
25+
public function getAddresses(string $host): Generator;
2426
}

tests/Integration/BoltDriverIntegrationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ final class BoltDriverIntegrationTest extends EnvironmentAwareIntegrationTest
2424
{
2525
/**
2626
* @throws Exception
27+
* @psalm-suppress MixedMethodCall
2728
*/
2829
public function testValidHostname(): void
2930
{
@@ -36,6 +37,7 @@ public function testValidHostname(): void
3637

3738
/**
3839
* @throws Exception
40+
* @psalm-suppress MixedMethodCall
3941
*/
4042
public function testValidUrl(): void
4143
{

tests/Unit/CypherListTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ public function testIteration(): void
264264
self::assertEquals(3, $counter);
265265
}
266266

267+
/**
268+
* @psalm-suppress UnevaluatedCode
269+
* @psalm-suppress NoValue
270+
* @psalm-suppress UnusedVariable
271+
*/
267272
public function testIterationEmpty(): void
268273
{
269274
$counter = 0;
@@ -443,8 +448,6 @@ public function testSlice(): void
443448
return $x;
444449
});
445450

446-
/** @var int $sumBefore */
447-
/** @var int $sumAfter */
448451
$start = $range->get(0);
449452

450453
self::assertEquals(5, $start);

tests/Unit/CypherMapTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ public function testIteration(): void
266266
self::assertEquals(3, $counter);
267267
}
268268

269+
/**
270+
* @psalm-suppress UnevaluatedCode
271+
* @psalm-suppress UnusedVariable
272+
* @psalm-suppress NoValue
273+
*/
269274
public function testIterationEmpty(): void
270275
{
271276
$counter = 0;
@@ -420,6 +425,7 @@ public function testSkipInvalid(): void
420425

421426
public function testInvalidConstruct(): void
422427
{
428+
/** @psalm-suppress MissingTemplateParam */
423429
$map = new CypherMap(new class() implements IteratorAggregate {
424430
public function getIterator(): Generator
425431
{

tests/Unit/DNSAddressResolverTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,24 @@ protected function setUp(): void
2828

2929
public function testResolverGhlenDotCom(): void
3030
{
31-
$records = [...$this->resolver->getAddresses('test.ghlen.com')];
31+
$records = iterator_to_array($this->resolver->getAddresses('test.ghlen.com'));
3232

3333
$this->assertEqualsCanonicalizing(['test.ghlen.com', '123.123.123.123', '123.123.123.124'], $records);
3434
$this->assertNotEmpty($records);
35-
$this->assertEquals('test.ghlen.com', $records[0]);
35+
$this->assertEquals('test.ghlen.com', $records[0] ?? '');
3636
}
3737

3838
public function testResolverGoogleDotComReverse(): void
3939
{
40-
$records = [...$this->resolver->getAddresses('8.8.8.8')];
40+
$records = iterator_to_array($this->resolver->getAddresses('8.8.8.8'));
4141

4242
$this->assertNotEmpty($records);
4343
$this->assertContains('8.8.8.8', $records);
4444
}
4545

4646
public function testBogus(): void
4747
{
48-
$this->assertEquals(['bogus'], [...$this->resolver->getAddresses('bogus')]);
48+
$addresses = iterator_to_array($this->resolver->getAddresses('bogus'));
49+
$this->assertEquals('bogus', $addresses);
4950
}
5051
}

tests/Unit/ParameterHelperTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ final class ParameterHelperTest extends TestCase
3232
public static function setUpBeforeClass(): void
3333
{
3434
parent::setUpBeforeClass();
35-
/** @psalm-suppress MixedPropertyTypeCoercion */
35+
/**
36+
* @psalm-suppress MixedPropertyTypeCoercion
37+
* @psalm-suppress MissingTemplateParam
38+
*/
3639
self::$invalidIterable = new class() implements Iterator {
3740
private bool $initial = true;
3841

0 commit comments

Comments
 (0)