Skip to content

Commit b3691c1

Browse files
committed
fix: array access by method error
1 parent 1aa43bf commit b3691c1

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

src/Obj/Traits/ArrayAccessByGetterSetterTrait.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
*/
2626
trait ArrayAccessByGetterSetterTrait
2727
{
28+
/** @var bool */
29+
// protected $__strict__ = false;
30+
2831
/**
2932
* Checks whether an offset exists in the iterator.
3033
*
@@ -49,7 +52,7 @@ public function offsetGet($offset)
4952
$getter = 'get' . ucfirst($offset);
5053

5154
if (method_exists($this, $getter)) {
52-
$this->$getter();
55+
return $this->$getter();
5356
}
5457

5558
return null;

src/Str/StrBuffer.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ public function __construct(string $str = '')
6464
$this->write($str);
6565
}
6666

67-
public function reset(): void
68-
{
69-
$this->parts = [];
70-
}
71-
7267
/**
7368
* @param string $content
7469
*/
@@ -110,6 +105,11 @@ public function prepend(string $content): void
110105
array_unshift($this->parts, $content);
111106
}
112107

108+
public function reset(): void
109+
{
110+
$this->parts = [];
111+
}
112+
113113
/**
114114
* clear data
115115
*/

src/Str/Traits/StringCaseHelperTrait.php

+25-14
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function strtolower(string $str): string
9292
*/
9393
public static function upper($str): string
9494
{
95-
return static::strtoupper($str);
95+
return static::toUpper($str);
9696
}
9797

9898
/**
@@ -103,16 +103,6 @@ public static function upper($str): string
103103
* @return string
104104
*/
105105
public static function toUpper($str): string
106-
{
107-
return static::strtoupper($str);
108-
}
109-
110-
/**
111-
* @param string|int $str
112-
*
113-
* @return string
114-
*/
115-
public static function strtoupper($str): string
116106
{
117107
if (!is_scalar($str)) {
118108
return '';
@@ -125,13 +115,24 @@ public static function strtoupper($str): string
125115
return function_exists('mb_strtoupper') ? mb_strtoupper($str, 'utf-8') : strtoupper($str);
126116
}
127117

118+
/**
119+
* @param string|int $str
120+
*
121+
* @return string
122+
*/
123+
public static function strtoupper($str): string
124+
{
125+
return self::toUpper($str);
126+
}
127+
128128
/**
129129
* @param $str
130130
*
131131
* @return string
132132
*/
133-
public static function ucfirst($str): string
133+
public static function upFirst($str): string
134134
{
135+
135136
if (!is_scalar($str)) {
136137
return '';
137138
}
@@ -148,10 +149,20 @@ public static function ucfirst($str): string
148149
*
149150
* @return string
150151
*/
151-
public static function ucwords(string $str): string
152+
public static function ucfirst($str): string
153+
{
154+
return self::upFirst($str);
155+
}
156+
157+
/**
158+
* @param $str
159+
*
160+
* @return string
161+
*/
162+
public static function ucwords($str): string
152163
{
153164
return function_exists('mb_convert_case') ?
154-
mb_convert_case($str, MB_CASE_TITLE) :
165+
mb_convert_case((string)$str, MB_CASE_TITLE) :
155166
ucwords(self::strtolower($str));
156167
}
157168

0 commit comments

Comments
 (0)