Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'cs/various-things' of /~https://github.com/Maks3w/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/Exception/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Zend\Text\Exception;

class OutOfBoundsException
class OutOfBoundsException
extends \OutOfBoundsException
implements ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @category Zend
* @package Zend_Text
*/
class RuntimeException
class RuntimeException
extends \RuntimeException
implements ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @category Zend
* @package Zend_Text
*/
class UnexpectedValueException
class UnexpectedValueException
extends \UnexpectedValueException
implements ExceptionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Figlet/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @category Zend
* @package Zend_Text
*/
class InvalidArgumentException
class InvalidArgumentException
extends Exception\InvalidArgumentException
implements ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Figlet/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @category Zend
* @package Zend_Text_Figlet
*/
class RuntimeException
class RuntimeException
extends Exception\RuntimeException
implements ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Figlet/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @category Zend
* @package Zend_Text_Figlet
*/
class UnexpectedValueException
class UnexpectedValueException
extends Exception\UnexpectedValueException
implements ExceptionInterface
{}
70 changes: 35 additions & 35 deletions src/Figlet/Figlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function setSmushMode($smushMode)
} else {
if ($smushMode === 0) {
$this->_userSmush = self::SM_KERN;
} else if ($smushMode === -1) {
} elseif ($smushMode === -1) {
$this->_userSmush = 0;
} else {
$this->_userSmush = (($smushMode & 63) | self::SM_SMUSH);
Expand Down Expand Up @@ -466,7 +466,7 @@ public function render($text, $encoding = 'UTF-8')
if ($wordBreakMode === -1) {
if ($char === ' ') {
break;
} else if ($char === "\n") {
} elseif ($char === "\n") {
$wordBreakMode = 0;
break;
}
Expand All @@ -477,13 +477,13 @@ public function render($text, $encoding = 'UTF-8')
if ($char === "\n") {
$this->_appendLine();
$wordBreakMode = false;
} else if ($this->_addChar($char)) {
} elseif ($this->_addChar($char)) {
if ($char !== ' ') {
$wordBreakMode = ($wordBreakMode >= 2) ? 3: 1;
} else {
$wordBreakMode = ($wordBreakMode > 0) ? 2: 0;
}
} else if ($this->_outlineLength === 0) {
} elseif ($this->_outlineLength === 0) {
for ($i = 0; $i < $this->_charHeight; $i++) {
if ($this->_rightToLeft === 1 && $this->_outputWidth > 1) {
$offset = (strlen($this->_currentChar[$i]) - $this->_outlineLengthLimit);
Expand All @@ -494,7 +494,7 @@ public function render($text, $encoding = 'UTF-8')
}

$wordBreakMode = -1;
} else if ($char === ' ') {
} elseif ($char === ' ') {
if ($wordBreakMode === 2) {
$this->_splitLine();
} else {
Expand Down Expand Up @@ -789,7 +789,7 @@ protected function _smushAmount()

if (empty($leftChar) || $leftChar === ' ') {
$amount++;
} else if (!empty($rightChar)) {
} elseif (!empty($rightChar)) {
if ($this->_smushem($leftChar, $rightChar) !== null) {
$amount++;
}
Expand Down Expand Up @@ -845,13 +845,13 @@ protected function _smushem($leftChar, $rightChar)
// This is smushing by universal overlapping
if ($leftChar === ' ') {
return $rightChar;
} else if ($rightChar === ' ') {
} elseif ($rightChar === ' ') {
return $leftChar;
} else if ($leftChar === $this->_hardBlank) {
} elseif ($leftChar === $this->_hardBlank) {
return $rightChar;
} else if ($rightChar === $this->_hardBlank) {
} elseif ($rightChar === $this->_hardBlank) {
return $rightChar;
} else if ($this->_rightToLeft === 1) {
} elseif ($this->_rightToLeft === 1) {
return $leftChar;
} else {
// Occurs in the absence of above exceptions
Expand All @@ -878,57 +878,57 @@ protected function _smushem($leftChar, $rightChar)
if (($this->_smushMode & self::SM_LOWLINE) > 0) {
if ($leftChar === '_' && strchr('|/\\[]{}()<>', $rightChar) !== false) {
return $rightChar;
} else if ($rightChar === '_' && strchr('|/\\[]{}()<>', $leftChar) !== false) {
} elseif ($rightChar === '_' && strchr('|/\\[]{}()<>', $leftChar) !== false) {
return $leftChar;
}
}

if (($this->_smushMode & self::SM_HIERARCHY) > 0) {
if ($leftChar === '|' && strchr('/\\[]{}()<>', $rightChar) !== false) {
return $rightChar;
} else if ($rightChar === '|' && strchr('/\\[]{}()<>', $leftChar) !== false) {
} elseif ($rightChar === '|' && strchr('/\\[]{}()<>', $leftChar) !== false) {
return $leftChar;
} else if (strchr('/\\', $leftChar) && strchr('[]{}()<>', $rightChar) !== false) {
} elseif (strchr('/\\', $leftChar) && strchr('[]{}()<>', $rightChar) !== false) {
return $rightChar;
} else if (strchr('/\\', $rightChar) && strchr('[]{}()<>', $leftChar) !== false) {
} elseif (strchr('/\\', $rightChar) && strchr('[]{}()<>', $leftChar) !== false) {
return $leftChar;
} else if (strchr('[]', $leftChar) && strchr('{}()<>', $rightChar) !== false) {
} elseif (strchr('[]', $leftChar) && strchr('{}()<>', $rightChar) !== false) {
return $rightChar;
} else if (strchr('[]', $rightChar) && strchr('{}()<>', $leftChar) !== false) {
} elseif (strchr('[]', $rightChar) && strchr('{}()<>', $leftChar) !== false) {
return $leftChar;
} else if (strchr('{}', $leftChar) && strchr('()<>', $rightChar) !== false) {
} elseif (strchr('{}', $leftChar) && strchr('()<>', $rightChar) !== false) {
return $rightChar;
} else if (strchr('{}', $rightChar) && strchr('()<>', $leftChar) !== false) {
} elseif (strchr('{}', $rightChar) && strchr('()<>', $leftChar) !== false) {
return $leftChar;
} else if (strchr('()', $leftChar) && strchr('<>', $rightChar) !== false) {
} elseif (strchr('()', $leftChar) && strchr('<>', $rightChar) !== false) {
return $rightChar;
} else if (strchr('()', $rightChar) && strchr('<>', $leftChar) !== false) {
} elseif (strchr('()', $rightChar) && strchr('<>', $leftChar) !== false) {
return $leftChar;
}
}

if (($this->_smushMode & self::SM_PAIR) > 0) {
if ($leftChar === '[' && $rightChar === ']') {
return '|';
} else if ($rightChar === '[' && $leftChar === ']') {
} elseif ($rightChar === '[' && $leftChar === ']') {
return '|';
} else if ($leftChar === '{' && $rightChar === '}') {
} elseif ($leftChar === '{' && $rightChar === '}') {
return '|';
} else if ($rightChar === '{' && $leftChar === '}') {
} elseif ($rightChar === '{' && $leftChar === '}') {
return '|';
} else if ($leftChar === '(' && $rightChar === ')') {
} elseif ($leftChar === '(' && $rightChar === ')') {
return '|';
} else if ($rightChar === '(' && $leftChar === ')') {
} elseif ($rightChar === '(' && $leftChar === ')') {
return '|';
}
}

if (($this->_smushMode & self::SM_BIGX) > 0) {
if ($leftChar === '/' && $rightChar === '\\') {
return '|';
} else if ($rightChar === '/' && $leftChar === '\\') {
} elseif ($rightChar === '/' && $leftChar === '\\') {
return 'Y';
} else if ($leftChar === '>' && $rightChar === '<') {
} elseif ($leftChar === '>' && $rightChar === '<') {
return 'X';
}
}
Expand Down Expand Up @@ -1004,7 +1004,7 @@ protected function _loadFont($fontFile)
if ($numsRead < 7) {
if ($smush === 2) {
$this->_fontSmush = self::SM_KERN;
} else if ($smush < 0) {
} elseif ($smush < 0) {
$this->_fontSmush = 0;
} else {
$this->_fontSmush = (($smush & 31) | self::SM_SMUSH);
Expand Down Expand Up @@ -1067,7 +1067,7 @@ protected function _loadFont($fontFile)
// Convert it if required
if (substr($uniCode, 0, 2) === '0x') {
$uniCode = hexdec(substr($uniCode, 2));
} else if (substr($uniCode, 0, 1) === '0' and
} elseif (substr($uniCode, 0, 1) === '0' and
$uniCode !== '0' or
substr($uniCode, 0, 2) === '-0') {
$uniCode = octdec($uniCode);
Expand Down Expand Up @@ -1101,9 +1101,9 @@ protected function _setUsedSmush()
{
if ($this->_smushOverride === self::SMO_NO) {
$this->_smushMode = $this->_fontSmush;
} else if ($this->_smushOverride === self::SMO_YES) {
} elseif ($this->_smushOverride === self::SMO_YES) {
$this->_smushMode = $this->_userSmush;
} else if ($this->_smushOverride === self::SMO_FORCE) {
} elseif ($this->_smushOverride === self::SMO_FORCE) {
$this->_smushMode = ($this->_fontSmush | $this->_userSmush);
}
}
Expand Down Expand Up @@ -1192,13 +1192,13 @@ protected function _uniOrd($c)

if ($h <= 0x7F) {
$ord = $h;
} else if ($h < 0xC2) {
} elseif ($h < 0xC2) {
$ord = 0;
} else if ($h <= 0xDF) {
} elseif ($h <= 0xDF) {
$ord = (($h & 0x1F) << 6 | (ord($c[1]) & 0x3F));
} else if ($h <= 0xEF) {
} elseif ($h <= 0xEF) {
$ord = (($h & 0x0F) << 12 | (ord($c[1]) & 0x3F) << 6 | (ord($c[2]) & 0x3F));
} else if ($h <= 0xF4) {
} elseif ($h <= 0xF4) {
$ord = (($h & 0x0F) << 18 | (ord($c[1]) & 0x3F) << 12 |
(ord($c[2]) & 0x3F) << 6 | (ord($c[3]) & 0x3F));
} else {
Expand Down
24 changes: 12 additions & 12 deletions src/MultiByte.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,61 +35,61 @@ public static function wordWrap($string, $width = 75, $break = "\n", $cut = fals

if (strlen($string) === 0) {
return '';
}
}

if ($breakWidth === null) {
throw new Exception\InvalidArgumentException('Break string cannot be empty');
}
}

if ($width === 0 && $cut) {
throw new Exception\InvalidArgumentException('Cannot force cut when width is zero');
}

$result = '';
$lastStart = $lastSpace = 0;

for ($current = 0; $current < $stringWidth; $current++) {
$char = iconv_substr($string, $current, 1, $charset);

$possibleBreak = $char;
if ($breakWidth !== 1) {
$possibleBreak = iconv_substr($string, $current, $breakWidth, $charset);
}

if ($possibleBreak === $break) {
$result .= iconv_substr($string, $lastStart, $current - $lastStart + $breakWidth, $charset);
$current += $breakWidth - 1;
$lastStart = $lastSpace = $current + 1;
continue;
}
}

if ($char === ' ') {
if ($current - $lastStart >= $width) {
$result .= iconv_substr($string, $lastStart, $current - $lastStart, $charset) . $break;
$lastStart = $current + 1;
}

$lastSpace = $current;
continue;
}
}

if ($current - $lastStart >= $width && $cut && $lastStart >= $lastSpace) {
$result .= iconv_substr($string, $lastStart, $current - $lastStart, $charset) . $break;
$lastStart = $lastSpace = $current;
continue;
}
}

if ($current - $lastStart >= $width && $lastStart < $lastSpace) {
$result .= iconv_substr($string, $lastStart, $lastSpace - $lastStart, $charset) . $break;
$lastStart = $lastSpace = $lastSpace + 1;
continue;
}
}

if ($lastStart !== $current) {
$result .= iconv_substr($string, $lastStart, $current - $lastStart, $charset);
}

return $result;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Table/Decorator/Unicode.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ protected function _uniChar($code)
{
if ($code <= 0x7F) {
$char = chr($code);
} else if ($code <= 0x7FF) {
} elseif ($code <= 0x7FF) {
$char = chr(0xC0 | $code >> 6)
. chr(0x80 | $code & 0x3F);
} else if ($code <= 0xFFFF) {
} elseif ($code <= 0xFFFF) {
$char = chr(0xE0 | $code >> 12)
. chr(0x80 | $code >> 6 & 0x3F)
. chr(0x80 | $code & 0x3F);
} else if ($code <= 0x10FFFF) {
} elseif ($code <= 0x10FFFF) {
$char = chr(0xF0 | $code >> 18)
. chr(0x80 | $code >> 12 & 0x3F)
. chr(0x80 | $code >> 6 & 0x3F)
Expand Down
2 changes: 1 addition & 1 deletion src/Table/Exception/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Zend\Text\Exception;

class OutOfBoundsException
class OutOfBoundsException
extends Exception\OutOfBoundsException
implements ExceptionInterface
{}
4 changes: 2 additions & 2 deletions src/Table/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ public function render()
// Else check if we have to draw the row separator
if ($this->_autoSeparate & self::AUTO_SEPARATE_ALL) {
$drawSeparator = true;
} else if ($rowNum === 1 && $this->_autoSeparate & self::AUTO_SEPARATE_HEADER) {
} elseif ($rowNum === 1 && $this->_autoSeparate & self::AUTO_SEPARATE_HEADER) {
$drawSeparator = true;
} else if ($rowNum === ($numRows - 1) && $this->_autoSeparate & self::AUTO_SEPARATE_FOOTER) {
} elseif ($rowNum === ($numRows - 1) && $this->_autoSeparate & self::AUTO_SEPARATE_FOOTER) {
$drawSeparator = true;
} else {
$drawSeparator = false;
Expand Down
2 changes: 1 addition & 1 deletion test/FigletTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testNonExistentFont()
{
$this->setExpectedException('Zend\Text\Figlet\Exception\RuntimeException', 'not found');
$figlet = new Figlet\Figlet(array('font' => __DIR__ . '/Figlet/NonExistentFont.flf'));

}

public function testInvalidFont()
Expand Down
2 changes: 1 addition & 1 deletion test/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function testColumnSetColSpanInvalidArgument()
public function testColumnRenderInvalidArgument()
{
$column = new Table\Column();

$this->setExpectedException('Zend\Text\Table\Exception\InvalidArgumentException', 'must be an integer and greater than 0');
$column->render(0);
}
Expand Down

0 comments on commit cfec87c

Please sign in to comment.