jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/354468 )
Change subject: Add phpcs and make pass ...................................................................... Add phpcs and make pass Change-Id: I5742dc6f0746bb624e7623608de45967a8602c4b --- M Josa.class.php M Josa.i18n.magic.php M composer.json A phpcs.xml 4 files changed, 60 insertions(+), 41 deletions(-) Approvals: Umherirrender: Looks good to me, approved Hashar: Looks good to me, approved jenkins-bot: Verified diff --git a/Josa.class.php b/Josa.class.php index d97e977..8154398 100644 --- a/Josa.class.php +++ b/Josa.class.php @@ -1,21 +1,21 @@ <?php /** - * Extension:Josa - * Author: JuneHyeon Bae <[email protected]> - * Original implementation by Park Shinjo <[email protected]> - * License: MIT License -*/ + * Extension:Josa + * Author: JuneHyeon Bae <[email protected]> + * Original implementation by Park Shinjo <[email protected]> + * License: MIT License + */ class Josa { - private static $josaMap = array( - 'Eul/Ruel' => array( '을', '를', '을(를)' ), # 곶감을 / 사과를 - 'Eun/Neun' => array( '은', '는', '은(는)' ), # 곶감은 / 사과는 - 'E/Ga' => array( '이', '가', '이(가)' ), # 곶감이 / 사과가 - 'Gwa/Wa' => array( '과', '와', '과(와)' ), # 곶감과 / 사과와 - 'A/Ya' => array( '아', '야', '아(야)' ), # 태준아 / 철수야 - 'Euro/Ro' => array( '으로', '로', '(으)로' ), # 집으로 / 학교로 - 'E/' => array( '이', '', '(이)' ), # 태준이가 / 철수가 - ); + private static $josaMap = [ + 'Eul/Ruel' => [ '을', '를', '을(를)' ], // 곶감을 / 사과를 + 'Eun/Neun' => [ '은', '는', '은(는)' ], // 곶감은 / 사과는 + 'E/Ga' => [ '이', '가', '이(가)' ], // 곶감이 / 사과가 + 'Gwa/Wa' => [ '과', '와', '과(와)' ], // 곶감과 / 사과와 + 'A/Ya' => [ '아', '야', '아(야)' ], // 태준아 / 철수야 + 'Euro/Ro' => [ '으로', '로', '(으)로' ], // 집으로 / 학교로 + 'E/' => [ '이', '', '(이)' ], // 태준이가 / 철수가 + ]; /** * @param Parser $parser @@ -46,13 +46,18 @@ } $code = self::convertToJohabCode( mb_substr( $str, -1, 1, 'utf-8' ) ); if ( !$code ) { - $idx = 2; # Not hangul + // Not hangul + $idx = 2; } elseif ( ( $code - 0xAC00 ) % 28 === 0 ) { - $idx = 1; # No trailing consonant + // No trailing consonant + $idx = 1; } elseif ( ( $type === 'Euro/Ro' ) && ( ( $code - 0xAC00 ) % 28 === 8 ) ) { - $idx = 1; # $type is Euro/Ro and trailing consonant is rieul(ㄹ). This is an exception on Korean postposition rules. + // $type is Euro/Ro and trailing consonant is rieul(ㄹ). + // This is an exception on Korean postposition rules. + $idx = 1; } else { - $idx = 0; # Trailing consonant exists + // Trailing consonant exists + $idx = 0; } return self::$josaMap[$type][$idx]; } @@ -60,12 +65,14 @@ /* * @param string $str String to convert * @return int Converted Johab code + * @codingStandardsIgnoreStart * see https://ko.wikipedia.org/wiki/%ED%95%9C%EA%B8%80_%EC%83%81%EC%9A%A9_%EC%A1%B0%ED%95%A9%ED%98%95_%EC%9D%B8%EC%BD%94%EB%94%A9 + * @codingStandardsIgnoreEnd */ private static function convertToJohabCode( $str ) { - $values = array(); + $values = []; $lookingFor = 1; - for ( $i = 0; $i < strlen( $str ); $i++ ) { + for ( $i = 0, $len = strlen( $str ); $i < $len; $i++ ) { $thisValue = ord( $str[ $i ] ); if ( $thisValue < 128 ) { return false; diff --git a/Josa.i18n.magic.php b/Josa.i18n.magic.php index 9b7421e..b23bc11 100644 --- a/Josa.i18n.magic.php +++ b/Josa.i18n.magic.php @@ -1,22 +1,22 @@ <?php -$magicWords = array(); +$magicWords = []; -$magicWords['en'] = array( - 'Eul/Ruel' => array ( 0, 'EulRuel' ), - 'Eun/Neun' => array( 0, 'EunNeun' ), - 'E/Ga' => array( 0, 'EGa' ), - 'Gwa/Wa' => array( 0, 'GwaWa' ), - 'A/Ya' => array( 0, 'AYa' ), - 'Euro/Ro' => array( 0, 'Euro' ), - 'E/' => array( 0, 'E' ), -); +$magicWords['en'] = [ + 'Eul/Ruel' => [ 0, 'EulRuel' ], + 'Eun/Neun' => [ 0, 'EunNeun' ], + 'E/Ga' => [ 0, 'EGa' ], + 'Gwa/Wa' => [ 0, 'GwaWa' ], + 'A/Ya' => [ 0, 'AYa' ], + 'Euro/Ro' => [ 0, 'Euro' ], + 'E/' => [ 0, 'E' ], +]; -$magicWords['ko'] = array( - 'Eul/Ruel' => array ( 0, '을를' ), - 'Eun/Neun' => array( 0, '은는' ), - 'E/Ga' => array( 0, '이가' ), - 'Gwa/Wa' => array( 0, '과와' ), - 'A/Ya' => array( 0, '아야' ), - 'Euro/Ro' => array( 0, '으로' ), - 'E/' => array( 0, '이' ), -); +$magicWords['ko'] = [ + 'Eul/Ruel' => [ 0, '을를' ], + 'Eun/Neun' => [ 0, '은는' ], + 'E/Ga' => [ 0, '이가' ], + 'Gwa/Wa' => [ 0, '과와' ], + 'A/Ya' => [ 0, '아야' ], + 'Euro/Ro' => [ 0, '으로' ], + 'E/' => [ 0, '이' ], +]; diff --git a/composer.json b/composer.json index 686b65b..b8f68fb 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,14 @@ { "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", - "jakub-onderka/php-console-highlighter": "0.3.2" + "jakub-onderka/php-console-highlighter": "0.3.2", + "mediawiki/mediawiki-codesniffer": "0.7.2" }, "scripts": { + "fix": "phpcbf", "test": [ - "parallel-lint . --exclude vendor" + "parallel-lint . --exclude vendor", + "phpcs -p -s" ] } } diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..ede6c5d --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ruleset> + <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/> + <file>.</file> + <arg name="extensions" value="php,php5,inc"/> + <arg name="encoding" value="utf8"/> + <exclude-pattern>vendor</exclude-pattern> + <exclude-pattern>node_modules</exclude-pattern> +</ruleset> -- To view, visit https://gerrit.wikimedia.org/r/354468 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5742dc6f0746bb624e7623608de45967a8602c4b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Josa Gerrit-Branch: master Gerrit-Owner: Umherirrender <[email protected]> Gerrit-Reviewer: Hashar <[email protected]> Gerrit-Reviewer: Umherirrender <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
