Skip to content

Commit 6a5fad0

Browse files
committedJan 2, 2015
Replaced non multi byte string function calls by
their mbstring equivalents
1 parent 8317feb commit 6a5fad0

16 files changed

+24
-24
lines changed
 

‎src/CLIOptions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ private function parse() {
160160
foreach($argv as $arg) {
161161
if ($arg[0] == '-') {
162162
if ($arg[1] == '-') {
163-
$argName = substr($arg, 2);
163+
$argName = mb_substr($arg, 2);
164164
if (!in_array($argName, $options)) {
165165
throw new CLIOptionsException(
166166
sprintf('Option "%s" is not defined', $argName)
167167
);
168168
}
169169
} else {
170-
$argChar = substr($arg, 1);
170+
$argChar = mb_substr($arg, 1);
171171
if (!isset($shortMap[$argChar])) {
172172
throw new CLIOptionsException(
173173
sprintf('Option "%s" is not defined', $argChar)

‎src/collector/project/AbstractVariableObject.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function setDefault($value) {
110110
* @param $type
111111
*/
112112
public function setType($type) {
113-
if (!in_array(strtolower($type), $this->types)) {
113+
if (!in_array(mb_strtolower($type), $this->types)) {
114114
$parts = explode('\\', $type);
115115
$local = array_pop($parts);
116116
$namespace = join('\\', $parts);

‎src/collector/project/IndexCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function addTrait(TraitObject $trait) {
120120
* @return \DOMNodeList
121121
*/
122122
public function findUnitNodesBySrcFile($path) {
123-
$src = substr($path, strlen($this->srcDir) + 1);
123+
$src = mb_substr($path, mb_strlen($this->srcDir) + 1);
124124
return $this->getRootElement()->query(sprintf('//*[@src="%s"]', $src));
125125
}
126126

‎src/collector/project/InlineComment.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ private function parse(array $comments) {
4747
foreach($comments as $pos => $comment) {
4848
preg_match('=^@{0,1}(todo|var|fixme):{0,1}(.*)=i', $comment, $matches);
4949
if (count($matches) != 0) {
50-
switch(strtolower($matches[1])) {
50+
switch(mb_strtolower($matches[1])) {
5151
case 'var': {
5252
// we ignore @var comments as they are IDE support only
5353
continue;
5454
}
5555
case 'fixme':
5656
case 'todo': {
5757
$node = $this->fragment->appendChild(
58-
$this->fragment->ownerDocument->createElementNS(self::XMLNS, strtolower($matches[1]))
58+
$this->fragment->ownerDocument->createElementNS(self::XMLNS, mb_strtolower($matches[1]))
5959
);
6060
$node->setAttribute('value', trim($matches[2]));
6161
break;

‎src/docblock/Factory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function getInstanceByMap($map, $name, $annotation = null) {
131131
*/
132132
protected function verifyType($item, $type = 'string') {
133133
$match = true;
134-
switch (strtolower($type)) {
134+
switch (mb_strtolower($type)) {
135135
case 'string': {
136136
if (!is_string($item)) {
137137
$match = false;

‎src/docblock/InlineProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function processMatch($match) {
8585
return $this->dom->createTextNode('{');
8686
}
8787
$parts = preg_split("/[\s,]+/", $match, 2, PREG_SPLIT_NO_EMPTY);
88-
$annotation = substr($parts[0], 1);
88+
$annotation = mb_substr($parts[0], 1);
8989
if (preg_match('=^[a-zA-Z0-9]*$=', $annotation)) {
9090
$parser = $this->factory->getParserInstanceFor($annotation);
9191
} else {

‎src/docblock/Parser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public function parse($block, array $aliasMap) {
9292
}
9393

9494
protected function prepare($block) {
95-
$block = str_replace(array("\r\n", "\r"), "\n", substr($block, 2, -2));
95+
$block = str_replace(array("\r\n", "\r"), "\n", mb_substr($block, 2, -2));
9696
$raw = array();
9797
foreach(explode("\n", $block) as $line) {
98-
$raw[] = substr(trim($line, " \n\t"), 2) ?: '';
98+
$raw[] = mb_substr(trim($line, " \n\t"), 2) ?: '';
9999
}
100100
return $raw;
101101
}

‎src/docblock/elements/GenericElement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __call($method, $value) {
6363
throw new GenericElementException("Method '$method' not defined", GenericElementException::MethodNotDefined);
6464
}
6565
// extract attribute name (remove 'set' or 'get' from string)
66-
$attribute = strtolower(substr($method, 3));
66+
$attribute = mb_strtolower(mb_substr($method, 3));
6767
$this->attributes[$attribute] = $value[0];
6868
}
6969

@@ -72,7 +72,7 @@ public function setBody($body) {
7272
}
7373

7474
public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
75-
$node = $ctx->createElementNS('http://xml.phpdox.net/src', strtolower($this->name));
75+
$node = $ctx->createElementNS('http://xml.phpdox.net/src', mb_strtolower($this->name));
7676
foreach($this->attributes as $attribute => $value) {
7777
if ($value != '') {
7878
$node->setAttribute($attribute, $value);

‎src/docblock/elements/VarElement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
5353
$type = $node->getAttribute('type');
5454

5555
if (strpos($type, '[]')) {
56-
$type = substr($type, 0, -2);
56+
$type = mb_substr($type, 0, -2);
5757
$node->setAttribute('type', 'array');
5858
$node->setAttribute('of', $type);
5959
}

‎src/docblock/parser/DescriptionParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getObject(array $buffer) {
4545
do {
4646
$line = array_shift($buffer);
4747
$compact .= ' ' . $line;
48-
} while ($line != '' && substr($line, -1) != '.');
48+
} while ($line != '' && mb_substr($line, -1) != '.');
4949
}
5050
$obj = $this->buildObject('generic', $buffer);
5151
$obj->setCompact(trim($compact, " *\t"));
@@ -54,4 +54,4 @@ public function getObject(array $buffer) {
5454

5555
}
5656

57-
}
57+
}

‎src/generator/engine/AbstractEngine.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function saveFile($content, $filename) {
7676
}
7777

7878
protected function copyStatic($path, $dest, $recursive = true) {
79-
$len = strlen($path);
79+
$len = mb_strlen($path);
8080
if ($recursive) {
8181
$worker = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
8282
} else {
@@ -86,7 +86,7 @@ protected function copyStatic($path, $dest, $recursive = true) {
8686
if($x->isDir() && ($x->getFilename() == "." || $x->getFilename() == "..")) {
8787
continue;
8888
}
89-
$target = $dest . substr($x->getPathname(), $len);
89+
$target = $dest . mb_substr($x->getPathname(), $len);
9090
if (!file_exists(dirname($target))) {
9191
mkdir(dirname($target), 0755, true);
9292
}

‎src/generator/enricher/git/Git.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function enrichStart(PHPDoxStartEvent $event) {
6363

6464
$binary = $this->config->getGitBinary();
6565

66-
$devNull = strtolower(substr(PHP_OS, 0, 3)) == 'win' ? 'NUL' : '/dev/null';
66+
$devNull = mb_strtolower(mb_substr(PHP_OS, 0, 3)) == 'win' ? 'NUL' : '/dev/null';
6767

6868
$cwd = getcwd();
6969
chdir($this->config->getSourceDirectory());
@@ -93,7 +93,7 @@ public function enrichStart(PHPDoxStartEvent $event) {
9393
foreach($branches as $branchName) {
9494
$branch = $branchesNode->appendElementNS(self::GITNS, 'branch');
9595
if ($branchName[0] == '*') {
96-
$branchName = trim(substr($branchName, 1));
96+
$branchName = trim(mb_substr($branchName, 1));
9797
$currentBranch = $branchName;
9898
} else {
9999
$branchName = trim($branchName);

‎src/generator/enricher/phpunit/PHPUnit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function enrichEnd(PHPDoxEndEvent $event) {
5959
$container = $this->getEnrichtmentContainer($classNode, 'phpunit');
6060
$resultNode = $container->appendElementNS(self::XMLNS, 'result');
6161
foreach($results as $key => $value) {
62-
$resultNode->setAttribute(strtolower($key), $value);
62+
$resultNode->setAttribute(mb_strtolower($key), $value);
6363
}
6464
$container->appendChild(
6565
$container->ownerDocument->importNode($this->coverage[$namespace][$class])

‎src/shared/DirectoryCleaner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class DirectoryCleaner {
55

66
public function process(FileInfo $path) {
7-
if (strlen($path->getPathname()) < 5) {
7+
if (mb_strlen($path->getPathname()) < 5) {
88
throw new DirectoryCleanerException(
99
'For security reasons, path must be at least 5 chars long',
1010
DirectoryCleanerException::SecurityLimitation

‎src/shared/FileInfo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getRelative(\SplFileInfo $relation, $inclusive = TRUE) {
4040
if ($inclusive) {
4141
$relationPath = dirname($relationPath);
4242
}
43-
$relPath = substr($relPath, strlen($relationPath)+1);
43+
$relPath = mb_substr($relPath, mb_strlen($relationPath)+1);
4444
return new FileInfo($relPath);
4545
}
4646

‎tests/data/collector/test0.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ protected function writeSocket($type, Array $payload) {
333333
}
334334

335335
$str = json_encode($obj)."\n";
336-
$x = strlen($str);
337-
$rc = @fwrite($this->socket, $str, strlen($str));
336+
$x = mb_strlen($str);
337+
$rc = @fwrite($this->socket, $str, mb_strlen($str));
338338
$rc2 = @fflush($this->socket);
339339
if (!$rc || ($x != $rc)) {
340340
$this->closeSocket();

0 commit comments

Comments
 (0)
Please sign in to comment.