phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Documentation: Incorrect return type annotation in explode() function

Open I-am-io opened this issue 5 months ago • 2 comments

  • File: function.explode.php
  • Line: 10
  • Current implementation suggests explode() might return a boolean value, which is incorrect

Description

There's an issue with the PHPDoc @return annotation for the explode() function. The current annotation incorrectly includes bool as a possible return type:

@return bool|string[] Returns an `array` of `string`s created by splitting...

However, according to PHP's official documentation and the function's implementation, explode() always returns an array (or throws a ValueError in PHP 8+ when the separator is an empty string).

Expected behavior

The @return annotation should only specify string[] or array as the return type, not bool.

The correct annotation should be:

@return string[] Returns an `array` of `string`s created by splitting...

Image

I-am-io avatar Jun 05 '25 10:06 I-am-io