44
55use PHPStan \PhpDocParser \Ast \ConstExpr \ConstExprArrayNode ;
66use PHPStan \PhpDocParser \Ast \ConstExpr \ConstExprIntegerNode ;
7+ use PHPStan \PhpDocParser \Ast \PhpDoc \DeprecatedTagValueNode ;
78use PHPStan \PhpDocParser \Ast \PhpDoc \GenericTagValueNode ;
89use PHPStan \PhpDocParser \Ast \PhpDoc \InvalidTagValueNode ;
910use PHPStan \PhpDocParser \Ast \PhpDoc \MethodTagValueNode ;
@@ -43,6 +44,7 @@ protected function setUp(): void
4344 * @dataProvider provideVarTagsData
4445 * @dataProvider provideReturnTagsData
4546 * @dataProvider provideThrowsTagsData
47+ * @dataProvider provideDeprecatedTagsData
4648 * @dataProvider providePropertyTagsData
4749 * @dataProvider provideMethodTagsData
4850 * @dataProvider provideSingleLinePhpDocData
@@ -967,6 +969,47 @@ public function provideThrowsTagsData(): \Iterator
967969 ];
968970 }
969971
972+ public function provideDeprecatedTagsData (): \Iterator
973+ {
974+ yield [
975+ 'OK with no description ' ,
976+ '/** @deprecated */ ' ,
977+ new PhpDocNode ([
978+ new PhpDocTagNode (
979+ '@deprecated ' ,
980+ new DeprecatedTagValueNode ()
981+ ),
982+ ]),
983+ ];
984+
985+ yield [
986+ 'OK with simple description description ' ,
987+ '/** @deprecated text string */ ' ,
988+ new PhpDocNode ([
989+ new PhpDocTagNode (
990+ '@deprecated ' ,
991+ new DeprecatedTagValueNode ('text string ' )
992+ ),
993+ ]),
994+ ];
995+
996+ yield [
997+ 'OK with long descriptions ' ,
998+ '/** @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
999+ * Drupal 9 there will be no way to set the status and in Drupal 8 this
1000+ * ability has been removed because mb_*() functions are supplied using
1001+ * Symfony \'s polyfill. */ ' ,
1002+ new PhpDocNode ([
1003+ new PhpDocTagNode (
1004+ '@deprecated ' ,
1005+ new DeprecatedTagValueNode ('in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In ' )
1006+ ),
1007+ new PhpDocTextNode ('Drupal 9 there will be no way to set the status and in Drupal 8 this ' ),
1008+ new PhpDocTextNode ('ability has been removed because mb_*() functions are supplied using ' ),
1009+ new PhpDocTextNode ('Symfony \'s polyfill. ' ),
1010+ ]),
1011+ ];
1012+ }
9701013
9711014 public function provideMethodTagsData (): \Iterator
9721015 {
@@ -1437,9 +1480,9 @@ public function provideMultiLinePhpDocData(): array
14371480 [
14381481 'multi-line with two tags ' ,
14391482 '/**
1440- * @param Foo $foo 1st multi world description
1441- * @param Bar $bar 2nd multi world description
1442- */ ' ,
1483+ * @param Foo $foo 1st multi world description
1484+ * @param Bar $bar 2nd multi world description
1485+ */ ' ,
14431486 new PhpDocNode ([
14441487 new PhpDocTagNode (
14451488 '@param ' ,
@@ -1464,10 +1507,10 @@ public function provideMultiLinePhpDocData(): array
14641507 [
14651508 'multi-line with two tags and text in the middle ' ,
14661509 '/**
1467- * @param Foo $foo 1st multi world description
1468- * some text in the middle
1469- * @param Bar $bar 2nd multi world description
1470- */ ' ,
1510+ * @param Foo $foo 1st multi world description
1511+ * some text in the middle
1512+ * @param Bar $bar 2nd multi world description
1513+ */ ' ,
14711514 new PhpDocNode ([
14721515 new PhpDocTagNode (
14731516 '@param ' ,
@@ -1493,18 +1536,18 @@ public function provideMultiLinePhpDocData(): array
14931536 [
14941537 'multi-line with two tags, text in the middle and some empty lines ' ,
14951538 '/**
1496- *
1497- *
1498- * @param Foo $foo 1st multi world description
1499- *
1500- *
1501- * some text in the middle
1502- *
1503- *
1504- * @param Bar $bar 2nd multi world description
1505- *
1506- *
1507- */ ' ,
1539+ *
1540+ *
1541+ * @param Foo $foo 1st multi world description
1542+ *
1543+ *
1544+ * some text in the middle
1545+ *
1546+ *
1547+ * @param Bar $bar 2nd multi world description
1548+ *
1549+ *
1550+ */ ' ,
15081551 new PhpDocNode ([
15091552 new PhpDocTextNode ('' ),
15101553 new PhpDocTextNode ('' ),
@@ -1538,9 +1581,9 @@ public function provideMultiLinePhpDocData(): array
15381581 [
15391582 'multi-line with just empty lines ' ,
15401583 '/**
1541- *
1542- *
1543- */ ' ,
1584+ *
1585+ *
1586+ */ ' ,
15441587 new PhpDocNode ([
15451588 new PhpDocTextNode ('' ),
15461589 new PhpDocTextNode ('' ),
@@ -1549,9 +1592,9 @@ public function provideMultiLinePhpDocData(): array
15491592 [
15501593 'multi-line with tag mentioned as part of text node ' ,
15511594 '/**
1552- * Lets talk about @param
1553- * @param int $foo @param string $bar
1554- */ ' ,
1595+ * Lets talk about @param
1596+ * @param int $foo @param string $bar
1597+ */ ' ,
15551598 new PhpDocNode ([
15561599 new PhpDocTextNode ('Lets talk about @param ' ),
15571600 new PhpDocTagNode (
@@ -1568,44 +1611,44 @@ public function provideMultiLinePhpDocData(): array
15681611 [
15691612 'multi-line with a lot of @method tags ' ,
15701613 '/**
1571- * @method int getInteger(int $a, int $b)
1572- * @method void doSomething(int $a, $b)
1573- * @method self|Bar getFooOrBar()
1574- * @method methodWithNoReturnType()
1575- * @method static int getIntegerStatically(int $a, int $b)
1576- * @method static void doSomethingStatically(int $a, $b)
1577- * @method static self|Bar getFooOrBarStatically()
1578- * @method static methodWithNoReturnTypeStatically()
1579- * @method int getIntegerWithDescription(int $a, int $b) Get an integer with a description.
1580- * @method void doSomethingWithDescription(int $a, $b) Do something with a description.
1581- * @method self|Bar getFooOrBarWithDescription() Get a Foo or a Bar with a description.
1582- * @method methodWithNoReturnTypeWithDescription() Do something with a description but what, who knows!
1583- * @method static int getIntegerStaticallyWithDescription(int $a, int $b) Get an integer with a description statically.
1584- * @method static void doSomethingStaticallyWithDescription(int $a, $b) Do something with a description statically.
1585- * @method static self|Bar getFooOrBarStaticallyWithDescription() Get a Foo or a Bar with a description statically.
1586- * @method static methodWithNoReturnTypeStaticallyWithDescription() Do something with a description statically, but what, who knows!
1587- * @method static bool aStaticMethodThatHasAUniqueReturnTypeInThisClass()
1588- * @method static string aStaticMethodThatHasAUniqueReturnTypeInThisClassWithDescription() A Description.
1589- * @method int getIntegerNoParams()
1590- * @method void doSomethingNoParams()
1591- * @method self|Bar getFooOrBarNoParams()
1592- * @method methodWithNoReturnTypeNoParams()
1593- * @method static int getIntegerStaticallyNoParams()
1594- * @method static void doSomethingStaticallyNoParams()
1595- * @method static self|Bar getFooOrBarStaticallyNoParams()
1596- * @method static methodWithNoReturnTypeStaticallyNoParams()
1597- * @method int getIntegerWithDescriptionNoParams() Get an integer with a description.
1598- * @method void doSomethingWithDescriptionNoParams() Do something with a description.
1599- * @method self|Bar getFooOrBarWithDescriptionNoParams() Get a Foo or a Bar with a description.
1600- * @method static int getIntegerStaticallyWithDescriptionNoParams() Get an integer with a description statically.
1601- * @method static void doSomethingStaticallyWithDescriptionNoParams() Do something with a description statically.
1602- * @method static self|Bar getFooOrBarStaticallyWithDescriptionNoParams() Get a Foo or a Bar with a description statically.
1603- * @method static bool|string aStaticMethodThatHasAUniqueReturnTypeInThisClassNoParams()
1604- * @method static string|float aStaticMethodThatHasAUniqueReturnTypeInThisClassWithDescriptionNoParams() A Description.
1605- * @method \Aws\Result publish(array $args)
1606- * @method Image rotate(float & ... $angle = array(), $backgroundColor)
1607- * @method Foo overridenMethod()
1608- */ ' ,
1614+ * @method int getInteger(int $a, int $b)
1615+ * @method void doSomething(int $a, $b)
1616+ * @method self|Bar getFooOrBar()
1617+ * @method methodWithNoReturnType()
1618+ * @method static int getIntegerStatically(int $a, int $b)
1619+ * @method static void doSomethingStatically(int $a, $b)
1620+ * @method static self|Bar getFooOrBarStatically()
1621+ * @method static methodWithNoReturnTypeStatically()
1622+ * @method int getIntegerWithDescription(int $a, int $b) Get an integer with a description.
1623+ * @method void doSomethingWithDescription(int $a, $b) Do something with a description.
1624+ * @method self|Bar getFooOrBarWithDescription() Get a Foo or a Bar with a description.
1625+ * @method methodWithNoReturnTypeWithDescription() Do something with a description but what, who knows!
1626+ * @method static int getIntegerStaticallyWithDescription(int $a, int $b) Get an integer with a description statically.
1627+ * @method static void doSomethingStaticallyWithDescription(int $a, $b) Do something with a description statically.
1628+ * @method static self|Bar getFooOrBarStaticallyWithDescription() Get a Foo or a Bar with a description statically.
1629+ * @method static methodWithNoReturnTypeStaticallyWithDescription() Do something with a description statically, but what, who knows!
1630+ * @method static bool aStaticMethodThatHasAUniqueReturnTypeInThisClass()
1631+ * @method static string aStaticMethodThatHasAUniqueReturnTypeInThisClassWithDescription() A Description.
1632+ * @method int getIntegerNoParams()
1633+ * @method void doSomethingNoParams()
1634+ * @method self|Bar getFooOrBarNoParams()
1635+ * @method methodWithNoReturnTypeNoParams()
1636+ * @method static int getIntegerStaticallyNoParams()
1637+ * @method static void doSomethingStaticallyNoParams()
1638+ * @method static self|Bar getFooOrBarStaticallyNoParams()
1639+ * @method static methodWithNoReturnTypeStaticallyNoParams()
1640+ * @method int getIntegerWithDescriptionNoParams() Get an integer with a description.
1641+ * @method void doSomethingWithDescriptionNoParams() Do something with a description.
1642+ * @method self|Bar getFooOrBarWithDescriptionNoParams() Get a Foo or a Bar with a description.
1643+ * @method static int getIntegerStaticallyWithDescriptionNoParams() Get an integer with a description statically.
1644+ * @method static void doSomethingStaticallyWithDescriptionNoParams() Do something with a description statically.
1645+ * @method static self|Bar getFooOrBarStaticallyWithDescriptionNoParams() Get a Foo or a Bar with a description statically.
1646+ * @method static bool|string aStaticMethodThatHasAUniqueReturnTypeInThisClassNoParams()
1647+ * @method static string|float aStaticMethodThatHasAUniqueReturnTypeInThisClassWithDescriptionNoParams() A Description.
1648+ * @method \Aws\Result publish(array $args)
1649+ * @method Image rotate(float & ... $angle = array(), $backgroundColor)
1650+ * @method Foo overridenMethod()
1651+ */ ' ,
16091652 new PhpDocNode ([
16101653 new PhpDocTagNode (
16111654 '@method ' ,
0 commit comments