From 62b35909511d51b243de1fbe1967c20d31e59fb9 Mon Sep 17 00:00:00 2001 From: Jesse Ross Date: Thu, 16 May 2019 09:35:58 -0400 Subject: [PATCH 1/2] When parsing response with regex, check resulting array of matches better to avoid undefined index notices --- src/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index d43cf16..d038715 100644 --- a/src/Client.php +++ b/src/Client.php @@ -240,7 +240,7 @@ class Client implements Interfaces\ClientInterface // If we have lines after current one if (isset($response[$j])) { $this->pregResponse($response[$j], $matches); - if (!empty($matches)) { + if (isset($matches[1][0]) && isset($matches[2][0])) { $result['after'][$matches[1][0]] = $matches[2][0]; } } @@ -248,7 +248,7 @@ class Client implements Interfaces\ClientInterface break 2; default: $this->pregResponse($value, $matches); - if (!empty($matches)) { + if (isset($matches[1][0]) && isset($matches[2][0])) { $result[$i][$matches[1][0]] = $matches[2][0]; } break; From 57564e21af2c3a6a2f8c8f8c4300627ceee88850 Mon Sep 17 00:00:00 2001 From: Jesse Ross Date: Thu, 16 May 2019 12:36:23 -0400 Subject: [PATCH 2/2] Fix code style --- src/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index d038715..41090b6 100644 --- a/src/Client.php +++ b/src/Client.php @@ -240,7 +240,7 @@ class Client implements Interfaces\ClientInterface // If we have lines after current one if (isset($response[$j])) { $this->pregResponse($response[$j], $matches); - if (isset($matches[1][0]) && isset($matches[2][0])) { + if (isset($matches[1][0], $matches[2][0])) { $result['after'][$matches[1][0]] = $matches[2][0]; } } @@ -248,7 +248,7 @@ class Client implements Interfaces\ClientInterface break 2; default: $this->pregResponse($value, $matches); - if (isset($matches[1][0]) && isset($matches[2][0])) { + if (isset($matches[1][0], $matches[2][0])) { $result[$i][$matches[1][0]] = $matches[2][0]; } break;