problem with prettier auto add double "php close tag" end of file
Hi
after save , prettier auto add double "php close tags" on end of file effect only short tags
Prettier 6.3.1 PHP Plugin 0.16.2
Input:
<?
?>
Output:
<?
?> ?>
save the second
<?
?> ?> ?>
save the third
<?
?> ?> ?> ?>
Debug options
{
"filepath": "includes\\get-approve-email.php",
"parser": "php",
"semi": false,
"arrowParens": "always",
"singleQuote": true,
"printWidth": 800,
"tabWidth": 3,
"separatorWidth": 800,
"trailingCommaPHP": false,
"braceStyle": "psr-2",
"requirePragma": false,
"insertPragma": false
}
Thanks.
Maybe this bug?
parts.push(lineSuffix(concat([beforeCloseTag, "?>"])));
to
parts.push(lineSuffix(beforeCloseTag));
https://github.com/prettier/plugin-php/blob/48e0489a97125b6ce1273087130100b772e2e620/src/printer.js#L1109
Hi @mean-cj, feel free to try it by opening a PR and adding some tests. https://github.com/prettier/plugin-php/blob/master/CONTRIBUTING.md should contain everything you need to get started, otherwise let me know :wink:
Hello @czosel
result of contributing prettier-php \node_modules.bin\prettier test.php
TEST 1
Input
<?php
echo 1;
?>
Output
<?php
echo 1;
?>
TEST 2
Input
<?
echo 1;
?>
Output
<?
echo 1;
TEST with VSCode
- Remove all vscode extensions
- Install only prettier-vscode (esbenp.prettier-vscode)
- Run powershell on windows 10 , install "prettier/plugin-php" --- cd C:\Users\USERNAME\.vscode\extensions\esbenp.prettier-vscode-6.3.1 --- yarn add --dev @prettier/plugin-php
TEST 3 Input
<?
echo 1;
?>
Output
<?
echo 1;
?>
?>
save the second
<?
echo 1;
?>
?> ?>
TEST 4 Input
<?php
echo 1;
?>
Output
<?php
echo 1;
?>
TEST 5 Input
<?
echo 1;
Output
<?
echo 1;
TEST 6 input
<?php
echo 1;
output
<?php
echo 1;
Prettier Options:
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 200,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"filepath": "....\test.php",
"parser": "php"
}
vscode: settings.json
"php.validate.executablePath": "c:/php74/php.exe",
Thanks