#5465 use strlen instead of empty #5499

Merged
merged 5 commits into from Feb 20, 2014

Conversation

Projects
None yet
5 participants
Contributor

jeremyquinton commented Nov 18, 2013

No description provided.

Contributor

jeremyquinton commented Nov 18, 2013

by mistake hadn't set my global name and email address for git hence the commit coming from someone named root.

Member

Ocramius commented Nov 19, 2013

@jeremyquinton test required

Contributor

jeremyquinton commented Nov 19, 2013

I will commit one this evening.

Contributor

jeremyquinton commented Nov 19, 2013

@Ocramius unit test as requested.

Member

marc-mabe commented Nov 25, 2013

Btw: (string)$var === "" is much faster then strlen($var) == 0

@Maks3w Maks3w self-assigned this Feb 20, 2014

@Maks3w Maks3w added this to the 2.2.6 milestone Feb 20, 2014

Member

Maks3w commented Feb 20, 2014

@jeremyquinton Please fix the cs and this will be merged.

Contributor

jeremyquinton commented Feb 20, 2014

@Maks3w when you say cs do you mean code style and are you referring to the comment above yours.

Member

Maks3w commented Feb 20, 2014

@jeremyquinton yes, code style. See travis report for to see where your code is failing.

Contributor

jeremyquinton commented Feb 20, 2014

@Maks3w
Build is still failing. Travis CI says
ZendTest/Filter/StripTagsTest.php (trailing_spaces)

I'm not 100% sure what trailing spaces it means but any guidance appreciated.

PSR-2 https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md

states
there MUST NOT be trailing whitespace at the end of non-blank lines.

I don't have any trailing whitespace that I can see

Contributor

jeremyquinton commented Feb 20, 2014

will give this https://github.com/fabpot/PHP-CS-Fixer a try leave it to me

Maks3w added a commit that referenced this pull request Feb 20, 2014

Maks3w added a commit that referenced this pull request Feb 20, 2014

Maks3w added a commit that referenced this pull request Feb 20, 2014

@Maks3w Maks3w merged commit ddb6a34 into zendframework:master Feb 20, 2014

1 check passed

default The Travis CI build passed
Details
@@ -282,7 +282,7 @@ protected function _filterTag($tag)
foreach ($matches[1] as $index => $attributeName) {
$attributeName = strtolower($attributeName);
$attributeDelimiter = empty($matches[2][$index]) ? $matches[4][$index] : $matches[2][$index];
- $attributeValue = empty($matches[3][$index]) ? $matches[5][$index] : $matches[3][$index];
+ $attributeValue = (strlen($matches[3][$index]) == 0) ? $matches[5][$index] : $matches[3][$index];
@DASPRiD

DASPRiD Feb 20, 2014

Member

Shouldn't there be a strict comparison, since strlen() may return null?

@jeremyquinton

jeremyquinton Feb 20, 2014

Contributor

from http://uk3.php.net/strlen strlen returns null if called on an array. Is there another circumstance when strlen can return null?

I wrote this fix a couple months ago but unless $matches[3][$index] is an array at any point I think this should be ok.

I can't find the code I used to reproduce the issue. In the next week what I will do is rewrite the code to reproduce the issue and see what the value of $matches[3][$index] is to get a feel for if it can every be an array.

gianarb pushed a commit to zendframework/zend-filter that referenced this pull request May 15, 2015

gianarb pushed a commit to zendframework/zend-filter that referenced this pull request May 15, 2015

gianarb pushed a commit to zendframework/zend-filter that referenced this pull request May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment