Task #63929
closedDeprecate usage of GeneralUtility::isFirstPartOfStr()
0%
Description
Use StringUtility::beginsWith() instead, which behaves "almost" identical but with some added checks.
Updated by Gerrit Code Review almost 10 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35513
Updated by Anja Leichsenring almost 10 years ago
- Sprint Focus set to On Location Sprint
Updated by Benni Mack almost 10 years ago
- Status changed from Under Review to Accepted
- Target version set to 7.5
The proper solution here is to get rid of isFirstPartOfStr by applying the following logic:
The following 'rules' should used for the replacement:- Drop isFirstPartOfStr / StringUtility::beginsWith in favor of any occurence of
strpos(haystack, needle) === 0
strpos(haystack, needle, 0) === 0 - Drop isFirstPartOfStr / StringUtility::beginsWith in favor of any occurence of
substr(haystack, 0, strlen(needle)) === needle - Use variable{x} for any occurence of
substr(string, x, 1) - Use array methods, when the string methods are simulating
an explode or check substr with the third parameter set to TRUE
Once all places are replaced (see related issue), then we can proceed here.
Updated by Stefan Neufeind almost 10 years ago
Note that substr($s, 0, 1), in case of NULL or an empty string, will return false - while simply accessing the index would at least trigger a notice.
beginsWith handles some edge-cases as well.
Updated by Jo Hasenau almost 10 years ago
So let's check for NULL and '' in these cases, to avoid the warning, since they are rare compared to the first example anyway.
Updated by Benni Mack almost 10 years ago
- Sprint Focus deleted (
On Location Sprint)
Updated by Christian Kuhn over 8 years ago
- Status changed from Accepted to Rejected
patch didn't make it and was not pushed forward. closed issue for now, feel free to further work on it if needed.