These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SESP\PropertyAnnotators; |
||
4 | |||
5 | use SMW\DIProperty; |
||
6 | use SMW\DIWikiPage; |
||
7 | use SMW\SemanticData; |
||
8 | use SMWDataItem as DataItem; |
||
9 | use SESP\PropertyAnnotator; |
||
10 | use SESP\AppFactory; |
||
11 | use Closure; |
||
12 | |||
13 | /** |
||
14 | * @private |
||
15 | * @ingroup SESP |
||
16 | * |
||
17 | * @license GNU GPL v2+ |
||
18 | * @since 2.0 |
||
19 | * |
||
20 | * @author mwjames |
||
21 | */ |
||
22 | class DispatchingPropertyAnnotator implements PropertyAnnotator { |
||
23 | |||
24 | /** |
||
25 | * @var AppFactory |
||
26 | */ |
||
27 | private $appFactory; |
||
28 | |||
29 | /** |
||
30 | * @var PropertyAnnotator[] |
||
31 | */ |
||
32 | private $propertyAnnotators = []; |
||
33 | |||
34 | /** |
||
35 | * @var PropertyAnnotator |
||
36 | */ |
||
37 | private $localPropertyAnnotator; |
||
38 | |||
39 | /** |
||
40 | * @since 2.0 |
||
41 | * |
||
42 | * @param AppFactory $appFactory |
||
43 | */ |
||
44 | 20 | public function __construct( AppFactory $appFactory ) { |
|
45 | 20 | $this->appFactory = $appFactory; |
|
46 | 20 | } |
|
47 | |||
48 | /** |
||
49 | * @since 2.0 |
||
50 | * |
||
51 | * {@inheritDoc} |
||
52 | */ |
||
53 | 1 | public function isAnnotatorFor( DIProperty $property ) { |
|
54 | 1 | return true; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @since 2.0 |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @param PropertyAnnotator $propertyAnnotator |
||
62 | */ |
||
63 | 1 | public function addPropertyAnnotator( $key, PropertyAnnotator $propertyAnnotator ) { |
|
64 | 1 | $this->propertyAnnotators[$key] = $propertyAnnotator; |
|
65 | 1 | } |
|
66 | |||
67 | /** |
||
68 | * @since 2.0 |
||
69 | * |
||
70 | * {@inheritDoc} |
||
71 | */ |
||
72 | 1 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
|
73 | 1 | $this->findPropertyAnnotator( $property )->addAnnotation( $property, $semanticData ); |
|
74 | 1 | } |
|
75 | |||
76 | /** |
||
77 | * @since 2.0 |
||
78 | * |
||
79 | * @param DIProperty $property |
||
80 | * |
||
81 | * @return PropertyAnnotator |
||
82 | */ |
||
83 | 18 | public function findPropertyAnnotator( DIProperty $property ) { |
|
84 | |||
85 | 18 | $key = $property->getKey(); |
|
86 | |||
87 | 18 | if ( $this->propertyAnnotators === [] ) { |
|
88 | 17 | $this->initDefaultPropertyAnnotators(); |
|
89 | 17 | } |
|
90 | |||
91 | 18 | if ( isset( $this->propertyAnnotators[$key] ) && is_callable( $this->propertyAnnotators[$key] ) ) { |
|
92 | 16 | return call_user_func( $this->propertyAnnotators[$key], $this->appFactory ); |
|
93 | 2 | } elseif( isset( $this->propertyAnnotators[$key] ) ) { |
|
94 | 1 | return $this->propertyAnnotators[$key]; |
|
95 | } |
||
96 | |||
97 | 1 | return new NullPropertyAnnotator(); |
|
98 | } |
||
99 | |||
100 | 17 | private function initDefaultPropertyAnnotators() { |
|
101 | |||
102 | // Encapsulate each instance to avoid direct instantiation for unused |
||
103 | // matches |
||
104 | 17 | $this->propertyAnnotators = [ |
|
0 ignored issues
–
show
|
|||
105 | |||
106 | CreatorPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
107 | 1 | return new CreatorPropertyAnnotator( $appFactory ); |
|
108 | 17 | }, |
|
109 | |||
110 | PageViewsPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
111 | 1 | return new PageViewsPropertyAnnotator( $appFactory ); |
|
112 | 17 | }, |
|
113 | |||
114 | ApprovedRevPropertyAnnotator::PROP_ID => function ( $appFactory ) { |
||
115 | return new ApprovedRevPropertyAnnotator( $appFactory ); |
||
116 | 17 | }, |
|
117 | |||
118 | ApprovedByPropertyAnnotator::PROP_ID => function ( $appFactory ) { |
||
119 | return new ApprovedByPropertyAnnotator( $appFactory ); |
||
120 | 17 | }, |
|
121 | |||
122 | ApprovedDatePropertyAnnotator::PROP_ID => function ( $appFactory ) { |
||
123 | return new ApprovedDatePropertyAnnotator( $appFactory ); |
||
124 | 17 | }, |
|
125 | |||
126 | ApprovedStatusPropertyAnnotator::PROP_ID => function ( $appFactory ) { |
||
127 | return new ApprovedStatusPropertyAnnotator( $appFactory ); |
||
128 | 17 | }, |
|
129 | |||
130 | UserRegistrationDatePropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
131 | 1 | return new UserRegistrationDatePropertyAnnotator( $appFactory ); |
|
132 | 17 | }, |
|
133 | |||
134 | UserEditCountPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
135 | 1 | return new UserEditCountPropertyAnnotator( $appFactory ); |
|
136 | 17 | }, |
|
137 | |||
138 | UserBlockPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
139 | 1 | return new UserBlockPropertyAnnotator( $appFactory ); |
|
140 | 17 | }, |
|
141 | |||
142 | UserRightPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
143 | 1 | return new UserRightPropertyAnnotator( $appFactory ); |
|
144 | 17 | }, |
|
145 | |||
146 | UserGroupPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
147 | 1 | return new UserGroupPropertyAnnotator( $appFactory ); |
|
148 | 17 | }, |
|
149 | |||
150 | PageIDPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
151 | 1 | return new PageIDPropertyAnnotator( $appFactory ); |
|
152 | 17 | }, |
|
153 | |||
154 | PageLengthPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
155 | 1 | return new PageLengthPropertyAnnotator( $appFactory ); |
|
156 | 17 | }, |
|
157 | |||
158 | RevisionIDPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
159 | 1 | return new RevisionIDPropertyAnnotator( $appFactory ); |
|
160 | 17 | }, |
|
161 | |||
162 | PageNumRevisionPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
163 | 1 | return new PageNumRevisionPropertyAnnotator( $appFactory ); |
|
164 | 17 | }, |
|
165 | |||
166 | TalkPageNumRevisionPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
167 | 1 | return new TalkPageNumRevisionPropertyAnnotator( $appFactory ); |
|
168 | 17 | }, |
|
169 | |||
170 | PageContributorsPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
171 | 1 | return new PageContributorsPropertyAnnotator( $appFactory ); |
|
172 | 17 | }, |
|
173 | |||
174 | SubPagePropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
175 | 1 | return new SubPagePropertyAnnotator( $appFactory ); |
|
176 | 17 | }, |
|
177 | |||
178 | ShortUrlPropertyAnnotator::PROP_ID => function( $appFactory ) { |
||
179 | 1 | return new ShortUrlPropertyAnnotator( $appFactory ); |
|
180 | 17 | }, |
|
181 | |||
182 | 17 | ExifPropertyAnnotator::PROP_ID => function( $appFactory ) { |
|
183 | 1 | return new ExifPropertyAnnotator( $appFactory ); |
|
184 | 17 | }, |
|
185 | |||
186 | ]; |
||
187 | 17 | } |
|
188 | |||
189 | } |
||
190 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..