Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 315 forks source link

[BUGFIX] PHP Warning: substr() expects parameter 1 to be string, array given #562

Open soda-2005 opened 8 years ago

soda-2005 commented 8 years ago

This bugfix fixes the following PHP-warning: PHP Warning: substr() expects parameter 1 to be string, array given in luracast/restler/vendor/Luracast/Restler/Data/Text.php line 63

Arul- commented 7 years ago

is_string($r['type']) should not be needed. If $r['type'] is not a string, problem is some where else and that needs to be fixed

scelt commented 7 years ago

If $r['type'] is not a string, problem is some where else and that needs to be fixed

When there's @param string|array it creates an array out of it (vendor/Luracast/Restler/CommentParser.php:477).

And if you put the is_string($r['type']) into the if clause, @param int|array[]will fail because it will be array but still there is the ending [] (see the last example here: https://www.phpdoc.org/docs/latest/guides/types.html).

I guess that this should be fixed in a way that if $r['type'] is an array, you should use the original type value (for example string|int[]) in the Text::endsWith() as a haystack.

What say you, @Arul-?

Arul- commented 7 years ago

@scelt Good Catch! Will come up with a way to handle that!