Skip to content

Commit 666ffe2

Browse files
committed
✅ Fix potential PHP 7.4 validation problem
1 parent 3af04b5 commit 666ffe2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/ppcp-agentic-commerce/src/Schema/GeoCoordinates.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ protected function parse_fields( array $input, callable $add_issue ): void {
3636

3737
if ( is_int( $latitude ) ) {
3838
$latitude = (float) $latitude;
39-
} elseif ( is_string( $latitude ) && is_numeric( $latitude ) ) {
40-
$latitude = (float) $latitude;
39+
} elseif ( is_string( $latitude ) ) {
40+
$latitude = trim( $latitude );
41+
42+
if ( is_numeric( $latitude ) ) {
43+
$latitude = (float) $latitude;
44+
}
4145
}
4246
if ( is_float( $latitude ) ) {
4347
if ( $latitude < - 90.0 || $latitude > 90.0 ) {
@@ -54,8 +58,12 @@ protected function parse_fields( array $input, callable $add_issue ): void {
5458

5559
if ( is_int( $longitude ) ) {
5660
$longitude = (float) $longitude;
57-
} elseif ( is_string( $longitude ) && is_numeric( $longitude ) ) {
58-
$longitude = (float) $longitude;
61+
} elseif ( is_string( $longitude ) ) {
62+
$longitude = trim( $longitude );
63+
64+
if ( is_numeric( $longitude ) ) {
65+
$longitude = (float) $longitude;
66+
}
5967
}
6068
if ( is_float( $longitude ) ) {
6169
if ( $longitude < - 180.0 || $longitude > 180.0 ) {

0 commit comments

Comments
 (0)