pristas-peter / wp-graphql-gutenberg

Query gutenberg blocks with wp-graphql
https://wp-graphql-gutenberg.netlify.app
GNU General Public License v3.0
299 stars 62 forks source link

Fix value reference warning with PHP 8 #157

Closed colis closed 1 year ago

colis commented 1 year ago

The use of array_reduce() on line 23 within the normalize() method will cause a "PHP Warning: WPGraphQLGutenberg\Blocks\Registry::WPGraphQLGutenberg\Blocks{closure}(): Argument #1 ($arr) must be passed by reference, value given" warning on PHP 8.0 because the callback is declared to expect the $arr parameter to be passed by reference.

Since PHP 8.0, any functions accepting callbacks that are not explicitly specified to accept parameters by reference - such as array_reduce() - will now warn if a callback with reference parameters is used, hence the reference in the function declaration is redundant and should be removed.