From beb39903ff791437711e9272adbac185c9bd689b Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 12 Jul 2012 21:11:36 +0200 Subject: [PATCH] [PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed --- src/Exception/OutOfBoundsException.php | 2 +- src/Exception/RuntimeException.php | 2 +- src/Exception/UnexpectedValueException.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- src/Figlet/Exception/RuntimeException.php | 2 +- .../Exception/UnexpectedValueException.php | 2 +- src/Figlet/Figlet.php | 70 +++++++++---------- src/MultiByte.php | 24 +++---- src/Table/Decorator/Unicode.php | 6 +- src/Table/Exception/OutOfBoundsException.php | 2 +- src/Table/Table.php | 4 +- test/FigletTest.php | 2 +- test/TableTest.php | 2 +- 13 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Exception/OutOfBoundsException.php b/src/Exception/OutOfBoundsException.php index 2d25910..2256e6e 100644 --- a/src/Exception/OutOfBoundsException.php +++ b/src/Exception/OutOfBoundsException.php @@ -12,7 +12,7 @@ use Zend\Text\Exception; -class OutOfBoundsException +class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface {} diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 3d47c0e..f061cf2 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -14,7 +14,7 @@ * @category Zend * @package Zend_Text */ -class RuntimeException +class RuntimeException extends \RuntimeException implements ExceptionInterface {} diff --git a/src/Exception/UnexpectedValueException.php b/src/Exception/UnexpectedValueException.php index 1dbbc3f..07b6916 100644 --- a/src/Exception/UnexpectedValueException.php +++ b/src/Exception/UnexpectedValueException.php @@ -14,7 +14,7 @@ * @category Zend * @package Zend_Text */ -class UnexpectedValueException +class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface { diff --git a/src/Figlet/Exception/InvalidArgumentException.php b/src/Figlet/Exception/InvalidArgumentException.php index 4de6004..73533b6 100644 --- a/src/Figlet/Exception/InvalidArgumentException.php +++ b/src/Figlet/Exception/InvalidArgumentException.php @@ -18,7 +18,7 @@ * @category Zend * @package Zend_Text */ -class InvalidArgumentException +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface {} diff --git a/src/Figlet/Exception/RuntimeException.php b/src/Figlet/Exception/RuntimeException.php index d705d3b..655f340 100644 --- a/src/Figlet/Exception/RuntimeException.php +++ b/src/Figlet/Exception/RuntimeException.php @@ -18,7 +18,7 @@ * @category Zend * @package Zend_Text_Figlet */ -class RuntimeException +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface {} diff --git a/src/Figlet/Exception/UnexpectedValueException.php b/src/Figlet/Exception/UnexpectedValueException.php index f3cb28c..58a9976 100644 --- a/src/Figlet/Exception/UnexpectedValueException.php +++ b/src/Figlet/Exception/UnexpectedValueException.php @@ -18,7 +18,7 @@ * @category Zend * @package Zend_Text_Figlet */ -class UnexpectedValueException +class UnexpectedValueException extends Exception\UnexpectedValueException implements ExceptionInterface {} diff --git a/src/Figlet/Figlet.php b/src/Figlet/Figlet.php index 1eee7e4..ba3c597 100644 --- a/src/Figlet/Figlet.php +++ b/src/Figlet/Figlet.php @@ -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); @@ -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; } @@ -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); @@ -494,7 +494,7 @@ public function render($text, $encoding = 'UTF-8') } $wordBreakMode = -1; - } else if ($char === ' ') { + } elseif ($char === ' ') { if ($wordBreakMode === 2) { $this->_splitLine(); } else { @@ -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++; } @@ -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 @@ -878,7 +878,7 @@ 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; } } @@ -886,23 +886,23 @@ protected function _smushem($leftChar, $rightChar) 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; } } @@ -910,15 +910,15 @@ protected function _smushem($leftChar, $rightChar) 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 '|'; } } @@ -926,9 +926,9 @@ protected function _smushem($leftChar, $rightChar) 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'; } } @@ -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); @@ -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); @@ -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); } } @@ -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 { diff --git a/src/MultiByte.php b/src/MultiByte.php index 5bcf8d4..37cdc7f 100644 --- a/src/MultiByte.php +++ b/src/MultiByte.php @@ -35,49 +35,49 @@ 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; @@ -85,11 +85,11 @@ public static function wordWrap($string, $width = 75, $break = "\n", $cut = fals continue; } } - + if ($lastStart !== $current) { $result .= iconv_substr($string, $lastStart, $current - $lastStart, $charset); } - + return $result; } diff --git a/src/Table/Decorator/Unicode.php b/src/Table/Decorator/Unicode.php index c1a4b06..01387ac 100644 --- a/src/Table/Decorator/Unicode.php +++ b/src/Table/Decorator/Unicode.php @@ -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) diff --git a/src/Table/Exception/OutOfBoundsException.php b/src/Table/Exception/OutOfBoundsException.php index 4b83858..9ac339b 100644 --- a/src/Table/Exception/OutOfBoundsException.php +++ b/src/Table/Exception/OutOfBoundsException.php @@ -12,7 +12,7 @@ use Zend\Text\Exception; -class OutOfBoundsException +class OutOfBoundsException extends Exception\OutOfBoundsException implements ExceptionInterface {} diff --git a/src/Table/Table.php b/src/Table/Table.php index 933c344..6c3734f 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -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; diff --git a/test/FigletTest.php b/test/FigletTest.php index 9af120b..4c9f33f 100644 --- a/test/FigletTest.php +++ b/test/FigletTest.php @@ -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() diff --git a/test/TableTest.php b/test/TableTest.php index be01189..b309180 100644 --- a/test/TableTest.php +++ b/test/TableTest.php @@ -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); }