Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed May 3, 2023
1 parent df93c69 commit 73a3624
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ It is recommended to add the directory of the `php.exe` to the PATH environment
If it still not working, refer to [#1](https://github.com/kokororin/vscode-phpfmt/issues/1) and [Stack Overflow Related](https://stackoverflow.com/a/45765854).


<!--
Q: How use tabs instead of spaces with PSR2 enabled ?
A: For [PSR2](https://www.php-fig.org/psr/psr-2/), code MUST use 4 spaces for indenting, not tabs. But if you like PSR2, and do not like 4 spaces for indentation, add following configuration:

Expand All @@ -69,10 +68,10 @@ A: For [PSR2](https://www.php-fig.org/psr/psr-2/), code MUST use 4 spaces for in
"ReindentComments",
"StripNewlineWithinClassBody"
],
"phpfmt.psr2": false
"phpfmt.psr2": false,
"phpfmt.use_old_phpfmt": true
}
```
-->

Q: Is fmt.phar (phpfmt itself) still maintained ?
~~A: Since phpfmt has no maintainers, only Serious bugs will be fixed.~~
Expand Down
22 changes: 12 additions & 10 deletions src/PHPFmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,19 @@ export class PHPFmt {
}

public async format(text: string): Promise<string> {
const passes = [...this.config.passes, ...this.config.exclude];
const transformations = await this.transformation.getTransformations();
if (passes.length > 0) {
const invalidPasses = passes.filter(
pass =>
!transformations.some(transformation => transformation.key === pass)
);
if (invalidPasses.length > 0) {
throw new PHPFmtError(
`passes or exclude invalid: ${invalidPasses.join(', ')}`
if (!this.config.use_old_phpfmt) {
const passes = [...this.config.passes, ...this.config.exclude];
const transformations = await this.transformation.getTransformations();
if (passes.length > 0) {
const invalidPasses = passes.filter(
pass =>
!transformations.some(transformation => transformation.key === pass)
);
if (invalidPasses.length > 0) {
throw new PHPFmtError(
`passes or exclude invalid: ${invalidPasses.join(', ')}`
);
}
}
}

Expand Down

0 comments on commit 73a3624

Please sign in to comment.