Skip to content

Update strpos docs with error handling details when offset exceeds length - #4959

Merged
TimWolla merged 12 commits into
php:masterfrom
beryllium:patch-2
Oct 28, 2025
Merged

Update strpos docs with error handling details when offset exceeds length#4959
TimWolla merged 12 commits into
php:masterfrom
beryllium:patch-2

Conversation

@beryllium

@beryllium beryllium commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Added error handling information for offset parameter on strpos, stripos, mb_strpos, and mb_stripos, after observing this un/underdocumented fatal in production.

Note: Using the github web editor, so my apologies for the cluttered PR with so many extra merges. Hopefully it can be squash-merged if approved.

Added error handling information for offset parameter, after observing this un/underdocumented fatal in production.

Note: Using the github web editor, I am not sure if I can pull a second file into this PR, so I may submit a second PR to handle `stripos`.
Added error handling information for offset parameter.
Document error for offset exceeding haystack length
Added error handling information for offset parameter.
Document error for exceeding offset length
Added error handling information for offset parameter.
Document error for offset exceeding haystack length
@beryllium beryllium changed the title Update strpos.xml with error handling details Update strpos docs with error handling details when offset exceeds length Oct 27, 2025

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. A ValueError will be thrown in these cases.

Comment thread reference/mbstring/functions/mb-stripos.xml Outdated
Comment thread reference/mbstring/functions/mb-stripos.xml Outdated
@beryllium

Copy link
Copy Markdown
Contributor Author

Ah, you're correct, thanks. I was operating on log output from a system that reclassified ValueError occurrences as E_ERROR.

Comment thread reference/mbstring/functions/mb-strpos.xml Outdated
Comment thread reference/mbstring/functions/mb-strpos.xml Outdated
Comment thread reference/strings/functions/stripos.xml Outdated
Comment thread reference/strings/functions/stripos.xml Outdated
Comment thread reference/strings/functions/strpos.xml Outdated
Comment thread reference/strings/functions/strpos.xml Outdated
Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry. Incomplete suggestion. You'll also need <itemizedlist>. See:

@TimWolla

Copy link
Copy Markdown
Member

Note: Using the github web editor, so my apologies for the cluttered PR with so many extra merges. Hopefully it can be squash-merged if approved.

I suggest using a GitHub Codespace as a batteries-included online editor that allows you to easily edit multiple files in a single commit.

Comment thread reference/mbstring/functions/mb-stripos.xml Outdated

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@TimWolla
TimWolla merged commit 4b72b23 into php:master Oct 28, 2025
2 checks passed
Crell pushed a commit to Crell/doc-en that referenced this pull request Dec 15, 2025
…ngth (php#4959)

* Update strpos.xml with error handling details

Added error handling information for offset parameter, after observing this un/underdocumented fatal in production.

Note: Using the github web editor, I am not sure if I can pull a second file into this PR, so I may submit a second PR to handle `stripos`.

* Document error for offset exceeding haystack length

Added error handling information for offset parameter.

* Document error for exceeding offset length

Added error handling information for offset parameter.

* Document error for offset exceeding haystack length

Added error handling information for offset parameter.

* Apply suggestions from code review

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

* Apply review suggestions

* Remove csprng-specific html entity

* Add invalid offset ValueError information to strrpos-related methods

* Fix whitespace for strprpos error message info

---------

Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants