forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallableParametersAcceptor.php
More file actions
63 lines (51 loc) · 1.87 KB
/
CallableParametersAcceptor.php
File metadata and controls
63 lines (51 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php declare(strict_types = 1);
namespace PHPStan\Reflection\Callables;
use PHPStan\Node\InvalidateExprNode;
use PHPStan\Reflection\Assertions;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\TrinaryLogic;
/**
* A ParametersAcceptor for callable types (closures, first-class callables).
*
* Extends ParametersAcceptor with information about side effects, exceptions,
* and other runtime behavior of callable values. This is what PHPStan knows
* about a closure or callable when it's passed as a parameter or stored in a variable.
*
* Implemented by ClosureType and used as the return type of
* Type::getCallableParametersAcceptors().
*
* Provides:
* - Throw points (what exceptions the callable may throw)
* - Impure points (what side effects the callable may have)
* - Purity information
* - Variables captured from outer scope (used variables)
* - Expressions that are invalidated by calling this callable
*
* @api
* @api-do-not-implement
*/
interface CallableParametersAcceptor extends ParametersAcceptor
{
/** @return SimpleThrowPoint[] */
public function getThrowPoints(): array;
public function isPure(): TrinaryLogic;
public function acceptsNamedArguments(): TrinaryLogic;
/** @return SimpleImpurePoint[] */
public function getImpurePoints(): array;
/**
* Tracks when calling a closure invalidates cached type information
* for variables it captures by reference.
*
* @return InvalidateExprNode[]
*/
public function getInvalidateExpressions(): array;
/** @return string[] */
public function getUsedVariables(): array;
/**
* Whether the callable is marked with the `#[\NoDiscard]` attribute.
* On PHP 8.5+ if the return value is unused at runtime, a warning is emitted.
* PHPStan reports this during analysis regardless of PHP version.
*/
public function mustUseReturnValue(): TrinaryLogic;
public function getAsserts(): Assertions;
}