1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Piotzkhider\FirebaseAuthenticationModule; |
6
|
|
|
|
7
|
|
|
use BEAR\Resource\ResourceObject; |
8
|
|
|
use Kreait\Firebase\Auth as FirebaseAuth; |
9
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Authenticate; |
10
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Extractors; |
11
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Extractor\AuthorizationHeaderTokenExtractor; |
12
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Extractor\TokenExtractorResolver; |
13
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Firebase\FirebaseAuthProvider; |
14
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Guard\Authenticator; |
15
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Guard\AuthenticatorInterface; |
16
|
|
|
use Piotzkhider\FirebaseAuthenticationModule\Interceptor\AuthenticationInterceptor; |
17
|
|
|
use Piotzkhider\FirebaseModule\FirebaseModule; |
18
|
|
|
use Ray\AuraWebModule\AuraWebModule; |
19
|
|
|
use Ray\Di\AbstractModule; |
20
|
|
|
use Ray\Di\AssistedModule; |
21
|
|
|
use Ray\Di\Scope; |
22
|
|
|
|
23
|
|
|
class FirebaseAuthenticationModule extends AbstractModule |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var mixed |
27
|
|
|
*/ |
28
|
|
|
private $credentials; |
29
|
|
|
|
30
|
2 |
|
public function __construct($credentials, AbstractModule $module = null) |
31
|
|
|
{ |
32
|
2 |
|
$this->credentials = $credentials; |
33
|
2 |
|
parent::__construct($module); |
34
|
2 |
|
} |
35
|
|
|
|
36
|
2 |
|
protected function configure(): void |
37
|
|
|
{ |
38
|
2 |
|
$this->install(new AssistedModule()); |
|
|
|
|
39
|
2 |
|
$this->install(new AuraWebModule()); |
|
|
|
|
40
|
2 |
|
$this->install(new FirebaseModule($this->credentials)); |
|
|
|
|
41
|
|
|
|
42
|
2 |
|
$this->bind(FirebaseAuth::class)->toProvider(FirebaseAuthProvider::class)->in(Scope::SINGLETON); |
43
|
2 |
|
$this->bind(AuthInterface::class)->to(Auth::class)->in(Scope::SINGLETON); |
44
|
2 |
|
$this->bind()->annotatedWith(Extractors::class)->toInstance([ |
45
|
2 |
|
new AuthorizationHeaderTokenExtractor(), |
46
|
|
|
]); |
47
|
2 |
|
$this->bind(TokenExtractorResolver::class)->in(Scope::SINGLETON); |
48
|
2 |
|
$this->bind(AuthenticatorInterface::class)->to(Authenticator::class)->in(Scope::SINGLETON); |
49
|
2 |
|
$this->bindInterceptor( |
50
|
2 |
|
$this->matcher->subclassesOf(ResourceObject::class), |
51
|
2 |
|
$this->matcher->annotatedWith(Authenticate::class), |
52
|
2 |
|
[AuthenticationInterceptor::class] |
53
|
|
|
); |
54
|
2 |
|
} |
55
|
|
|
} |
56
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: