File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace mglaman \PHPStanDrupal \Tests \Type ;
6
+
7
+ use mglaman \PHPStanDrupal \Tests \AdditionalConfigFilesTrait ;
8
+ use PHPStan \Testing \TypeInferenceTestCase ;
9
+
10
+ final class EntityDynamicReturnTypeTest extends TypeInferenceTestCase
11
+ {
12
+ use AdditionalConfigFilesTrait;
13
+
14
+ public function dataFileAsserts (): iterable
15
+ {
16
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/entity.php ' );
17
+ }
18
+
19
+ /**
20
+ * @dataProvider dataFileAsserts
21
+ * @param string $assertType
22
+ * @param string $file
23
+ * @param mixed ...$args
24
+ */
25
+ public function testFileAsserts (
26
+ string $ assertType ,
27
+ string $ file ,
28
+ ...$ args
29
+ ): void
30
+ {
31
+ $ this ->assertFileAsserts ($ assertType , $ file , ...$ args );
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DrupalEntity ;
4
+
5
+ use Drupal \node \Entity \Node ;
6
+ use function PHPStan \Testing \assertType ;
7
+
8
+ assertType ('Drupal\node\Entity\Node ' , $ node = Node::create (['type ' => 'page ' , 'title ' => 'foo ' ]));
9
+ assertType ('Drupal\node\Entity\Node ' , $ node ->createDuplicate ());
10
+ assertType ('Drupal\node\Entity\Node ' , $ node ->enforceIsNew ());
11
+ assertType ('Drupal\node\Entity\Node ' , $ node ->enforceIsNew (TRUE ));
12
+ assertType ('Drupal\node\Entity\Node ' , $ node ->enforceIsNew (FALSE ));
13
+ assertType ('Drupal\node\Entity\Node ' , $ node ->setOriginalId (42 ));
14
+ assertType ('Drupal\node\Entity\Node ' , $ node ->setOriginalId ('42 ' ));
15
+ assertType ('Drupal\node\Entity\Node ' , $ node ->setOriginalId (NULL ));
16
+ assertType ('Drupal\node\Entity\Node|null ' , Node::load (42 ));
17
+ assertType ('Drupal\node\Entity\Node|null ' , Node::load ('42 ' ));
18
+ assertType ('array<Drupal\node\Entity\Node> ' , Node::loadMultiple ([42 , 29 ]));
19
+ assertType ('array<Drupal\node\Entity\Node> ' , Node::loadMultiple (['42 ' , '29 ' ]));
20
+ assertType ('array<Drupal\node\Entity\Node> ' , Node::loadMultiple (NULL ));
You can’t perform that action at this time.
0 commit comments