Skip to content

Commit

Permalink
fix: πŸ› syntax error on chained method
Browse files Browse the repository at this point in the history
βœ… Closes: #686
  • Loading branch information
shufo committed Aug 13, 2022
1 parent 8df6b32 commit 22b5f49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions __tests__/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4392,4 +4392,21 @@ describe('formatter', () => {

await util.doubleFormatCheck(content, expected2, { useTabs: true, indentSize: 2 });
});

test('unless directive with arrowed method', async () => {
const content = [
`@unless (auth()->user()->hasVerifiedEmail())`,
` <p>Please check and verify your email to access the system</p>`,
`@endunless`,
].join('\n');

const expected = [
`@unless(auth()->user()->hasVerifiedEmail())`,
` <p>Please check and verify your email to access the system</p>`,
`@endunless`,
``,
].join('\n');

await util.doubleFormatCheck(content, expected, { sortHtmlAttributes: 'idiomatic' });
});
});
1 change: 1 addition & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export async function prettifyPhpContentWithUnescapedTags(content: any) {
(match2: any, j1: any, j2: any, j3: any) => `@${j1.trim()}${j2}(${j3.trim()})`,
)
.replace(/([\n\s]*)->([\n\s]*)/gs, '->')
.replace(/,\)$/, ')')
.replace(/(?:\n\s*)* as(?= (?:&{0,1}\$[\w]+|list|\[\$[\w]+))/g, ' as'),
),
)
Expand Down

0 comments on commit 22b5f49

Please sign in to comment.