-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathbug-757.php
More file actions
41 lines (32 loc) · 827 Bytes
/
bug-757.php
File metadata and controls
41 lines (32 loc) · 827 Bytes
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
<?php
namespace Bug757;
class A {
/** @var string */
public $foo = "bar";
public function &getString() : string {
return $this->foo;
}
public function getStringNoRef() : string {
return $this->foo;
}
public static function &staticGetString() : string {
static $s = "bar";
return $s;
}
}
function &refFunction() : string {
static $s = "bar";
return $s;
}
function noRefFunction() : string {
return "bar";
}
function useString(string &$s) : void {}
function () {
$a = new A();
useString($a->getString()); // ok - returns by reference
useString($a->getStringNoRef()); // error - does not return by reference
useString(A::staticGetString()); // ok - returns by reference
useString(refFunction()); // ok - returns by reference
useString(noRefFunction()); // error - does not return by reference
};