-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closes #6306 - Console\RouteNotFoundStrategy invalid index #6307
Conversation
Solves an issue where the consoles RouteNotFoundStrategy would throw an exception because an arrays index 0 isn't defined.
@@ -378,7 +378,7 @@ protected function renderTable($data, $cols, $consoleWidth) | |||
// If there is only 1 column, just concatenate it | |||
if ($cols == 1) { | |||
foreach ($data as $row) { | |||
$result .= $row[0] . "\n"; | |||
$result .= isset($row[0]) ? $row[0] . "\n" : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for the else, an if statement already does the trick:
if (isset($row[0])) {
$result .= $row[0] . "\n";
}
Still needs a test case. |
Sorry for the delay, there isn't a test class for RouteNotFoundStrategy yet, should I create a complete new testclass? |
Tests have been added, not sure why php 5.3 fails? |
$reflection = new ReflectionClass('Zend\Mvc\View\Console\RouteNotFoundStrategy'); | ||
$method = $reflection->getMethod('renderTable'); | ||
$method->setAccessible(true); | ||
$method->invokeArgs($this->strategy, [[[]], 1, 0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
short array syntax is available since PHP 5.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's why tests fail, thanks, I'll fix that!
Please merge this, it is so annoying :) |
@@ -0,0 +1,37 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the ZF2 licence header:
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my bad, sorry!
|
||
public function setUp() | ||
{ | ||
$this->strategy = new RouteNotFoundStrategy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cs (spaces)
Assigning to @DASPRiD |
Closes #6306 - Console\RouteNotFoundStrategy invalid index
- Added an assertion to the test, and verified that it failed before the change. - Modified the foreach loop to continue if the test fails (do work outside of conditions/return early).
Solves an issue where the consoles RouteNotFoundStrategy would throw an exception because an arrays index 0 isn't defined.