In CakePHP there is a (quite fundamental) method called find. Most of the time this method would return an array but if you pass count as the first parameter the method would return a different data type – an integer.
The method is allowed to return various data types.
Isn’t that bad?
Scripting languages tend to use this pattern of returning multiple types depending on either type of input parameters or value of parameters.
It can be confusing, but as long as you have good documentation its not a problem and can be very powerful.
Strongly typed languages use function overloads to do the same thing.