Skip to content

Commit 76bbb04

Browse files
fixed psalm errros and info issues
1 parent 1ab6a4e commit 76bbb04

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

src/OGM.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function map(array $data): mixed
4141
'OffsetDateTime' => $this->mapDateTime($data['_value']),
4242
'Time' => $this->mapTime($data['_value']),
4343
'LocalTime' => $this->mapLocalTime($data['_value']),
44-
'LocalDateTime'=> $this->mapLocalDateTime($data['_value']),
45-
'Duration'=>$this->mapDuration($data['_value']),
44+
'LocalDateTime' => $this->mapLocalDateTime($data['_value']),
45+
'Duration' => $this->mapDuration($data['_value']),
4646

4747
'String' => $this->isValidTimeZone($data['_value'])
4848
? new DateTimeZoneId($data['_value']) // Convert timezone strings to `DateTimeZoneId`
@@ -147,19 +147,19 @@ private function mapProperties(array $properties): array
147147
return $mappedProperties;
148148
}
149149

150-
private function mapDate(string $value)
150+
private function mapDate(string $value): Date
151151
{
152152
$totalDaysSinceEpoch = (new \DateTime($value))->diff(new \DateTime('@0'))->days;
153153

154154
return new Date($totalDaysSinceEpoch);
155155
}
156156

157-
private function mapDateTime(string $value)
157+
private function mapDateTime(string $value): DateTime
158158
{
159159
return new DateTime($value);
160160
}
161161

162-
private function mapDateTimeZoneId(string $value)
162+
private function mapDateTimeZoneId(string $value): DateTimeZoneId
163163
{
164164
return new DateTimeZoneId($value);
165165
}
@@ -169,24 +169,24 @@ private function isValidTimeZone(string $value): bool
169169
return in_array($value, timezone_identifiers_list(), true);
170170
}
171171

172-
private function mapTime(mixed $_value)
172+
private function mapTime(mixed $_value): Time
173173
{
174174
return new Time($_value);
175175

176176
}
177177

178-
private function mapLocalTime(mixed $_value)
178+
private function mapLocalTime(mixed $_value): LocalTime
179179
{
180180
return new LocalTime($_value);
181181
}
182182

183-
private function mapLocalDateTime(mixed $_value)
183+
private function mapLocalDateTime(mixed $_value): LocalDateTime
184184
{
185-
return new LocalDateTime($_value);
185+
return new LocalDateTime($_value);
186186
}
187187

188-
private function mapDuration(mixed $_value)
188+
private function mapDuration(mixed $_value): Duration
189189
{
190-
return new Duration($_value);
190+
return new Duration($_value);
191191
}
192192
}

src/Objects/Temporal/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
final class Date
66
{
7-
public int $days;
7+
public int $days;
88

99
public function __construct(int $days)
1010
{

src/Results/ResultSet.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
/**
1717
* @template TValue
18+
* @implements ArrayAccess<int, ResultRow>
1819
* @implements IteratorAggregate<int, ResultRow>
1920
*/
2021
final class ResultSet implements IteratorAggregate, Countable, ArrayAccess
@@ -28,8 +29,7 @@ public function __construct(
2829
public readonly AccessMode $accessMode,
2930
public readonly ?ResultCounters $counters = null,
3031
public readonly ?ProfiledQueryPlan $profiledQueryPlan = null
31-
)
32-
{
32+
) {
3333
}
3434

3535
/**
@@ -56,21 +56,25 @@ public function get(int $index): ResultRow
5656
return $this->rows[$index];
5757

5858
}
59+
#[\Override]
5960

6061
public function offsetExists(mixed $offset): bool
6162
{
6263
return isset($this->rows[$offset]);
6364
}
65+
#[\Override]
6466

6567
public function offsetGet(mixed $offset): mixed
6668
{
6769
return $this->rows[$offset] ?? throw new \OutOfBoundsException("Index $offset is out of bounds.");
6870
}
71+
#[\Override]
6972

7073
public function offsetSet(mixed $offset, mixed $value): void
7174
{
7275
throw new \LogicException("ResultSet is immutable. You cannot modify elements.");
7376
}
77+
#[\Override]
7478

7579
public function offsetUnset(mixed $offset): void
7680
{

tests/Integration/Neo4jQueryAPIIntegrationTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
final class Neo4jQueryAPIIntegrationTest extends TestCase
2626
{
2727
private Neo4jQueryAPI $api;
28+
#[\Override]
2829

29-
#[Override]
3030
public function setUp(): void
3131
{
3232
parent::setUp();
@@ -136,9 +136,12 @@ public function testTemporalDateTime(): void
136136
$datetime = $results->rows[0]->data['datetime'];
137137
$this->assertInstanceOf(DateTime::class, $datetime);
138138

139-
$this->assertEquals(date_create()->format('Y-m-d'), $datetime->getDateTime()->format('Y-m-d'));
139+
$now = date_create();
140+
$this->assertNotFalse($now);
141+
$this->assertEquals($now->format('Y-m-d'), $datetime->getDateTime()->format('Y-m-d'));
140142
}
141143

144+
142145
public function testTemporalDateTimeZoneId(): void
143146
{
144147
$results = $this->api->run("RETURN 'America/New_York' AS timezone");
@@ -165,6 +168,8 @@ public function testTemporalTime(): void
165168

166169
$neo4jTime = $time->getTime();
167170
$expectedTime = (new \DateTime())->format('H:i');
171+
$this->assertNotEmpty($expectedTime);
172+
168173
$this->assertStringStartsWith($expectedTime, $neo4jTime);
169174
}
170175

@@ -180,6 +185,7 @@ public function testTemporalLocalTime(): void
180185
$neo4jLocalTime = $localTime->getLocalTime();
181186

182187
$expectedLocalTime = (new \DateTime())->format('H:i');
188+
$this->assertNotEmpty($expectedLocalTime);
183189

184190
$this->assertStringStartsWith($expectedLocalTime, $neo4jLocalTime);
185191
}
@@ -197,7 +203,11 @@ public function testTemporalLocalDateTime(): void
197203

198204
$neo4jLocalDateTime = $localDateTime->getLocalDateTime();
199205

200-
$expectedDate = date_create()->format('Y-m-d');
206+
$expectedDateTime = date_create();
207+
$this->assertNotFalse($expectedDateTime); // 💡 Ensure it's not false
208+
209+
$expectedDate = $expectedDateTime->format('Y-m-d');
210+
$this->assertNotEmpty($expectedDate);
201211

202212
$this->assertEquals($expectedDate, $neo4jLocalDateTime->format('Y-m-d'));
203213
}

tests/Unit/Temporal/OGMTemporalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
use Neo4j\QueryAPI\OGM;
77
use Neo4j\QueryAPI\Objects\Temporal\Date;
88

9-
class OGMTemporalTest extends TestCase
9+
final class OGMTemporalTest extends TestCase
1010
{
1111
private OGM $ogm;
12+
#[\Override]
1213

1314
protected function setUp(): void
1415
{

0 commit comments

Comments
 (0)