Browse Source

Style fixes

labels
J. King 4 years ago
parent
commit
540d8a237e
  1. 2
      .php_cs.dist
  2. 10
      lib/Encoding/UTF8.php
  3. 4
      perf/perf.php
  4. 5
      tests/cases/Encoding/TestUTF8.php

2
.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();

10
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;

4
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;

5
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);
}
/**

Loading…
Cancel
Save