Skip to content

🐛 Fix to handle utf8 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
if (false === $indent) {
$currentIndent = 0;
} else {
$currentIndent = strlen($tokens[$indent]['content']);
$currentIndent = mb_strlen($tokens[$indent]['content']);
}

// Check the closing bracket is on a new line.
Expand Down Expand Up @@ -462,7 +462,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
);
}

$indexLength = strlen($currentEntry['index_content']);
$indexLength = mb_strlen($currentEntry['index_content']);
if ($maxLength < $indexLength) {
$maxLength = $indexLength;
}
Expand Down Expand Up @@ -652,9 +652,9 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
}

if ($tokens[$index['arrow']]['column'] !== $arrowStart) {
$expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column']));
$expected = ($arrowStart - (mb_strlen($index['index_content']) + $tokens[$index['index']]['column']));
$found = $tokens[$index['arrow']]['column']
- (strlen($index['index_content']) + $tokens[$index['index']]['column']);
- (mb_strlen($index['index_content']) + $tokens[$index['index']]['column']);

if ($found < 0) {
$found = 'newline';
Expand Down
27 changes: 27 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,32 @@ class TestClass
),
'short_name' => 'big'
);

$utf8 = array(
'/[áàâãªäå]/u' => 'a',
'/[ÁÀÂÃÄÅ]/u' => 'A',
'/[ÍÌÎÏ]/u' => 'I',
'/[íìîï]/u' => 'i',
'/[éèêë]/u' => 'e',
'/[ÉÈÊË]/u' => 'E',
'/[óòôõºöø]/u' => 'o',
'/[ÓÒÔÕÖØ]/u' => 'O',
'/ÿ/' => 'y',
'/Ÿ/' => 'Y',
'/æ/' => 'ae',
'/Æ/' => 'AE',
'/œ/' => 'oe',
'/Œ/' => 'OE',
'/[úùûü]/u' => 'u',
'/[ÚÙÛÜ]/u' => 'U',
'/ç/' => 'c',
'/Ç/' => 'C',
'/ñ/' => 'n',
'/Ñ/' => 'N',
'/–/' => '-',
'/[’‘‹›‚]/u' => ' ',
'/[“”«»„]/u' => ' ',
'/ +/' => ' ',
);
}
}
27 changes: 27 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,32 @@ class TestClass
),
'short_name' => 'big',
);

$utf8 = array(
'/[áàâãªäå]/u' => 'a',
'/[ÁÀÂÃÄÅ]/u' => 'A',
'/[ÍÌÎÏ]/u' => 'I',
'/[íìîï]/u' => 'i',
'/[éèêë]/u' => 'e',
'/[ÉÈÊË]/u' => 'E',
'/[óòôõºöø]/u' => 'o',
'/[ÓÒÔÕÖØ]/u' => 'O',
'/ÿ/' => 'y',
'/Ÿ/' => 'Y',
'/æ/' => 'ae',
'/Æ/' => 'AE',
'/œ/' => 'oe',
'/Œ/' => 'OE',
'/[úùûü]/u' => 'u',
'/[ÚÙÛÜ]/u' => 'U',
'/ç/' => 'c',
'/Ç/' => 'C',
'/ñ/' => 'n',
'/Ñ/' => 'N',
'/–/' => '-',
'/[’‘‹›‚]/u' => ' ',
'/[“”«»„]/u' => ' ',
'/ +/' => ' ',
);
}
}
3 changes: 3 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
composer.url = http://getcomposer.org/composer.phar
composer.path = ${basedir}/composer.phar

# Php Unit
phpunit.bin = ${basedir}/vendor/bin/phpunit

# PHP Code Sniffer
## Paths
phpcs.bin = ${basedir}/vendor/bin/phpcs
Expand Down
7 changes: 4 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<target name="test" depends="vendor,lint,phpunit,phpcs"/>

<target name="vendor" depends="composer" description="Load composer repositories">
<exec executable="composer" failonerror="true">
<arg value="install"/>
<exec executable="/bin/bash" failonerror="true">
<arg value="-c" />
<arg value="php composer.phar install"/>
</exec>
</target>

Expand All @@ -27,7 +28,7 @@
</target>

<target name="phpunit" depends="symlink-cs" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true" >
<exec executable="${phpunit.bin}" failonerror="true" >
<arg value="--verbose"/>
<arg value="--group=SymfonyCustom"/>
<arg value="${phpcs.dir}/tests/AllTests.php"/>
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
],
"require": {
"squizlabs/php_codesniffer": "3.0.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
}
}
Loading