Replies: 1 comment 1 reply
-
Since no one has replied for a week, I will take this as a "not interested right now" |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently looking for a replacement for the built-in
preg_match()
andpreg_replace()
functions that isYour project ticks all the boxes except that
Regex::replace(…)->result()
returnsarray | string
which triggers the same type-errors on phpstan and psalm as plainpreg_replace()
when simply assuming it must be a string, because the subject was a string.My suggestion would be to distinguish between
replace
andreplaceMulti
and have them both return differentReplaceResult
s, one having->result()
return a string, the other an array of strings. Yes, this is mainly to make linters and autocompleters happy, but splitting a function that returnsarray | string
into one that returns a string and one that returns an array makes it easier to work with.If I implemented this and provided a PR for it, would you even consider it, or is this change too breaking for you or simply not fitting the goal?
Beta Was this translation helpful? Give feedback.
All reactions