THRIFT-2807 PHP CS Fix
This closes #252
Patch: Roger Thomas
diff --git a/lib/php/src/TStringUtils.php b/lib/php/src/TStringUtils.php
index 69672e8..894baf8 100644
--- a/lib/php/src/TStringUtils.php
+++ b/lib/php/src/TStringUtils.php
@@ -1,28 +1,33 @@
<?php
-interface TStringFunc {
+interface TStringFunc
+{
public function substr($str, $start, $length = null);
public function strlen($str);
}
class TStringFunc_Core
implements TStringFunc {
- public function substr($str, $start, $length = null) {
+ public function substr($str, $start, $length = null)
+ {
// specifying a null $length would return an empty string
- if($length === null) {
+ if ($length === null) {
return substr($str, $start);
}
+
return substr($str, $start, $length);
}
- public function strlen($str) {
+ public function strlen($str)
+ {
return strlen($str);
}
}
class TStringFunc_Mbstring
implements TStringFunc {
- public function substr($str, $start, $length = null) {
+ public function substr($str, $start, $length = null)
+ {
/**
* We need to set the charset parameter, which is the second
* optional parameter and the first optional parameter can't
@@ -30,19 +35,21 @@
* cause an empty string to be returned, so we need to
* actually calculate the proper length value.
*/
- if($length === null) {
+ if ($length === null) {
$length = $this->strlen($str) - $start;
}
return mb_substr($str, $start, $length, '8bit');
}
- public function strlen($str) {
+ public function strlen($str)
+ {
return mb_strlen($str, '8bit');
}
}
-class TStringFuncFactory {
+class TStringFuncFactory
+{
private static $_instance;
/**
@@ -51,22 +58,24 @@
*
* @return TStringFunc
*/
- public static function create() {
- if(!self::$_instance) {
+ public static function create()
+ {
+ if (!self::$_instance) {
self::_setInstance();
}
return self::$_instance;
}
- private static function _setInstance() {
+ private static function _setInstance()
+ {
/**
* Cannot use str* functions for byte counting because multibyte
* characters will be read a single bytes.
*
* See: http://us.php.net/manual/en/mbstring.overload.php
*/
- if(ini_get('mbstring.func_overload') & 2) {
+ if (ini_get('mbstring.func_overload') & 2) {
self::$_instance = new TStringFunc_Mbstring();
}
/**