Closed SamTyurenkov closed 5 months ago
@valeryan, could I check with you here. Is this a similar issue to https://github.com/valeryan/vscode-phpsab/issues/109. I'm not aware of phpcs working on .html files, but I could be mistaken.
Yes, this is similar to #109 and we are not going to support or add features around deprecated functionality. This extension specifically only activates for php file types when the extension is registered in VSCode.
@valeryan @jonathanbossenger
No it is not similar issue.
The difference is - the one you mentioned is about different languages - css or js. While my issue is about working with php language but inside an .html file.
Please reopen, I dont seem to have access rights.
Example code: (the only difference is file extension, otherwise its a valid php file)
<!-- html file with regular html markup, but with php embeddings. -->
<div>
Regular html markup
</div>
<?php
//Php code that could be sniffed
$variable = 'hello world';
?>
<!-- html file with regular html markup, but with php embeddings. -->
<div>
Regular html markup
</div>
<?php
//Php code that could be sniffed
$variable = 'hello world';
?>
in vscode you can choose to treat html files, as PHP files., in the bottom right corner
I don't do php anymore but I can't imagine why you would want to invert and embed php in html. However, if you tell VSCode to treat the file as php the extension should activate. Phpcs may not pick that up though. I will look at it but I don't see this working.
@valeryan in my projects I dont implement such crazy things, but I have to work with code written by others, and unfortunately I met such a case, where I need those .html files to be sniffed as well.
Some template files of an unpopular CMS.
@SamTyurenkov are you able to run phpcs in the terminal against the .html template files?
I just did a quick test using
phpcs -p example-file.html --standard=PSR1
Against an .html file which included the following code
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<?php
class my_class(){
function my_class(){
return true;
}
}
?>
</body>
</html>
and none of the expected phpcs errors or warnings were reported.
@jonathanbossenger im not near PC right now, but didnt think about it.
Actually I keep forgeting that extension cant do more than actual executable can.
If it cant - sorry, probably close this issue then.
Yup, as far as I know that is the case, so I'll close this out.
When working with php inside .html templates, sniffer doesnt seem to validate or fix errors.