This problem is about custom code template for PHP and JS and it's bug that has been there for many years.
Thanks to user markiewb who replied to me on the Netbeans forum
the cause is clear: the Netbeans php component doesn't set the code scope in the xml file with the custom templates.
E.g. a template named ech is written down this way
<codetemplate abbreviation="ech" xml:space="preserve">
but should be this other way
<codetemplate abbreviation="ech" xml:space="preserve" contexts="php-code">
Set the file by hand or, after any change you make in the Netbeans code templates editor, run this simple script I've made for myself, and restart Netbeans. No problem running it more than once: it only makes changes where the option is missing.
17/8/2020 - Upgraded version here Netbeans 12 no completion on code templates (also backwards compatible with Netbeans 8 and middle versions).
Remember to change the var FILE with the proper path. You'll probably have to change only the version number.
Quite obvious but… if Netbeans is open when you run the script, remember to restart Netbeans or you won't see any change.