PHP is converting single and double quotes: ' and " into the characters: ’ and ” (https://unicode-table.com/en/2019/ and https://unicode-table.com/en/201D/) (right single quotation mark and right double quotation mark)
It only does this in arrow functions:
<div class="modal onclick="(() => { console.log('test button clicked'); })()">
<!-- modal contents -->
</div>
PHP spits out the wrong quotes:

onclick="(() => { console.log(‘test button clicked’); })()”
<div class="modal onclick="console.log('test button clicked')">
<!-- modal contents -->
</div>
onclick="(() => console.log('test button clicked')"
This is only in .php files; In a .html file this works fine:
onclick="(() => { console.log('test button clicked'); })()"
This means that I cannot use an arrow function inline in an HTML element because PHP incorrectly converts the quotes to unicode quote characters which renders those quotes to the DOM and the browser then continues to handle the rest of the page (as it should) as within double quotes and inside of the onclick (as it should) until it encounters another double quote from another HTML property.
I am using PHP 8.0.0. I've tried researching this and can't find anything else about it. As bold of a claim as it is, I believe I've found a bug in PHP, although I'd like someone more qualified than I to determine that.