File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -174,3 +174,43 @@ parameters:
174
174
```
175
175
176
176
To add support for custom entities, you may add the same definition in your project's ` phpstan.neon ` likewise.
177
+
178
+ ### Providing entity type mappings for a contrib module
179
+
180
+ Contributed modules can provide their own mapping that can be automatically registered with a user's code base when
181
+ they use the ` phpstan/extension-installer ` . The extension installer scans installed package's ` composer.json ` for a
182
+ value in ` extra.phpstan ` . This will automatically bundle the defined include that contains an entity mapping
183
+ configuration.
184
+
185
+ For example, the Paragraphs module could have the following ` entity_mapping.neon ` file:
186
+
187
+ ``` neon
188
+ parameters:
189
+ entityMapping:
190
+ paragraph:
191
+ class: Drupal\paragraphs\Entity\Paragraph
192
+ paragraphs_type:
193
+ class: Drupal\paragraphs\Entity\ParagraphsType
194
+ ```
195
+
196
+ Then in the ` composer.json ` for Paragraphs, the ` entity_mapping.neon ` would be provided as a PHPStan include
197
+
198
+ ``` json
199
+ {
200
+ "name" : " drupal/paragraphs" ,
201
+ "description" : " Enables the creation of Paragraphs entities." ,
202
+ "type" : " drupal-module" ,
203
+ "license" : " GPL-2.0-or-later" ,
204
+ "require" : {
205
+ "drupal/entity_reference_revisions" : " ~1.3"
206
+ },
207
+ "extra" : {
208
+ "phpstan" : {
209
+ "includes" : [
210
+ " entity_mapping.neon"
211
+ ]
212
+ }
213
+ }
214
+ }
215
+
216
+ ```
You can’t perform that action at this time.
0 commit comments