Skip to content

Commit c93abd8

Browse files
authored
fixes #41 (#42)
* fixes #41
1 parent 06340af commit c93abd8

File tree

7 files changed

+117
-98
lines changed

7 files changed

+117
-98
lines changed

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
</ignoreFiles>
2020
</projectFiles>
2121
<stubs>
22-
<file name="tools/psalm/vendor/vimeo/psalm/stubs/ext-ds.php"/>
22+
<file name="tools/psalm/vendor/vimeo/psalm/stubs/ext-ds.phpstub"/>
2323
</stubs>
2424
<plugins><pluginClass class="Psalm\PhpUnitPlugin\Plugin"/></plugins></psalm>

src/Network/Bolt/BoltInjections.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ public function withAutoRouting($routing): self
101101

102102
public function database(): string
103103
{
104-
if (is_callable($this->database)) {
105-
$this->database = call_user_func($this->database);
104+
if (is_string($this->database)) {
105+
return $this->database;
106106
}
107107

108+
/** @var string */
109+
$this->database = call_user_func($this->database);
110+
108111
return $this->database;
109112
}
110113

src/Network/Http/HttpInjections.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ public function requestFactory(): RequestFactoryInterface
125125

126126
public function database(): string
127127
{
128-
if (is_callable($this->database)) {
129-
$this->database = call_user_func($this->database);
128+
if (is_string($this->database)) {
129+
return $this->database;
130130
}
131131

132+
/** @var string */
133+
$this->database = call_user_func($this->database);
134+
132135
return $this->database;
133136
}
134137

tests/Integration/ComplexQueryTests.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ private static function generate(): Generator
123123
public function testInvalidParameters(string $alias): void
124124
{
125125
$this->expectException(InvalidArgumentException::class);
126+
/** @var iterable<string, iterable<mixed, mixed>|scalar|null> $generator */
127+
$generator = self::generate();
126128
$this->client->run(<<<'CYPHER'
127129
MERGE (x:Node {slug: 'a'})
128130
WITH x
129131
MATCH (x) WHERE x.slug IN $listOrMap RETURN x
130-
CYPHER, self::generate(), $alias);
132+
CYPHER, $generator, $alias);
131133
}
132134

133135
/**

tests/Unit/BoltInjectionsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ public function testConstruct(): void
2626
self::assertEquals('abc', $injections->database());
2727
}
2828

29+
public function testSystem(): void
30+
{
31+
$injections = BoltInjections::create('system');
32+
self::assertEquals('system', $injections->database());
33+
}
34+
2935
public function testWithDatabase(): void
3036
{
3137
$injections = new BoltInjections('abc');

tests/Unit/HttpInjectionsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public function testConstruct(): void
2929
self::assertEquals('abc', $injections->database());
3030
}
3131

32+
public function testSystem(): void
33+
{
34+
self::assertEquals('system', HttpInjections::create()->withDatabase('system')->database());
35+
}
36+
3237
public function testWithDatabase(): void
3338
{
3439
self::assertEquals('test', HttpInjections::create()->withDatabase('test')->database());

0 commit comments

Comments
 (0)