generator icon indicating copy to clipboard operation
generator copied to clipboard

Parse Error with Immediately Invoked Function Expression (IIFE)

Open senadir opened this issue 2 years ago • 4 comments

I have the following function that fails parsing because of the () call at the end:

$container = $container ?: ( function() {
	// logic here
} )();

IIFE are supported as of PHP 7.0 and up.

senadir avatar Nov 09 '22 09:11 senadir

Can you explain a bit more? How does this relate to this library?

johnbillion avatar Nov 09 '22 10:11 johnbillion

Ah is that code inside your application that you're scanning with this library? In that case the error is probably because the hooks parser library that's used in this library is quite out of date and needs to be updated. See #4.

johnbillion avatar Nov 09 '22 10:11 johnbillion

Thank you, I will update to wp-hooks/wordpress-core

senadir avatar Nov 09 '22 10:11 senadir

This won't be enough, bc the library this depends on is outdated/not maintained anymore.

There are tons of similar issues with all kinds of code that cause issues here. A possible solution (besides maintaining that other library) is to just remove all code that causes issues. I currently pre-parse all files and remove all code that causes issues and is irrelevant for hooks anyway.

kkmuffme avatar Nov 10 '22 12:11 kkmuffme