Inconsistencies ( return values )
It is said that an 'if clause' should return true if the evaluation within isn't false.
PHP Code:
Objects return false in an if clause... obj != false, returns true. "string,var" returns true, while {"string","var"} returns false. ( string representation of array, and array )... I believe it would be better having the evalFix, rather than the eval as return... This would allow flexability as such: PHP Code:
|
Okay, nevermind, I jumped the gun there by misreading your post... I'll re-edit this post later.
Okay, I've looked at this problem in detail. evalFIX() works properly, yes. eval() - the problem may or may not be a problem. arg ? true : false arg before it does ?: gets cast to a float -- Objects / arrays get cast to 0.0 obviously, which is why that logic fails with them. |
Quote:
PHP Code:
It casts the variable, yes... But that's where the problem is. It should only return false when it is false ("", null, false, "false" ), and in every other occasion, return true ( -1, "foo", {"stuff"}, new Object() ). |
I don't know if the behaviour should be changed. The only thing that seems to be different is the check if an object is not null, and return true in that case. You can check that yourself though, with "if (obj==NULL)". For optimization it is currently doing "float(condition)!=false" instead of "condition!=false".
|
Stefan: Seems like your post was deleted.
( talked about converting to float and bool ) Couldn't you work it out with type() ? PHP Code:
|
I have deleted and created a new post. It is doing such a check when you compare like 'condition!=false', but for optimization it is doing 'float(condition)!=0'
|
All times are GMT +2. The time now is 04:47 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.