neomerx / json-api

Framework agnostic JSON API (jsonapi.org) implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Have a version with PHP 7.2 support

oliverlundquist opened this issue · comments

Hi, thanks for a great library.

I stumbled upon this error when upgrading to PHP 7.2 today.

This:

assert('is_callable($classNameOrCallable) === true');

Gives:

Error: Failure evaluating code:
is_callable($classNameOrCallable) === true
ErrorException: assert(): Calling assert() with a string argument is deprecated

I guess it would be enough just changing this like to:

assert(is_callable($classNameOrCallable));

Thanks

Yep, that's PHP incompatibility. PHP 5.6 accepts only strings, 7.0 and 7.1 both and 7.2 only non-strings. Unfortunately, we can't have both.
It's a broader issue than just removing ' from asserts. PHP 7+ brings to table stronger type system and what should be done is preparing version 2.0 for PHP 7.2+.

2 step solution.

Step 1. Make the lib compatible to 7.2 without losing compatibility with earlier versions.

  • done with removing the line with assert. To this date, we can be sure it works fine.

Step 2. Make a new version taking advantages of PHP 7.2

  • in the process. A branch called v2 is created.

Step 1 released as 1.0.8

For step 2 issue #190 is added