Skip to content

Commit ce2e9ed

Browse files
committed
Add @psalm-return non-empty-string on toString methods (and alike).
1 parent 4682c4e commit ce2e9ed

17 files changed

+93
-0
lines changed

src/DayOfWeek.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ public function minus(int $days): DayOfWeek
226226

227227
/**
228228
* Serializes as a string using {@see DayOfWeek::toString()}.
229+
*
230+
* @psalm-return non-empty-string
229231
*/
230232
public function jsonSerialize(): string
231233
{
@@ -234,6 +236,8 @@ public function jsonSerialize(): string
234236

235237
/**
236238
* Returns the capitalized English name of this day-of-week.
239+
*
240+
* @psalm-return non-empty-string
237241
*/
238242
public function toString(): string
239243
{

src/Duration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ public function toNanosPart(): int
756756

757757
/**
758758
* Serializes as a string using {@see Duration::toISOString()}.
759+
*
760+
* @psalm-return non-empty-string
759761
*/
760762
public function jsonSerialize(): string
761763
{
@@ -772,6 +774,8 @@ public function jsonSerialize(): string
772774
* The hours, minutes and seconds will all have the same sign.
773775
*
774776
* Note that multiples of 24 hours are not output as days to avoid confusion with Period.
777+
*
778+
* @psalm-return non-empty-string
775779
*/
776780
public function toISOString(): string
777781
{
@@ -817,6 +821,8 @@ public function toISOString(): string
817821

818822
/**
819823
* {@see Duration::toISOString()}.
824+
*
825+
* @psalm-return non-empty-string
820826
*/
821827
public function __toString(): string
822828
{

src/Instant.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ public function toDecimal(): string
368368

369369
/**
370370
* Serializes as a string using {@see Instant::toISOString()}.
371+
*
372+
* @psalm-return non-empty-string
371373
*/
372374
public function jsonSerialize(): string
373375
{
@@ -376,6 +378,8 @@ public function jsonSerialize(): string
376378

377379
/**
378380
* Returns the ISO 8601 representation of this instant.
381+
*
382+
* @psalm-return non-empty-string
379383
*/
380384
public function toISOString(): string
381385
{
@@ -384,6 +388,8 @@ public function toISOString(): string
384388

385389
/**
386390
* {@see Instant::toISOString()}.
391+
*
392+
* @psalm-return non-empty-string
387393
*/
388394
public function __toString(): string
389395
{

src/Interval.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public function isEqualTo(Interval $that): bool
140140

141141
/**
142142
* Serializes as a string using {@see Interval::toISOString()}.
143+
*
144+
* @psalm-return non-empty-string
143145
*/
144146
public function jsonSerialize(): string
145147
{
@@ -148,6 +150,8 @@ public function jsonSerialize(): string
148150

149151
/**
150152
* Returns the ISO 8601 representation of this interval.
153+
*
154+
* @psalm-return non-empty-string
151155
*/
152156
public function toISOString(): string
153157
{
@@ -156,6 +160,8 @@ public function toISOString(): string
156160

157161
/**
158162
* {@see Interval::toISOString()}.
163+
*
164+
* @psalm-return non-empty-string
159165
*/
160166
public function __toString(): string
161167
{

src/LocalDate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ public function toNativeDateTimeImmutable(): DateTimeImmutable
771771

772772
/**
773773
* Serializes as a string using {@see LocalDate::toISOString()}.
774+
*
775+
* @psalm-return non-empty-string
774776
*/
775777
public function jsonSerialize(): string
776778
{
@@ -779,6 +781,8 @@ public function jsonSerialize(): string
779781

780782
/**
781783
* Returns the ISO 8601 representation of this date.
784+
*
785+
* @psalm-return non-empty-string
782786
*/
783787
public function toISOString(): string
784788
{
@@ -799,6 +803,8 @@ public function toISOString(): string
799803

800804
/**
801805
* {@see LocalDate::toISOString()}.
806+
*
807+
* @psalm-return non-empty-string
802808
*/
803809
public function __toString(): string
804810
{

src/LocalDateRange.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ public function toNativeDatePeriod(): DatePeriod
262262

263263
/**
264264
* Returns the ISO 8601 representation of this date range.
265+
*
266+
* @psalm-return non-empty-string
265267
*/
266268
public function toISOString(): string
267269
{
@@ -270,6 +272,8 @@ public function toISOString(): string
270272

271273
/**
272274
* {@see LocalDateRange::toISOString()}.
275+
*
276+
* @psalm-return non-empty-string
273277
*/
274278
public function __toString(): string
275279
{

src/LocalDateTime.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ public function toNativeDateTimeImmutable(): DateTimeImmutable
738738

739739
/**
740740
* Serializes as a string using {@see LocalDateTime::toISOString()}.
741+
*
742+
* @psalm-return non-empty-string
741743
*/
742744
public function jsonSerialize(): string
743745
{
@@ -746,6 +748,8 @@ public function jsonSerialize(): string
746748

747749
/**
748750
* Returns the ISO 8601 representation of this date time.
751+
*
752+
* @psalm-return non-empty-string
749753
*/
750754
public function toISOString(): string
751755
{
@@ -754,6 +758,8 @@ public function toISOString(): string
754758

755759
/**
756760
* {@see LocalDateTime::toISOString()}.
761+
*
762+
* @psalm-return non-empty-string
757763
*/
758764
public function __toString(): string
759765
{

src/LocalTime.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ public function toNativeDateTimeImmutable(): DateTimeImmutable
643643

644644
/**
645645
* Serializes as a string using {@see LocalTime::toISOString()}.
646+
*
647+
* @psalm-return non-empty-string
646648
*/
647649
public function jsonSerialize(): string
648650
{
@@ -661,6 +663,8 @@ public function jsonSerialize(): string
661663
* The format used will be the shortest that outputs the full value of
662664
* the time where the omitted parts are implied to be zero.
663665
* The nanoseconds value, if present, can be 0 to 9 digits.
666+
*
667+
* @psalm-return non-empty-string
664668
*/
665669
public function toISOString(): string
666670
{
@@ -674,6 +678,8 @@ public function toISOString(): string
674678

675679
/**
676680
* {@see LocalTime::toISOString()}.
681+
*
682+
* @psalm-return non-empty-string
677683
*/
678684
public function __toString(): string
679685
{

src/Month.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ public function minus(int $months): Month
201201

202202
/**
203203
* Serializes as a string using {@see Month::toString()}.
204+
*
205+
* @psalm-return non-empty-string
204206
*/
205207
public function jsonSerialize(): string
206208
{
@@ -209,6 +211,8 @@ public function jsonSerialize(): string
209211

210212
/**
211213
* Returns the capitalized English name of this Month.
214+
*
215+
* @psalm-return non-empty-string
212216
*/
213217
public function toString(): string
214218
{

src/MonthDay.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ public function atYear(int $year): LocalDate
243243

244244
/**
245245
* Serializes as a string using {@see MonthDay::toISOString()}.
246+
*
247+
* @psalm-return non-empty-string
246248
*/
247249
public function jsonSerialize(): string
248250
{
@@ -251,6 +253,8 @@ public function jsonSerialize(): string
251253

252254
/**
253255
* Returns the ISO 8601 representation of this month-day.
256+
*
257+
* @psalm-return non-empty-string
254258
*/
255259
public function toISOString(): string
256260
{
@@ -263,6 +267,8 @@ public function toISOString(): string
263267

264268
/**
265269
* {@see MonthDay::toISOString()}.
270+
*
271+
* @psalm-return non-empty-string
266272
*/
267273
public function __toString(): string
268274
{

0 commit comments

Comments
 (0)