Task #63929
Deprecate usage of GeneralUtility::isFirstPartOfStr()
Status: | Accepted | Start date: | 2014-12-16 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Code Cleanup | Spent time: | - | |
Target version: | 7.5 | |||
TYPO3 Version: | 7 | Complexity: | ||
PHP Version: | Sprint Focus: |
Description
Use StringUtility::beginsWith() instead, which behaves "almost" identical but with some added checks.
Related issues
History
#1 Updated by Gerrit Code Review 8 months 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
#2 Updated by Anja Leichsenring 6 months ago
- Sprint Focus set to On Location Sprint
#3 Updated by Benjamin Mack 6 months 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.
#4 Updated by Stefan Neufeind 6 months 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.
#5 Updated by Jo Hasenau 6 months 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.
#6 Updated by Benjamin Mack 6 months ago
- Sprint Focus deleted (
On Location Sprint)