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

Warnings with php 7.1+ on string concatenate with + #618

Closed devprofession closed 5 years ago

devprofession commented 5 years ago

with 3.0.0 Restler Warning: A non-numeric value encountered in .../vendor/luracast/restler/vendor/Luracast/Restler/CommentParser.php on line 283

You can replace the plus with dot, and the warnings disappeared.

Arul- commented 5 years ago

@devprofession thanks for reporting, will get it fixed.

squatto commented 5 years ago

I just wanted to throw my support behind this one. Every morning I wake up to Rollbar.com errors hitting their limit because of this issue.

I've submitted PR #619 to fix this issue. Are there any releases planned in the near future?

Thanks!

Arul- commented 5 years ago

Can you share a specifc comment that causes this issue? it will help in debugging!

Arul- commented 5 years ago

@squatto thanks for your efforts to fix this

Can you try the following fix and confirm that resolves the issue and does not create any new issue

Change the following on Line 276 on CommentParser.php

        } else {
            if (!is_string($value) && isset($value[self::$embeddedDataName])
                && isset($data[$param][self::$embeddedDataName])
            ) {
                $value[self::$embeddedDataName]
                    += $data[$param][self::$embeddedDataName];
            }
            $data[$param] = $value + $data[$param];
        }

To the following

        } elseif (!is_string($value) && isset($value[self::$embeddedDataName]) && isset($data[$param][self::$embeddedDataName])) {
            $value[self::$embeddedDataName] += $data[$param][self::$embeddedDataName];
            $data[$param] = $value + $data[$param];
        }
Arul- commented 5 years ago

@devprofession can you try the above fix?

JoyceBabu commented 5 years ago

I too had the issue. After applying the above change, the warning is no longer appearing.

Btw, you can replicate the issue by enabling rate limiting, and using the following doc block for the handler class. The warning starts appearing once the rate limit is crossed.

/**
 * Test Class
 *
 * @abc opt1 900
 * @abc opt2 300
 */