@@ -581,7 +581,7 @@ class ApplicationLevelDto
581581 $ this ->assertCount (0 , $ violations );
582582 }
583583
584- public function test_it_parse_dependencies_in_docblocks (): void
584+ public function test_it_parse_dependencies_in_docblocks_customs (): void
585585 {
586586 $ code = <<< 'EOF'
587587<?php
@@ -649,17 +649,13 @@ public function test_should_implement_exact_classname(): void
649649 {
650650 $ code = <<< 'EOF'
651651<?php
652-
653652namespace Foo;
654-
655653interface Order
656654{
657655}
658-
659656interface OrderTwo
660657{
661658}
662-
663659class test implements Order
664660{
665661}
@@ -678,4 +674,34 @@ class test implements Order
678674
679675 $ this ->assertCount (0 , $ violations , $ violations ->toString ());
680676 }
677+
678+ public function test_it_parse_dependencies_in_docblocks_with_alias (): void
679+ {
680+ $ code = <<< 'EOF'
681+ <?php
682+ namespace MyProject\AppBundle\Application;
683+ use Symfony\Component\Validator\Constraints as Assert;
684+ use Symfony\Test;
685+ class ApplicationLevelDto
686+ {
687+ /**
688+ * @Assert\NotBlank
689+ */
690+ public string|null $foo;
691+ }
692+ EOF;
693+
694+ /** @var FileParser $fp */
695+ $ fp = FileParserFactory::createFileParser (TargetPhpVersion::create ('8.1 ' ));
696+ $ fp ->parse ($ code , 'relativePathName ' );
697+
698+ $ cd = $ fp ->getClassDescriptions ();
699+
700+ $ violations = new Violations ();
701+
702+ $ dependsOnTheseNamespaces = new DependsOnlyOnTheseNamespaces ('MyProject\AppBundle\Application ' );
703+ $ dependsOnTheseNamespaces ->evaluate ($ cd [0 ], $ violations , 'we want to add this rule for our software ' );
704+
705+ $ this ->assertCount (1 , $ violations );
706+ }
681707}
0 commit comments