[TYPO3-core] RFC: GIFBUILDER transparency
Bernhard Kraft
kraftb at kraftb.at
Tue Mar 21 16:19:56 CET 2006
Martin Kutschker wrote:
> I have no proof, but I think that in TYPO3 usually the same type for a return value is preferred. There was much mumbling when I
> tried to change the return value for a plugin's main method. So using -1 is probably more in line with existing TYPO3 code and
> resembles the PHP API for this specific task.
>
> So maybe sticking to the type is a good general rule.
So it seems we have clarified what "-1" should get used in this case. (It conforms to T3 standards becasue returning only one specific
type (int) and conforms to PHP context because it returns color indexes (ints) and -1 if not found - like PHP does)
> But I think that there may be exemptions to a rule. eg if we have an extenstion to an existing PHP API we should mimick it's behaviour.
> And if it may return FALSE on failure or some other condition then we should do the same.
From the php manual for function "imagecolorexact()"
---------------------------------------
int imagecolorexact ( resource image, int red, int green, int blue )
Returns the index of the specified color in the palette of the image.
If the color does not exist in the image's palette, -1 is returned.
---------------------------------------
> And there may be cases where also negative ints are possible results, so here FALSE is the only way to signal an error.
Surely - don't know currently where this happens but it is possible of course (often 0 is a valid return value
like for strpos when the searched string was found at offset 0 - the beginning of the string ... so you have to check for
"not-found" with ===false here ...)
I think our telephone call we had clarified everything else (except the deeper reasons of existence of the universe :)
greets,
Bernhard
More information about the TYPO3-team-core
mailing list