Project

General

Profile

Actions

Task #55518

closed

Use variable array access instead of strlen($a) > 0

Added by Michiel Roos over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Code Cleanup
Target version:
Start date:
2014-01-31
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
no-brainer
Sprint Focus:

Description

Checking if a string has any length greater than 0 characters can be done cheaply using variable array access:

Use:
if ($string{0}) {

Instead of:
if (strlen($string) > 0) {
if (strlen($string)) {

Actions #1

Updated by Michiel Roos over 10 years ago

How to find them:

/if\s*\(strlen\s*\([^\(\)]+\)( > 0)?\)/

Actions #2

Updated by Michiel Roos over 10 years ago

Please close this issue, http://forge.typo3.org/issues/54091 fixes this in a more readable way.

Actions #3

Updated by Wouter Wolters over 10 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF