forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-7369.php
More file actions
43 lines (35 loc) · 940 Bytes
/
bug-7369.php
File metadata and controls
43 lines (35 loc) · 940 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
42
43
<?php declare(strict_types=1);
namespace Bug7369;
interface AccountInterface {}
interface AccessResultInterface {
public function isAllowed(): bool;
}
interface AccessibleInterface {
/**
* @return ($return_as_object is true ? AccessResultInterface : bool)
*/
public function access(string $operation, AccountInterface $account = NULL, bool $return_as_object = FALSE);
}
$class = new class() implements AccessibleInterface {
/**
* {@inheritDoc}
*/
public function access(
string $operation,
AccountInterface $account = null,
bool $return_as_object = false
) {
if ($return_as_object) {
return new class () implements AccessResultInterface {
public function isAllowed(): bool {
return true;
}
};
}
return false;
}
};
$class->access('view', null, true)->isAllowed();
$class->access('view', null, false)->isAllowed();
$params = ['view', null, true];
$class->access(...$params)->isAllowed();