forked from phan/phan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0264_closure_override_context.php
81 lines (73 loc) · 2.18 KB
/
0264_closure_override_context.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace NS264;
class BoundClass264 {
/** @var string $b */
protected $b = 'a';
/** @var string $b */
public $c = 'a';
protected static function a_static_method() { }
}
class TestFramework {
/** @var string */
protected $_frameworkProperty = 'value';
public function mockA() : string { // mockA() is buggy, it didn't return anything.
// BoundClass264::a_static_method(); // What? This should emit an issue.
/**
* blank, should be ignored?
* @phan-closure-scope
*/
$w = function() : string {
// BoundClass264::a_static_method(); // should emit an issue?
return $this->_frameworkProperty;
};
/**
* @phan-closure-scope BoundClass264
*/
$x = function() : string {
BoundClass264::a_static_method();
self::a_static_method();
return $this->b . $this->c;
};
/**
* @phan-closure-scope \NS264\BoundClass264
*/
$y = function() : string {
BoundClass264::a_static_method();
self::a_static_method();
return $this->b . $this->d;
};
/**
* BoundClass264 scope of a native type(string, array, object, bool, etc.) makes no sense. Phan should warn.
* @phan-closure-scope string
*/
$z = function() : string {
return $this->b . $this->d;
};
$prefix = 'NotExplicitlyUsed';
$suffix = 'Suf';
/**
* BoundClass264 scope of a native type(string, array, object, bool, etc.) makes no sense. Phan should warn.
* @phan-closure-scope BoundClass264
*/
$a = function() use($suffix) : string {
$str = $prefix;
$str .= $this->b;
$str .= $suffix;
return $str;
};
/**
* @phan-closure-scope UndeclaredClass264
*/
$b = function() use($suffix) : string {
$str = $this->b;
$str .= $suffix;
return $str;
};
}
}
/**
* @phan-closure-scope BoundClass264
*/
$global264 = function() : string {
return $this->b . $this->undefVar;
};