From 1ce3accf4d9f711436200740a3662d4c882e5612 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Tue, 10 Apr 2018 15:44:11 -0700 Subject: [PATCH] Fix variable name for integer keyed arrays --- Debugger/src/Agent.php | 2 +- Debugger/src/VariableTable.php | 2 +- Debugger/tests/Unit/VariableTableTest.php | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Debugger/src/Agent.php b/Debugger/src/Agent.php index e025c7378100..a849b2606c32 100644 --- a/Debugger/src/Agent.php +++ b/Debugger/src/Agent.php @@ -21,7 +21,7 @@ use Google\Cloud\Core\Batch\BatchRunner; use Google\Cloud\Core\Batch\BatchTrait; use Google\Cloud\Core\ExponentialBackoff; -use Google\Cloud\Core\Exceptions\ServiceException; +use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Core\SysvTrait; use Google\Cloud\Debugger\BreakpointStorage\BreakpointStorageInterface; use Google\Cloud\Debugger\BreakpointStorage\FileBreakpointStorage; diff --git a/Debugger/src/VariableTable.php b/Debugger/src/VariableTable.php index 26a8a09de811..29659fc7e0f2 100644 --- a/Debugger/src/VariableTable.php +++ b/Debugger/src/VariableTable.php @@ -160,7 +160,7 @@ private function doRegisterMembers($array, $depth) $members = []; if ($depth < self::MAX_MEMBER_DEPTH) { foreach ($array as $key => $member) { - $members[] = $this->doRegister($key, $member, $depth + 1, null); + $members[] = $this->doRegister((string) $key, $member, $depth + 1, null); } } return $members; diff --git a/Debugger/tests/Unit/VariableTableTest.php b/Debugger/tests/Unit/VariableTableTest.php index b828671c500a..74706f6c4fa5 100644 --- a/Debugger/tests/Unit/VariableTableTest.php +++ b/Debugger/tests/Unit/VariableTableTest.php @@ -170,4 +170,15 @@ public function testRegisterSameStrings() $this->assertCount(1, $variableTable->variables()); } + + public function testRegistersArrayMembers() + { + $variableTable = new VariableTable(); + $variable = $variableTable->register('array', [1, 2, 3]); + $data = json_decode(json_encode($variable), true); + $this->assertCount(3, $data['members']); + foreach ($data['members'] as $member) { + $this->assertInternalType('string', $member['name']); + } + } }