You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Coerce.php
+4-4
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ public static function toInt(mixed $value, bool $allowBool = false): int
55
55
returnself::stringToInt($value);
56
56
}
57
57
58
-
thrownewTypeError('Only ' . ( $allowBool ? 'booleans, ' : '' ) . 'numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: ' . Debug::sanitizeData($value));
58
+
thrownewTypeError('Only ' . ( $allowBool ? 'booleans, ' : '' ) . 'numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: ' . Debug::sanitizeData($value));
59
59
}
60
60
61
61
/**
@@ -150,7 +150,7 @@ public static function intToBool(int $value): bool
150
150
returnmatch($value) {
151
151
0 => false,
152
152
1 => true,
153
-
default => thrownewTypeError('Only 0 and 1 can be coerced from an int to a boolean, given value: ' . Debug::sanitizeData($value)),
153
+
default => thrownewTypeError('Only 0 and 1 can be coerced from an integer to a boolean, given value: ' . Debug::sanitizeData($value)),
154
154
};
155
155
}
156
156
@@ -177,7 +177,7 @@ public static function floatToInt(float $value): int
177
177
return\intval($value);
178
178
}
179
179
180
-
thrownewTypeError('Only numbers with no fractional part can be coerced from a float to an int, given value: ' . Debug::sanitizeData($value));
180
+
thrownewTypeError('Only numbers with no fractional part can be coerced from a float to an integer, given value: ' . Debug::sanitizeData($value));
181
181
}
182
182
183
183
/**
@@ -190,7 +190,7 @@ public static function stringToInt(string $value): int
190
190
return\intval($value);
191
191
}
192
192
193
-
thrownewTypeError('Only numbers with no fractional part can be coerced from a string to an int, given value: ' . Debug::sanitizeData($value));
193
+
thrownewTypeError('Only numbers with no fractional part can be coerced from a string to an integer, given value: ' . Debug::sanitizeData($value));
Copy file name to clipboardExpand all lines: tests/CoerceTest.php
+10-10
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,12 @@ public function testCoerceToInt(): void
29
29
],
30
30
[
31
31
'input' => 'failed',
32
-
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an int, given value: \'failed\''),
32
+
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an integer, given value: \'failed\''),
33
33
'coerceable' => false,
34
34
],
35
35
[
36
36
'input' => '39hello',
37
-
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an int, given value: \'39hello\''),
37
+
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an integer, given value: \'39hello\''),
38
38
'coerceable' => false,
39
39
],
40
40
[
@@ -44,12 +44,12 @@ public function testCoerceToInt(): void
44
44
],
45
45
[
46
46
'input' => true,
47
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: true'),
47
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: true'),
48
48
'coerceable' => false,
49
49
],
50
50
[
51
51
'input' => false,
52
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: false'),
52
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: false'),
53
53
'coerceable' => false,
54
54
],
55
55
[
@@ -70,12 +70,12 @@ public function testCoerceToInt(): void
70
70
],
71
71
[
72
72
'input' => 1.5,
73
-
'output' => newTypeError('Only numbers with no fractional part can be coerced from a float to an int, given value: 1.5'),
73
+
'output' => newTypeError('Only numbers with no fractional part can be coerced from a float to an integer, given value: 1.5'),
74
74
'coerceable' => false,
75
75
],
76
76
[
77
77
'input' => '',
78
-
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an int, given value: \'\''),
78
+
'output' => newTypeError('Only numbers with no fractional part can be coerced from a string to an integer, given value: \'\''),
79
79
'coerceable' => false,
80
80
],
81
81
[
@@ -85,22 +85,22 @@ public function __toString()
85
85
return'amazing';
86
86
}
87
87
},
88
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: object(class@anonymous' . '$end$'),
88
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: object(class@anonymous' . '$end$'),
89
89
'coerceable' => false,
90
90
],
91
91
[
92
92
'input' => [],
93
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: []'),
93
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: []'),
94
94
'coerceable' => false,
95
95
],
96
96
[
97
97
'input' => (object)[],
98
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: object(stdClass)'),
98
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: object(stdClass)'),
99
99
'coerceable' => false,
100
100
],
101
101
[
102
102
'input' => null,
103
-
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an int, given value: NULL'),
103
+
'output' => newTypeError('Only numeric strings and floats with no fractional part are alternative coerceable values for an integer, given value: NULL'),
0 commit comments