Skip to content

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

Open
soda-2005 wants to merge 1 commit intoLuracast:v3from
AOEpeople:v3
Open

[BUGFIX] PHP Warning: substr() expects parameter 1 to be string, array given#562
soda-2005 wants to merge 1 commit intoLuracast:v3from
AOEpeople:v3

Conversation

@soda-2005
Copy link
Copy Markdown

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-
Copy link
Copy Markdown
Member

Arul- commented Jan 12, 2017

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
Copy link
Copy Markdown

scelt commented Jan 12, 2017

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-
Copy link
Copy Markdown
Member

Arul- commented Jan 16, 2017

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

@vdespa vdespa deleted the v3 branch May 15, 2017 11:10
…rray given in Restler/Data/Text.php line 63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants