Skip to content

Commit be3aafa

Browse files
committed
[BCB] Constructor parameter $isReference in ParamTagValueNode made required
1 parent 6e68248 commit be3aafa

File tree

5 files changed

+56
-20
lines changed

5 files changed

+56
-20
lines changed

UPGRADING.md

+1
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,4 @@ The line with `some text in the middle` in phpdoc-parser 2.0 is now part of the
118118

119119
* Constructor parameter `$isEquality` in `AssertTag*ValueNode` made required
120120
* Constructor parameter `$templateTypes` in `MethodTagValueNode` made required
121+
* Constructor parameter `$isReference` in `ParamTagValueNode` made required

src/Ast/PhpDoc/ParamTagValueNode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ParamTagValueNode implements PhpDocTagValueNode
2222
/** @var string (may be empty) */
2323
public string $description;
2424

25-
public function __construct(TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference = false)
25+
public function __construct(TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference)
2626
{
2727
$this->type = $type;
2828
$this->isReference = $isReference;

tests/PHPStan/Parser/PhpDocParserTest.php

+48-15
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public function provideParamTagsData(): Iterator
160160
false,
161161
'$foo',
162162
'',
163+
false,
163164
),
164165
),
165166
]),
@@ -176,6 +177,7 @@ public function provideParamTagsData(): Iterator
176177
false,
177178
'$foo',
178179
'optional description',
180+
false,
179181
),
180182
),
181183
]),
@@ -192,6 +194,7 @@ public function provideParamTagsData(): Iterator
192194
true,
193195
'$foo',
194196
'',
197+
false,
195198
),
196199
),
197200
]),
@@ -208,6 +211,7 @@ public function provideParamTagsData(): Iterator
208211
true,
209212
'$foo',
210213
'optional description',
214+
false,
211215
),
212216
),
213217
]),
@@ -292,6 +296,7 @@ public function provideParamTagsData(): Iterator
292296
false,
293297
'$foo',
294298
'optional description',
299+
false,
295300
),
296301
),
297302
]),
@@ -509,6 +514,7 @@ public function provideParamTagsData(): Iterator
509514
'$parameters',
510515
'{' . PHP_EOL .
511516
' Optional. Parameters for filtering the list of user assignments. Default empty array.',
517+
false,
512518
),
513519
),
514520
new PhpDocTextNode(''),
@@ -2966,6 +2972,7 @@ public function provideMultiLinePhpDocData(): iterable
29662972
false,
29672973
'$foo',
29682974
'1st multi world description',
2975+
false,
29692976
),
29702977
),
29712978
new PhpDocTagNode(
@@ -2975,6 +2982,7 @@ public function provideMultiLinePhpDocData(): iterable
29752982
false,
29762983
'$bar',
29772984
'2nd multi world description',
2985+
false,
29782986
),
29792987
),
29802988
]),
@@ -2995,6 +3003,7 @@ public function provideMultiLinePhpDocData(): iterable
29953003
'$foo',
29963004
'1st multi world description
29973005
some text in the middle',
3006+
false,
29983007
),
29993008
),
30003009
new PhpDocTagNode(
@@ -3004,6 +3013,7 @@ public function provideMultiLinePhpDocData(): iterable
30043013
false,
30053014
'$bar',
30063015
'2nd multi world description',
3016+
false,
30073017
),
30083018
),
30093019
]),
@@ -3037,6 +3047,7 @@ public function provideMultiLinePhpDocData(): iterable
30373047
30383048
30393049
some text in the middle',
3050+
false,
30403051
),
30413052
),
30423053
new PhpDocTextNode(''),
@@ -3051,6 +3062,7 @@ public function provideMultiLinePhpDocData(): iterable
30513062
30523063
30533064
test',
3065+
false,
30543066
),
30553067
),
30563068

@@ -3082,6 +3094,7 @@ public function provideMultiLinePhpDocData(): iterable
30823094
false,
30833095
'$foo',
30843096
'@param string $bar',
3097+
false,
30853098
),
30863099
),
30873100
]),
@@ -3824,6 +3837,7 @@ public function provideMultiLinePhpDocData(): iterable
38243837
false,
38253838
'$list',
38263839
'',
3840+
false,
38273841
),
38283842
),
38293843
new PhpDocTextNode(''),
@@ -3903,7 +3917,7 @@ public function provideMultiLinePhpDocData(): iterable
39033917
' */',
39043918
new PhpDocNode([
39053919
new PhpDocTextNode('Real description'),
3906-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '')),
3920+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '', false)),
39073921
new PhpDocTextNode(''),
39083922
new PhpDocTextNode(''),
39093923
]),
@@ -3930,6 +3944,7 @@ public function provideMultiLinePhpDocData(): iterable
39303944
. PHP_EOL
39313945
. PHP_EOL
39323946
. 'test',
3947+
false,
39333948
),
39343949
),
39353950
]),
@@ -4344,6 +4359,7 @@ public function provideExtendsTagsData(): Iterator
43444359
false,
43454360
'$test',
43464361
'',
4362+
false,
43474363
),
43484364
),
43494365
]),
@@ -4360,6 +4376,7 @@ public function provideExtendsTagsData(): Iterator
43604376
false,
43614377
'$test',
43624378
'some description',
4379+
false,
43634380
),
43644381
),
43654382
]),
@@ -5082,6 +5099,7 @@ public function provideRealWorldExampleData(): Iterator
50825099
'$field_definition',
50835100
'
50845101
The field definition.',
5102+
false,
50855103
),
50865104
),
50875105
new PhpDocTextNode(''),
@@ -5158,6 +5176,7 @@ public function provideRealWorldExampleData(): Iterator
51585176
false,
51595177
'$request',
51605178
'- The request object',
5179+
false,
51615180
),
51625181
),
51635182
new PhpDocTextNode(''),
@@ -5328,6 +5347,7 @@ public function provideRealWorldExampleData(): Iterator
53285347
false,
53295348
'$foo',
53305349
'',
5350+
false,
53315351
),
53325352
),
53335353
]),
@@ -5356,6 +5376,7 @@ public function provideRealWorldExampleData(): Iterator
53565376
false,
53575377
'$foo',
53585378
'',
5379+
false,
53595380
),
53605381
),
53615382
]),
@@ -5384,6 +5405,7 @@ public function provideRealWorldExampleData(): Iterator
53845405
false,
53855406
'$foo',
53865407
'',
5408+
false,
53875409
),
53885410
),
53895411
]),
@@ -5437,6 +5459,7 @@ public function provideRealWorldExampleData(): Iterator
54375459
false,
54385460
'$pattern',
54395461
'',
5462+
false,
54405463
),
54415464
),
54425465
new PhpDocTagNode(
@@ -5446,6 +5469,7 @@ public function provideRealWorldExampleData(): Iterator
54465469
false,
54475470
'$subject',
54485471
'',
5472+
false,
54495473
),
54505474
),
54515475
new PhpDocTagNode(
@@ -5455,6 +5479,7 @@ public function provideRealWorldExampleData(): Iterator
54555479
false,
54565480
'$matches',
54575481
'',
5482+
false,
54585483
),
54595484
),
54605485
new PhpDocTagNode(
@@ -5464,6 +5489,7 @@ public function provideRealWorldExampleData(): Iterator
54645489
false,
54655490
'$flags',
54665491
'',
5492+
false,
54675493
),
54685494
),
54695495
new PhpDocTagNode(
@@ -5671,6 +5697,7 @@ public function dataParseTagValue(): array
56715697
false,
56725698
'$a',
56735699
'',
5700+
false,
56745701
),
56755702
],
56765703
[
@@ -5817,6 +5844,7 @@ public function provideCommentLikeDescriptions(): Iterator
58175844
false,
58185845
'$a',
58195846
'// this is a description',
5847+
false,
58205848
)),
58215849
]),
58225850
];
@@ -5833,6 +5861,7 @@ public function provideCommentLikeDescriptions(): Iterator
58335861
false,
58345862
'$a',
58355863
PHP_EOL . '// this is a comment',
5864+
false,
58365865
)),
58375866
]),
58385867
];
@@ -5849,6 +5878,7 @@ public function provideCommentLikeDescriptions(): Iterator
58495878
false,
58505879
'$a',
58515880
PHP_EOL . PHP_EOL . '// this is a comment',
5881+
false,
58525882
)),
58535883
]),
58545884
];
@@ -6720,6 +6750,7 @@ public function provideDoctrineWithoutDoctrineCheckData(): Iterator
67206750
false,
67216751
'$z',
67226752
'@X()',
6753+
false,
67236754
)),
67246755
]),
67256756
];
@@ -6733,6 +6764,7 @@ public function provideDoctrineWithoutDoctrineCheckData(): Iterator
67336764
false,
67346765
'$z',
67356766
'@\X\Y()',
6767+
false,
67366768
)),
67376769
]),
67386770
];
@@ -6746,6 +6778,7 @@ public function provideDoctrineWithoutDoctrineCheckData(): Iterator
67466778
false,
67476779
'$z',
67486780
'@X',
6781+
false,
67496782
)),
67506783
]),
67516784
];
@@ -7198,8 +7231,8 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
71987231
' */',
71997232
new PhpDocNode([
72007233
new PhpDocTextNode('Real description'),
7201-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' paramA description')),
7202-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', PHP_EOL . ' paramB description')),
7234+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' paramA description', false)),
7235+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', PHP_EOL . ' paramB description', false)),
72037236
]),
72047237
];
72057238

@@ -7212,9 +7245,9 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
72127245
' */',
72137246
new PhpDocNode([
72147247
new PhpDocTextNode('Real description'),
7215-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '')),
7248+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '', false)),
72167249
new PhpDocTextNode(''),
7217-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', '')),
7250+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', '', false)),
72187251
]),
72197252
];
72207253

@@ -7228,7 +7261,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
72287261
' */',
72297262
new PhpDocNode([
72307263
new PhpDocTextNode('Real description'),
7231-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'aaaa' . PHP_EOL . ' bbbb' . PHP_EOL . PHP_EOL . 'ccc')),
7264+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'aaaa' . PHP_EOL . ' bbbb' . PHP_EOL . PHP_EOL . 'ccc', false)),
72327265
]),
72337266
];
72347267

@@ -7272,7 +7305,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
72727305
new PhpDocNode([
72737306
new PhpDocTextNode('Real description'),
72747307
new PhpDocTagNode('@ORM\Column', new DoctrineTagValueNode(new DoctrineAnnotation('@ORM\Column', []), 'aaaa' . PHP_EOL . ' bbbb' . PHP_EOL . PHP_EOL . 'ccc')),
7275-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', '')),
7308+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$b', '', false)),
72767309
]),
72777310
];
72787311

@@ -7285,7 +7318,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
72857318
' */',
72867319
new PhpDocNode([
72877320
new PhpDocTextNode('Real description'),
7288-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '')),
7321+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', '', false)),
72897322
new PhpDocTextNode(''),
72907323
new PhpDocTextNode(''),
72917324
]),
@@ -7301,7 +7334,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73017334
' */',
73027335
new PhpDocNode([
73037336
new PhpDocTextNode('Real description'),
7304-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . PHP_EOL . PHP_EOL . 'test')),
7337+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . PHP_EOL . PHP_EOL . 'test', false)),
73057338
]),
73067339
];
73077340

@@ -7313,7 +7346,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73137346
' */',
73147347
new PhpDocNode([
73157348
new PhpDocTextNode('Real description'),
7316-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'test')),
7349+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'test', false)),
73177350
new PhpDocTextNode(''),
73187351
]),
73197352
];
@@ -7327,7 +7360,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73277360
' */',
73287361
new PhpDocNode([
73297362
new PhpDocTextNode('Real description'),
7330-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'test')),
7363+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', 'test', false)),
73317364
new PhpDocTextNode(''),
73327365
new PhpDocTextNode(''),
73337366
]),
@@ -7343,7 +7376,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73437376
' */',
73447377
new PhpDocNode([
73457378
new PhpDocTextNode('Real description'),
7346-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test')),
7379+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test', false)),
73477380
new PhpDocTextNode(''),
73487381
new PhpDocTextNode(''),
73497382
]),
@@ -7360,7 +7393,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73607393
' */',
73617394
new PhpDocNode([
73627395
new PhpDocTextNode('Real description'),
7363-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test')),
7396+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test', false)),
73647397
new PhpDocTextNode(''),
73657398
new PhpDocTextNode(''),
73667399
new PhpDocTextNode(''),
@@ -7378,7 +7411,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73787411
' */',
73797412
new PhpDocNode([
73807413
new PhpDocTextNode('Real description'),
7381-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test' . PHP_EOL . PHP_EOL . 'test 2')),
7414+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test' . PHP_EOL . PHP_EOL . 'test 2', false)),
73827415
new PhpDocTextNode(''),
73837416
]),
73847417
];
@@ -7394,7 +7427,7 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
73947427
' */',
73957428
new PhpDocNode([
73967429
new PhpDocTextNode('Real description'),
7397-
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test' . PHP_EOL . PHP_EOL . 'test 2')),
7430+
new PhpDocTagNode('@param', new ParamTagValueNode(new IdentifierTypeNode('int'), false, '$a', PHP_EOL . ' test' . PHP_EOL . PHP_EOL . 'test 2', false)),
73987431
new PhpDocTextNode(''),
73997432
new PhpDocTextNode(''),
74007433
]),

0 commit comments

Comments
 (0)