Skip to content
Browse files

Updated consumers after API changes

  • Loading branch information...
1 parent 0eb46d6 commit 772156375bc721269e8f9e2021125046adf8413e @marc-mabe committed Dec 31, 2012
View
2 library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php
@@ -407,7 +407,7 @@ protected function renderTable($data, $cols, $consoleWidth)
for ($x = 1; $x <= $cols; $x += 1) {
$maxW[$x] = 0;
foreach ($data as $row) {
- $maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1],'UTF-8') + $padding * 2);
+ $maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1]) + $padding * 2);
}
}
View
3 library/Zend/ProgressBar/Adapter/Console.php
@@ -443,8 +443,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
substr($text, 0, $this->textWidth),
$this->textWidth,
' ',
- \STR_PAD_RIGHT,
- $this->charset
+ \STR_PAD_RIGHT
);
break;
}
View
2 library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php
@@ -72,7 +72,7 @@ public function __construct($encoding, $convertEncoding = null)
* @param string|null $convertEncoding The character encoding to convert to
* @return StringWrapperInterface
*/
- public function setEncoding($encoding, $convertEncoding)
+ public function setEncoding($encoding, $convertEncoding = null)
{
$supportedEncodings = static::getSupportedEncodings();
View
9 library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php
@@ -42,6 +42,15 @@ public static function getSupportedEncodings();
public function __construct($encoding, $convertEncoding = null);
/**
+ * Set character encoding working with and convert to
+ *
+ * @param string $encoding The character encoding to work with
+ * @param string|null $convertEncoding The character encoding to convert to
+ * @return StringWrapperInterface
+ */
+ public function setEncoding($encoding, $convertEncoding = null);
+
+ /**
* Returns the length of the given string
*
* @param string $str
View
12 library/Zend/Text/Figlet/Figlet.php
@@ -415,14 +415,16 @@ public function render($text, $encoding = 'UTF-8')
}
// Get the string wrapper supporting UTF-8 character encoding and the input encoding
- $strWrapper = StringUtils::getWrapper('UTF-8', $encoding);
+ $strWrapper = StringUtils::getWrapper($encoding, 'UTF-8');
// Convert $text to UTF-8 and check encoding
- $text = $strWrapper->convert($text, 'UTF-8', $encoding);
+ $text = $strWrapper->convert($text);
if (!StringUtils::isValidUtf8($text)) {
throw new Exception\UnexpectedValueException('$text is not encoded with ' . $encoding);
}
+ $strWrapper = StringUtils::getWrapper('UTF-8');
+
$this->output = '';
$this->outputLine = array();
@@ -433,14 +435,14 @@ public function render($text, $encoding = 'UTF-8')
$wordBreakMode = 0;
$lastCharWasEol = false;
- $textLength = $strWrapper->strlen($text, 'UTF-8');
+ $textLength = $strWrapper->strlen($text);
for ($charNum = 0; $charNum < $textLength; $charNum++) {
// Handle paragraphs
- $char = $strWrapper->substr($text, $charNum, 1, 'UTF-8');
+ $char = $strWrapper->substr($text, $charNum, 1);
if ($char === "\n" && $this->handleParagraphs && !$lastCharWasEol) {
- $nextChar = $strWrapper->substr($text, ($charNum + 1), 1, 'UTF-8');
+ $nextChar = $strWrapper->substr($text, ($charNum + 1), 1);
if (!$nextChar) {
$nextChar = null;
}
View
4 library/Zend/Text/MultiByte.php
@@ -40,7 +40,7 @@ public static function wordWrap($string, $width = 75, $break = "\n", $cut = fals
), E_USER_DEPRECATED);
try {
- return StringUtils::getWrapper($charset)->wordWrap($string, $width, $break, $cut, $charset);
+ return StringUtils::getWrapper($charset)->wordWrap($string, $width, $break, $cut);
} catch (\Zend\Stdlib\Exception\InvalidArgumentException $e) {
throw new Exception\InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
@@ -63,6 +63,6 @@ public static function strPad($input, $padLength, $padString = ' ', $padType = \
'Zend\Stdlib\StringUtils::getWrapper(<charset>)->strPad'
), E_USER_DEPRECATED);
- return StringUtils::getWrapper($charset)->strPad($input, $padLength, $padString, $padType, $charset);
+ return StringUtils::getWrapper($charset)->strPad($input, $padLength, $padString, $padType);
}
}
View
8 library/Zend/Text/Table/Column.php
@@ -109,7 +109,7 @@ public function setContent($content, $charset = null)
if (PHP_OS !== 'AIX') {
// AIX does not understand these character sets
$strWrapper = StringUtils::getWrapper($inputCharset, $outputCharset);
- $content = $strWrapper->convert($content, $outputCharset, $inputCharset);
+ $content = $strWrapper->convert($content);
}
}
@@ -206,12 +206,12 @@ public function render($columnWidth, $padding = 0)
$outputCharset = Table::getOutputCharset();
$strWrapper = StringUtils::getWrapper($outputCharset);
- $lines = explode("\n", $strWrapper->wordWrap($this->content, $columnWidth, "\n", true, $outputCharset));
+ $lines = explode("\n", $strWrapper->wordWrap($this->content, $columnWidth, "\n", true));
$paddedLines = array();
- foreach ($lines AS $line) {
+ foreach ($lines as $line) {
$paddedLines[] = str_repeat(' ', $padding)
- . $strWrapper->strPad($line, $columnWidth, ' ', $padMode, $outputCharset)
+ . $strWrapper->strPad($line, $columnWidth, ' ', $padMode)
. str_repeat(' ', $padding);
}
View
31 library/Zend/Validator/Barcode/Code128.php
@@ -10,6 +10,7 @@
namespace Zend\Validator\Barcode;
+use Zend\Validator\Exception;
use Zend\Stdlib\StringUtils;
use Zend\Stdlib\StringWrapper\StringWrapperInterface;
@@ -84,7 +85,7 @@ public function __construct()
public function setUtf8StringWrapper(StringWrapperInterface $utf8StringWrapper)
{
- if (!$utf8StringWrapper->isEncodingSupported('UTF-8')) {
+ if (!$utf8StringWrapper->isSupported('UTF-8')) {
throw new Exception\InvalidArgumentException(
"The string wrapper needs to support UTF-8 character encoding"
);
@@ -124,12 +125,12 @@ public function hasValidCharacters($value)
$set = $this->getCodingSet($value);
$read = $set;
if ($set != '') {
- $value = $strWrapper->substr($value, 1, null, 'UTF-8');
+ $value = $strWrapper->substr($value, 1, null);
}
// process barcode
while ($value != '') {
- $char = $strWrapper->substr($value, 0, 1, 'UTF-8');
+ $char = $strWrapper->substr($value, 0, 1);
switch ($char) {
// Function definition
@@ -185,11 +186,11 @@ public function hasValidCharacters($value)
break;
}
- $value = $strWrapper->substr($value, 1, null, 'UTF-8');
+ $value = $strWrapper->substr($value, 1, null);
$read = $set;
}
- if (($value != '') && ($strWrapper->strlen($value, 'UTF-8') != 1)) {
+ if (($value != '') && ($strWrapper->strlen($value) != 1)) {
return false;
}
@@ -210,7 +211,7 @@ protected function code128($value)
$read = $set;
$usecheck = $this->useChecksum(null);
$strWrapper = $this->getUtf8StringWrapper();
- $char = $strWrapper->substr($value, 0, 1, 'UTF-8');
+ $char = $strWrapper->substr($value, 0, 1);
if ($char == '') {
$sum = 103;
} elseif ($char == 'ˆ') {
@@ -222,11 +223,11 @@ protected function code128($value)
return false;
}
- $value = $strWrapper->substr($value, 1, null, 'UTF-8');
- while ($strWrapper->strpos($value, 'Š', 0, 'UTF-8') || ($value != '')) {
- $char = $strWrapper->substr($value, 0, 1, 'UTF-8');
+ $value = $strWrapper->substr($value, 1, null);
+ while ($strWrapper->strpos($value, 'Š') || ($value != '')) {
+ $char = $strWrapper->substr($value, 0, 1);
if ($read == 'C') {
- $char = $strWrapper->substr($value, 0, 2, 'UTF-8');
+ $char = $strWrapper->substr($value, 0, 2);
}
switch ($char) {
@@ -283,22 +284,22 @@ protected function code128($value)
break;
}
- $value = $strWrapper->substr($value, 1, null, 'UTF-8');
+ $value = $strWrapper->substr($value, 1);
++$pos;
- if (($strWrapper->strpos($value, 'Š', 0, 'UTF-8') == 1) && ($strWrapper->strlen($value, 'UTF-8') == 2)) {
+ if (($strWrapper->strpos($value, 'Š') == 1) && ($strWrapper->strlen($value) == 2)) {
// break by stop and checksum char
break;
}
$read = $set;
}
- if (($strWrapper->strpos($value, 'Š', 0, 'UTF-8') != 1) || ($strWrapper->strlen($value, 'UTF-8') != 2)) {
+ if (($strWrapper->strpos($value, 'Š') != 1) || ($strWrapper->strlen($value) != 2)) {
// return false if checksum is not readable and true if no startvalue is detected
return (!$usecheck);
}
$mod = $sum % 103;
- if ($strWrapper->substr($value, 0, 1, 'UTF-8') == $this->chr128($mod, $set)) {
+ if ($strWrapper->substr($value, 0, 1) == $this->chr128($mod, $set)) {
return true;
}
@@ -313,7 +314,7 @@ protected function code128($value)
*/
protected function getCodingSet($value)
{
- $value = $this->getUtf8StringWrapper()->substr($value, 0, 1, 'UTF-8');
+ $value = $this->getUtf8StringWrapper()->substr($value, 0, 1);
switch ($value) {
case '' :
return 'A';
View
2 library/Zend/Validator/Hostname.php
@@ -557,7 +557,7 @@ public function isValid($value)
$length = $this->idnLength[strtoupper($this->tld)];
}
- if ($utf8StrWrapper->strlen($domainPart, 'UTF-8') > $length) {
+ if ($utf8StrWrapper->strlen($domainPart) > $length) {
$this->error(self::INVALID_HOSTNAME);
} else {
$checked = true;
View
35 library/Zend/Validator/StringLength.php
@@ -11,6 +11,7 @@
namespace Zend\Validator;
use Zend\Stdlib\StringUtils;
+use Zend\Stdlib\StringWrapper\StringWrapperInterface as StringWrapper;
/**
* @category Zend
@@ -131,6 +132,31 @@ public function setMax($max)
}
/**
+ * Get the string wrapper to detect the string length
+ *
+ * @return StringWrapper
+ */
+ public function getStringWrapper()
+ {
+ if (!$this->stringWrapper) {
+ $this->stringWrapper = StringUtils::getWrapper($this->getEncoding());
+ }
+ return $this->stringWrapper;
+ }
+
+ /**
+ * Set the string wrapper to detect the string length
+ *
+ * @param StringWrapper
+ * @return StringLength
+ */
+ public function setStringWrapper(StringWrapper $stringWrapper)
+ {
+ $stringWrapper->setEncoding($this->getEncoding());
+ $this->stringWrapper = $stringWrapper;
+ }
+
+ /**
* Returns the actual encoding
*
* @return string
@@ -147,12 +173,9 @@ public function getEncoding()
* @return StringLength
* @throws Exception\InvalidArgumentException
*/
- public function setEncoding($encoding = null)
+ public function setEncoding($encoding)
{
- if ($encoding !== null) {
- StringUtils::getWrapper($encoding);
- }
-
+ $this->stringWrapper = StringUtils::getWrapper($encoding);
$this->options['encoding'] = $encoding;
return $this;
}
@@ -173,7 +196,7 @@ public function isValid($value)
$this->setValue($value);
- $length = StringUtils::getWrapper($this->getEncoding())->strlen($value, $this->getEncoding());
+ $length = $this->getStringWrapper()->strlen($value);
if ($length < $this->getMin()) {
$this->error(self::TOO_SHORT);
}

0 comments on commit 7721563

Please sign in to comment.
Something went wrong with that request. Please try again.