You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/annotating_code/supported_annotations.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,9 +202,10 @@ takesFoo(getFoo());
202
202
203
203
This provides the same, but for `false`. Psalm uses this internally for functions like `preg_replace`, which can return false if the given input has encoding errors, but where 99.9% of the time the function operates as expected.
If you have a magic property getter/setter, you can use `@psalm-seal-properties` to instruct Psalm to disallow getting and setting any properties not contained in a list of `@property` (or `@property-read`/`@property-write`) annotations.
208
+
This is automatically enabled with the configuration option `sealAllProperties` and can be disabled for a class with `@psalm-no-seal-properties`
If you have a magic method caller, you can use `@psalm-seal-methods` to instruct Psalm to disallow calling any methods not contained in a list of `@method` annotations.
233
+
This is automatically enabled with the configuration option `sealAllMethods` and can be disabled for a class with `@psalm-no-seal-methods`
234
+
235
+
```php
236
+
<?php
237
+
/**
238
+
* @method foo(): string
239
+
* @psalm-seal-methods
240
+
*/
241
+
class A {
242
+
public function __call(string $name, array $args) {
243
+
if ($name === "foo") {
244
+
return "hello";
245
+
}
246
+
}
247
+
}
248
+
249
+
$a = new A();
250
+
$b = $a->bar(); // this call fails
251
+
```
252
+
229
253
### `@psalm-internal`
230
254
231
255
Used to mark a class, property or function as internal to a given namespace. Psalm treats this slightly differently to
0 commit comments