Skip to content

Commit

Permalink
fix and update methods in class \Swoole\MultibyteStringObject
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed Dec 9, 2023
1 parent f211ae1 commit 3a543c1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/MultibyteStringObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,25 @@ public function rpos(string $needle, int $offset = 0, ?string $encoding = null):
return mb_strrpos($this->string, $needle, $offset, $encoding);
}

/**
* @return false|int
*/
public function ipos(string $needle, ?string $encoding = null)
public function ipos(string $needle, int $offset = 0, ?string $encoding = null): int|false
{
return mb_stripos($this->string, ...func_get_args());
return mb_stripos($this->string, $needle, $offset, $encoding);
}

/**
* @return static
* @todo First parameter will be renamed to $start in Swoole 5.2+.
* @todo This method will be refactored and marked as final in Swoole 5.2+.
* 1. It should use keyword self instead of static.
* 2. Don't use function func_get_args().
*/
public function substr(int $offset, ?int $length = null, ?string $encoding = null)
public function substr(int $offset, ?int $length = null, ?string $encoding = null): static
{
return new static(mb_substr($this->string, ...func_get_args()));
return new static(mb_substr($this->string, ...func_get_args())); // @phpstan-ignore new.static
}

/**
* @todo This method is not implemented correctly.
*/
public function chunk(int $splitLength = 1, ?int $limit = null): ArrayObject
{
return static::detectArrayType(mb_split($this->string, ...func_get_args()));
Expand Down

0 comments on commit 3a543c1

Please sign in to comment.