Commit 526354e
committed
Change how to stringify Stringable objects
This library's goal is to convert anything to a string, and although it
seems obvious to return the content of the `__toString()` method, that
behavior does not tell the user much about what the input is.
This commit sets the tone for this library: it's for engineers to
represent anything as a string. However, the fact that we can convert
an object to a string does not mean it is a string.
This commit will also change how we verify those objects. Since PHP 8.0,
any object that implements a `__toString()` method automatically
implements the Stringable interface. Since we dropped support for
versions that are less than 8.1, it makes sense to check that instead of
checking if the method exists.
Signed-off-by: Henrique Moody <[email protected]>1 parent b2f1eff commit 526354e
File tree
5 files changed
+41
-58
lines changed- src/Stringifiers
- tests
- fixtures
- integration
- unit/Stringifiers
5 files changed
+41
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | | - | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
14 | 12 | | |
15 | | - | |
16 | | - | |
17 | 13 | | |
18 | 14 | | |
19 | | - | |
| 15 | + | |
20 | 16 | | |
21 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
Lines changed: 22 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 27 | + | |
39 | 28 | | |
40 | 29 | | |
41 | | - | |
| 30 | + | |
42 | 31 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 32 | + | |
50 | 33 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 34 | + | |
54 | 35 | | |
55 | 36 | | |
56 | 37 | | |
57 | | - | |
| 38 | + | |
58 | 39 | | |
59 | | - | |
60 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
61 | 44 | | |
62 | | - | |
| 45 | + | |
63 | 46 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 47 | + | |
70 | 48 | | |
71 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
72 | 54 | | |
73 | | - | |
| 55 | + | |
74 | 56 | | |
75 | 57 | | |
0 commit comments