Skip to content

Commit 7be7fd1

Browse files
committed
style: fix prettier formatting and add beachball change file
1 parent 76ea1eb commit 7be7fd1

9 files changed

Lines changed: 50 additions & 46 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"comment": "feat: sync with upstream phpdoc-parser v1.25-v2.3.2",
3+
"type": "minor",
4+
"packageName": "@rightcapital/phpdoc-parser",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

src/phpdoc-parser/ast/php-doc/php-doc-node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ export class PhpDocNode extends BaseNode {
136136
);
137137
}
138138

139-
public getSealedTagValues(
140-
tagName = '@phpstan-sealed',
141-
): SealedTagValueNode[] {
139+
public getSealedTagValues(tagName = '@phpstan-sealed'): SealedTagValueNode[] {
142140
return this.getTagsByName(tagName)
143141
.map((tag) => tag.value)
144142
.filter(

src/phpdoc-parser/ast/type/array-shape-node.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export class ArrayShapeNode extends TypeNode {
4242
const items: (ArrayShapeItemNode | string)[] = [...this.items];
4343

4444
if (!this.sealed) {
45-
items.push(`...${ this.unsealedType !== null ? this.unsealedType.toString() : ''}`);
45+
items.push(
46+
`...${this.unsealedType !== null ? this.unsealedType.toString() : ''}`,
47+
);
4648
}
4749

4850
return `${this.kind}{${items.join(', ')}}`;

src/phpdoc-parser/ast/type/callable-type-node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export class CallableTypeNode extends TypeNode {
1818
if (returnType instanceof CallableTypeNode) {
1919
returnType = `(${returnType.toString()})`;
2020
}
21-
const template = this.templateTypes.length > 0 ? `<${this.templateTypes.join(', ')}>` : '';
21+
const template =
22+
this.templateTypes.length > 0 ? `<${this.templateTypes.join(', ')}>` : '';
2223
const parameters = this.parameters.join(', ');
2324
return `${this.identifier.toString()}${template}(${parameters}): ${returnType.toString()}`;
2425
}

src/phpdoc-parser/parser/const-expr-parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export class ConstExprParser {
2222
/**
2323
* @param usedAttributes is an object that may have 'lines' and 'indexes' properties
2424
*/
25-
constructor(
26-
usedAttributes: { lines?: boolean; indexes?: boolean } = {},
27-
) {
25+
constructor(usedAttributes: { lines?: boolean; indexes?: boolean } = {}) {
2826
this.useLinesAttributes = usedAttributes.lines ?? false;
2927
this.useIndexAttributes = usedAttributes.indexes ?? false;
3028
}

src/phpdoc-parser/parser/type-parser.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ export class TypeParser {
252252
type = this.tryParseArrayOrOffsetAccess(tokens, type);
253253
}
254254
}
255-
} else if (
256-
tokens.isCurrentTokenType(Lexer.TOKEN_OPEN_PARENTHESES)
257-
) {
255+
} else if (tokens.isCurrentTokenType(Lexer.TOKEN_OPEN_PARENTHESES)) {
258256
type = this.tryParseCallable(tokens, identifierTypeNode, false);
259257
} else if (tokens.isCurrentTokenType(Lexer.TOKEN_OPEN_SQUARE_BRACKET)) {
260258
type = this.tryParseArrayOrOffsetAccess(tokens, type);
@@ -578,9 +576,7 @@ export class TypeParser {
578576
identifier: IdentifierTypeNode,
579577
hasTemplate: boolean,
580578
): CallableTypeNode {
581-
const templates = hasTemplate
582-
? this.parseCallableTemplates(tokens)
583-
: [];
579+
const templates = hasTemplate ? this.parseCallableTemplates(tokens) : [];
584580

585581
tokens.consumeTokenType(Lexer.TOKEN_OPEN_PARENTHESES);
586582
tokens.skipNewLineTokensAndConsumeComments();
@@ -618,7 +614,9 @@ export class TypeParser {
618614
return new CallableTypeNode(identifier, parameters, returnType, templates);
619615
}
620616

621-
private parseCallableTemplates(tokens: TokenIterator): TemplateTagValueNode[] {
617+
private parseCallableTemplates(
618+
tokens: TokenIterator,
619+
): TemplateTagValueNode[] {
622620
tokens.consumeTokenType(Lexer.TOKEN_OPEN_ANGLE_BRACKET);
623621

624622
const templates: TemplateTagValueNode[] = [];

tests/parser/const-expr-node.test.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ const floatNodeParseData = [
8787
const stringNodeParseData = [
8888
// String - values are always unescaped in v2.0
8989
['"foo"', new ConstExprStringNode('foo', ConstExprStringNode.DOUBLE_QUOTED)],
90-
['"Foo \\n\\"\\r Bar"', new ConstExprStringNode('Foo \n"\r Bar', ConstExprStringNode.DOUBLE_QUOTED)],
90+
[
91+
'"Foo \\n\\"\\r Bar"',
92+
new ConstExprStringNode('Foo \n"\r Bar', ConstExprStringNode.DOUBLE_QUOTED),
93+
],
9194
["'bar'", new ConstExprStringNode('bar', ConstExprStringNode.SINGLE_QUOTED)],
92-
["'Foo \\' Bar'", new ConstExprStringNode("Foo ' Bar", ConstExprStringNode.SINGLE_QUOTED)],
95+
[
96+
"'Foo \\' Bar'",
97+
new ConstExprStringNode("Foo ' Bar", ConstExprStringNode.SINGLE_QUOTED),
98+
],
9399
] as TestFixtureDataItem[];
94100

95101
const arrayNodeParseData = [
@@ -166,10 +172,19 @@ const fetchNodeParseData = [
166172

167173
const withTrimStringsStringParseData = [
168174
['"foo"', new ConstExprStringNode('foo', ConstExprStringNode.DOUBLE_QUOTED)],
169-
['"Foo \\n\\"\\r Bar"', new ConstExprStringNode('Foo \n"\r Bar', ConstExprStringNode.DOUBLE_QUOTED)],
175+
[
176+
'"Foo \\n\\"\\r Bar"',
177+
new ConstExprStringNode('Foo \n"\r Bar', ConstExprStringNode.DOUBLE_QUOTED),
178+
],
170179
["'bar'", new ConstExprStringNode('bar', ConstExprStringNode.SINGLE_QUOTED)],
171-
["'Foo \\' Bar'", new ConstExprStringNode("Foo ' Bar", ConstExprStringNode.SINGLE_QUOTED)],
172-
['"\u{1f601}"', new ConstExprStringNode('\u{1f601}', ConstExprStringNode.DOUBLE_QUOTED)],
180+
[
181+
"'Foo \\' Bar'",
182+
new ConstExprStringNode("Foo ' Bar", ConstExprStringNode.SINGLE_QUOTED),
183+
],
184+
[
185+
'"\u{1f601}"',
186+
new ConstExprStringNode('\u{1f601}', ConstExprStringNode.DOUBLE_QUOTED),
187+
],
173188
// ['"\u{ffffffff}"', new ConstExprStringNode('\u{fffd}', ConstExprStringNode.DOUBLE_QUOTED)],
174189
];
175190

tests/parser/upstream-2024-features.test.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,14 @@ describe('Upstream 2024 Features', () => {
267267
const phpDocParser = new PhpDocParser(typeParser, constExprParser);
268268

269269
const tokens = new TokenIterator(
270-
lexer.tokenize(
271-
'/** @param-immediately-invoked-callable $callback */',
272-
),
270+
lexer.tokenize('/** @param-immediately-invoked-callable $callback */'),
273271
);
274272

275273
const phpDoc = phpDocParser.parse(tokens);
276274
const tag = phpDoc.children[0];
277275
// @ts-expect-error - accessing value property
278276
const value = tag.value as ParamImmediatelyInvokedCallableTagValueNode;
279-
expect(value).toBeInstanceOf(
280-
ParamImmediatelyInvokedCallableTagValueNode,
281-
);
277+
expect(value).toBeInstanceOf(ParamImmediatelyInvokedCallableTagValueNode);
282278
expect(value.parameterName).toBe('$callback');
283279
});
284280

@@ -298,9 +294,7 @@ describe('Upstream 2024 Features', () => {
298294
const tag = phpDoc.children[0];
299295
// @ts-expect-error - accessing value property
300296
const value = tag.value as ParamImmediatelyInvokedCallableTagValueNode;
301-
expect(value).toBeInstanceOf(
302-
ParamImmediatelyInvokedCallableTagValueNode,
303-
);
297+
expect(value).toBeInstanceOf(ParamImmediatelyInvokedCallableTagValueNode);
304298
expect(value.parameterName).toBe('$fn');
305299
expect(value.description).toBe('some desc');
306300
});
@@ -356,8 +350,7 @@ describe('Upstream 2024 Features', () => {
356350
const phpDocParser = new PhpDocParser(typeParser, constExprParser);
357351

358352
const tokens = new TokenIterator(
359-
lexer.tokenize(
360-
'/** @pure-unless-callable-is-impure $callback */'),
353+
lexer.tokenize('/** @pure-unless-callable-is-impure $callback */'),
361354
);
362355

363356
const phpDoc = phpDocParser.parse(tokens);
@@ -616,9 +609,9 @@ describe('Upstream 2024 Features', () => {
616609
expect(callable.templateTypes[0].bound).toBeInstanceOf(
617610
IdentifierTypeNode,
618611
);
619-
expect(
620-
(callable.templateTypes[0].bound as IdentifierTypeNode).name,
621-
).toBe('Foo');
612+
expect((callable.templateTypes[0].bound as IdentifierTypeNode).name).toBe(
613+
'Foo',
614+
);
622615
});
623616

624617
it('should preserve toString for callable with templates', () => {
@@ -655,9 +648,7 @@ describe('Upstream 2024 Features', () => {
655648

656649
expect(value.name).toBe('T');
657650
expect(value.defaultTypeNode).toBeInstanceOf(IdentifierTypeNode);
658-
expect((value.defaultTypeNode as IdentifierTypeNode).name).toBe(
659-
'string',
660-
);
651+
expect((value.defaultTypeNode as IdentifierTypeNode).name).toBe('string');
661652
});
662653

663654
it('should parse template with bound, lower bound, and default', () => {
@@ -667,9 +658,7 @@ describe('Upstream 2024 Features', () => {
667658
const phpDocParser = new PhpDocParser(typeParser, constExprParser);
668659

669660
const tokens = new TokenIterator(
670-
lexer.tokenize(
671-
'/** @template T of Upper super Lower = Default */',
672-
),
661+
lexer.tokenize('/** @template T of Upper super Lower = Default */'),
673662
);
674663

675664
const phpDoc = phpDocParser.parse(tokens);
@@ -692,9 +681,7 @@ describe('Upstream 2024 Features', () => {
692681
const phpDocParser = new PhpDocParser(typeParser, constExprParser);
693682

694683
const tokens = new TokenIterator(
695-
lexer.tokenize(
696-
'/** @template T of Upper super Lower = Default */',
697-
),
684+
lexer.tokenize('/** @template T of Upper super Lower = Default */'),
698685
);
699686

700687
const phpDoc = phpDocParser.parse(tokens);

tests/parser/upstream-v2-features.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ describe('Upstream v2.0+ Features', () => {
232232

233233
// Test parsing a type directly
234234
const tokens = new TokenIterator(
235-
lexer.tokenize(
236-
'/** @return Foo<int, // key type\nstring> */',
237-
),
235+
lexer.tokenize('/** @return Foo<int, // key type\nstring> */'),
238236
);
239237
const phpDocParser = new PhpDocParser(typeParser, constExprParser);
240238
const result = phpDocParser.parse(tokens);

0 commit comments

Comments
 (0)