From 540d8a237ef060d1ddd01b3a461ec17ff0271f9f Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 10 Aug 2018 15:00:30 -0400 Subject: [PATCH] Style fixes --- .php_cs.dist | 2 ++ lib/Encoding/UTF8.php | 10 +++++----- perf/perf.php | 4 ++-- tests/cases/Encoding/TestUTF8.php | 5 ++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 42ef197..d39f997 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -11,11 +11,13 @@ $paths = [ __FILE__, BASE."RoboFile.php", BASE."lib", + BASE."perf", BASE."tests", ]; $rules = [ '@PSR2' => true, 'braces' => ['position_after_functions_and_oop_constructs' => "same"], + 'function_declaration' => ['closure_function_spacing' => "none"], ]; $finder = \PhpCsFixer\Finder::create(); diff --git a/lib/Encoding/UTF8.php b/lib/Encoding/UTF8.php index 8b0fb57..4ced745 100644 --- a/lib/Encoding/UTF8.php +++ b/lib/Encoding/UTF8.php @@ -66,7 +66,7 @@ class UTF8 { /** Decodes the next character from the string and returns its code point number * * If the end of the string has been reached, false is returned - * + * * @return int|bool */ public function nextCode() { @@ -188,8 +188,8 @@ class UTF8 { } } - /** Seeks to the start of the string - * + /** Seeks to the start of the string + * * This is usually faster than using the seek method for the same purpose */ public function rewind() { @@ -285,14 +285,14 @@ class UTF8 { /** Sets the decoder's state to the values specified */ protected function stateApply(array $state) { - foreach($state as $key => $value) { + foreach ($state as $key => $value) { $this->$key = $value; } } /** Handles decoding and encoding errors */ protected static function err(int $mode, $data = null) { - switch($mode) { + switch ($mode) { case self::MODE_NULL: // used internally during backward seeking return null; diff --git a/perf/perf.php b/perf/perf.php index 47ba8b6..eb8c66f 100644 --- a/perf/perf.php +++ b/perf/perf.php @@ -70,7 +70,7 @@ if (!file_exists(__DIR__."/docs/")) { mkdir(__DIR__."/docs/"); } -foreach($files as $fName => $file) { +foreach ($files as $fName => $file) { list($file, $make) = $file; $file = __DIR__."/docs/$file"; if (!file_exists($file)) { @@ -84,7 +84,7 @@ foreach($files as $fName => $file) { $text = file_get_contents($file); } echo str_pad("$fName:", 30, " ").compile_statistics($text)."\n"; - foreach($tests as $tName => $test) { + foreach ($tests as $tName => $test) { list($req, $test) = $test; if ($req && !extension_loaded($req)) { continue; diff --git a/tests/cases/Encoding/TestUTF8.php b/tests/cases/Encoding/TestUTF8.php index 63b06c5..9afd561 100644 --- a/tests/cases/Encoding/TestUTF8.php +++ b/tests/cases/Encoding/TestUTF8.php @@ -46,7 +46,7 @@ class TestUTF8 extends \PHPUnit\Framework\TestCase { */ public function testDecodeMultipleCharactersAsStrings(string $input, array $exp) { $out = []; - $exp = array_map(function ($v) { + $exp = array_map(function($v) { return \IntlChar::chr($v); }, $exp); $s = new UTF8($input); @@ -83,7 +83,7 @@ class TestUTF8 extends \PHPUnit\Framework\TestCase { } $this->assertSame(sizeof($exp), $a); - $exp = array_map(function ($v) { + $exp = array_map(function($v) { return \IntlChar::chr($v); }, $exp); @@ -102,7 +102,6 @@ class TestUTF8 extends \PHPUnit\Framework\TestCase { $a++; } $this->assertSame(sizeof($exp), $a); - } /**