File tree Expand file tree Collapse file tree 7 files changed +126
-81
lines changed Expand file tree Collapse file tree 7 files changed +126
-81
lines changed Original file line number Diff line number Diff line change 5
5
use mglaman \PHPStanDrupal \Drupal \EntityDataRepository ;
6
6
use mglaman \PHPStanDrupal \Type \EntityQuery \ConfigEntityQueryType ;
7
7
use mglaman \PHPStanDrupal \Type \EntityQuery \ContentEntityQueryType ;
8
+ use mglaman \PHPStanDrupal \Type \EntityQuery \EntityQueryType ;
8
9
use mglaman \PHPStanDrupal \Type \EntityStorage \ConfigEntityStorageType ;
9
10
use mglaman \PHPStanDrupal \Type \EntityStorage \ContentEntityStorageType ;
10
11
use PhpParser \Node \Expr \StaticCall ;
@@ -80,6 +81,10 @@ public function getTypeFromStaticMethodCall(
80
81
);
81
82
}
82
83
83
- return $ returnType ;
84
+ return new EntityQueryType (
85
+ $ returnType ->getClassName (),
86
+ $ returnType ->getSubtractedType (),
87
+ $ returnType ->getClassReflection ()
88
+ );
84
89
}
85
90
}
Original file line number Diff line number Diff line change @@ -49,8 +49,8 @@ public function cases(): \Generator
49
49
[__DIR__ . '/data/bug-438.php ' ],
50
50
[]
51
51
];
52
- yield 'bug-396a .php ' => [
53
- [__DIR__ .'/data/bug-396a .php ' ],
52
+ yield 'bug-396a1 .php ' => [
53
+ [__DIR__ .'/data/bug-396a1 .php ' ],
54
54
[
55
55
[
56
56
'Missing explicit access check on entity query. ' ,
@@ -59,6 +59,14 @@ public function cases(): \Generator
59
59
]
60
60
]
61
61
];
62
+ yield 'bug-396a2.php ' => [
63
+ [__DIR__ . '/data/bug-396a2.php ' ],
64
+ []
65
+ ];
66
+ yield 'bug-396a3.php ' => [
67
+ [__DIR__ . '/data/bug-396a3.php ' ],
68
+ []
69
+ ];
62
70
yield 'bug-396b.php ' => [
63
71
[__DIR__ . '/data/bug-396b.php ' ],
64
72
[]
@@ -67,5 +75,9 @@ public function cases(): \Generator
67
75
[__DIR__ . '/data/bug-396c.php ' ],
68
76
[]
69
77
];
78
+ yield 'bug-437.php ' => [
79
+ [__DIR__ . '/data/bug-437.php ' ],
80
+ []
81
+ ];
70
82
}
71
83
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug396a ;
4
+
5
+ function foo () {
6
+ $ query = \Drupal::entityQuery ('user ' )
7
+ ->condition ('status ' , 1 )
8
+ ->condition ('uid ' , 1 , '<> ' )
9
+ ->condition ('field_profile_visibility ' , 1 )
10
+ ->condition ('field_account_type ' , '' , '<> ' )
11
+ ->condition ('field_last_name.value ' , '' , '<> ' );
12
+ if ( isset ($ qparam ['expertise ' ]) && !empty ($ qparam ['expertise ' ]) ) {
13
+ $ query ->condition ('field_field_expertise.entity.tid ' , $ qparam ['expertise ' ]);
14
+ }
15
+ if ( isset ($ qparam ['origin ' ]) && !empty ($ qparam ['origin ' ]) ) {
16
+ $ query ->condition ('field_place_origin.entity:taxonomy_term.field_country_tags ' , $ qparam ['origin ' ]);
17
+ }
18
+ if ( isset ($ qparam ['place_residence ' ]) && !empty ($ qparam ['place_residence ' ]) ) {
19
+ $ query ->condition ('field_place_residence.entity:taxonomy_term.field_country_tags ' , $ qparam ['place_residence ' ]);
20
+ }
21
+ if ( isset ($ qparam ['city ' ]) && !empty ($ qparam ['city ' ]) ) {
22
+ $ query ->condition ('field_city ' , $ qparam ['city ' ], 'CONTAINS ' );
23
+ }
24
+ if ( isset ($ qparam ['user_type ' ]) && !empty ($ qparam ['user_type ' ]) ) {
25
+ $ query ->condition ('field_account_type.entity.tid ' , $ qparam ['user_type ' ]);
26
+ }
27
+ $ users = $ query ->execute ();
28
+ };
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug396a ;
4
+
5
+ function bar () {
6
+ $ query = \Drupal::entityQuery ('user ' )
7
+ ->accessCheck (FALSE )
8
+ ->condition ('status ' , 1 )
9
+ ->condition ('uid ' , 1 , '<> ' )
10
+ ->condition ('field_profile_visibility ' , 1 )
11
+ ->condition ('field_account_type ' , '' , '<> ' )
12
+ ->condition ('field_last_name.value ' , '' , '<> ' );
13
+ if ( isset ($ qparam ['expertise ' ]) && !empty ($ qparam ['expertise ' ]) ) {
14
+ $ query ->condition ('field_field_expertise.entity.tid ' , $ qparam ['expertise ' ]);
15
+ }
16
+ if ( isset ($ qparam ['origin ' ]) && !empty ($ qparam ['origin ' ]) ) {
17
+ $ query ->condition ('field_place_origin.entity:taxonomy_term.field_country_tags ' , $ qparam ['origin ' ]);
18
+ }
19
+ if ( isset ($ qparam ['place_residence ' ]) && !empty ($ qparam ['place_residence ' ]) ) {
20
+ $ query ->condition ('field_place_residence.entity:taxonomy_term.field_country_tags ' , $ qparam ['place_residence ' ]);
21
+ }
22
+ if ( isset ($ qparam ['city ' ]) && !empty ($ qparam ['city ' ]) ) {
23
+ $ query ->condition ('field_city ' , $ qparam ['city ' ], 'CONTAINS ' );
24
+ }
25
+ if ( isset ($ qparam ['user_type ' ]) && !empty ($ qparam ['user_type ' ]) ) {
26
+ $ query ->condition ('field_account_type.entity.tid ' , $ qparam ['user_type ' ]);
27
+ }
28
+ $ users = $ query ->execute ();
29
+ };
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug396a ;
4
+
5
+ function baz () {
6
+ $ query = \Drupal::entityQuery ('user ' )
7
+ ->condition ('status ' , 1 )
8
+ ->condition ('uid ' , 1 , '<> ' )
9
+ ->condition ('field_profile_visibility ' , 1 )
10
+ ->condition ('field_account_type ' , '' , '<> ' )
11
+ ->condition ('field_last_name.value ' , '' , '<> ' );
12
+ if ( isset ($ qparam ['expertise ' ]) && !empty ($ qparam ['expertise ' ]) ) {
13
+ $ query ->condition ('field_field_expertise.entity.tid ' , $ qparam ['expertise ' ]);
14
+ }
15
+ if ( isset ($ qparam ['origin ' ]) && !empty ($ qparam ['origin ' ]) ) {
16
+ $ query ->condition ('field_place_origin.entity:taxonomy_term.field_country_tags ' , $ qparam ['origin ' ]);
17
+ }
18
+ if ( isset ($ qparam ['place_residence ' ]) && !empty ($ qparam ['place_residence ' ]) ) {
19
+ $ query ->condition ('field_place_residence.entity:taxonomy_term.field_country_tags ' , $ qparam ['place_residence ' ]);
20
+ }
21
+ if ( isset ($ qparam ['city ' ]) && !empty ($ qparam ['city ' ]) ) {
22
+ $ query ->condition ('field_city ' , $ qparam ['city ' ], 'CONTAINS ' );
23
+ }
24
+ if ( isset ($ qparam ['user_type ' ]) && !empty ($ qparam ['user_type ' ]) ) {
25
+ $ query ->condition ('field_account_type.entity.tid ' , $ qparam ['user_type ' ]);
26
+ }
27
+ $ query ->accessCheck (FALSE );
28
+ $ users = $ query ->execute ();
29
+ };
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug437 ;
4
+
5
+ use Drupal \Core \Entity \EntityTypeManagerInterface ;
6
+ use Drupal \Core \Entity \Query \QueryInterface ;
7
+
8
+ final class Foo {
9
+ private QueryInterface $ vocabularyQuery ;
10
+ public function __construct (EntityTypeManagerInterface $ entityTypeManager )
11
+ {
12
+ $ this ->vocabularyQuery = $ entityTypeManager
13
+ ->getStorage ('taxonomy_term ' )
14
+ ->getQuery ()
15
+ ->accessCheck (TRUE );
16
+ }
17
+ public function a (): int {
18
+ return $ this ->vocabularyQuery ->count ()->execute ();
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments