Skip to content

Commit 3bce05c

Browse files
committed
🚿 constructor promotion with docblocks makes me wanna stab my eyes out
1 parent 2bddabd commit 3bce05c

File tree

3 files changed

+81
-25
lines changed

3 files changed

+81
-25
lines changed

src/Core/OAuthProvider.php

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,41 @@
3636
*/
3737
abstract class OAuthProvider implements OAuthInterface{
3838

39+
/**
40+
* The options instance
41+
*/
42+
protected OAuthOptions|SettingsContainerInterface $options;
43+
44+
/**
45+
* The PSR-18 HTTP client
46+
*/
47+
protected ClientInterface $http;
48+
49+
/**
50+
* A PSR-17 request factory
51+
*/
52+
protected RequestFactoryInterface $requestFactory;
53+
54+
/**
55+
* A PSR-17 stream factory
56+
*/
57+
protected StreamFactoryInterface $streamFactory;
58+
59+
/**
60+
* A PSR-17 URI factory
61+
*/
62+
protected UriFactoryInterface $uriFactory;
63+
64+
/**
65+
* A storage instance
66+
*/
67+
protected OAuthStorageInterface $storage;
68+
69+
/**
70+
* A PSR-3 logger
71+
*/
72+
protected LoggerInterface $logger;
73+
3974
/**
4075
* the authorization URL
4176
*/
@@ -76,22 +111,23 @@ abstract class OAuthProvider implements OAuthInterface{
76111
* OAuthProvider constructor.
77112
*/
78113
final public function __construct(
79-
/** The options instance */
80-
protected OAuthOptions|SettingsContainerInterface $options,
81-
/** The PSR-18 HTTP client */
82-
protected ClientInterface $http,
83-
/** A PSR-17 request factory */
84-
protected RequestFactoryInterface $requestFactory,
85-
/** A PSR-17 stream factory */
86-
protected StreamFactoryInterface $streamFactory,
87-
/** A PSR-17 URI factory */
88-
protected UriFactoryInterface $uriFactory,
89-
/** A storage instance */
90-
protected OAuthStorageInterface $storage = new MemoryStorage,
91-
/** A PSR-3 logger */
92-
protected LoggerInterface $logger = new NullLogger,
114+
OAuthOptions|SettingsContainerInterface $options,
115+
ClientInterface $http,
116+
RequestFactoryInterface $requestFactory,
117+
StreamFactoryInterface $streamFactory,
118+
UriFactoryInterface $uriFactory,
119+
OAuthStorageInterface $storage = new MemoryStorage,
120+
LoggerInterface $logger = new NullLogger,
93121
){
94-
$this->name = (new ReflectionClass($this))->getShortName();
122+
$this->options = $options;
123+
$this->http = $http;
124+
$this->requestFactory = $requestFactory;
125+
$this->streamFactory = $streamFactory;
126+
$this->uriFactory = $uriFactory;
127+
$this->storage = $storage;
128+
$this->logger = $logger;
129+
130+
$this->name = (new ReflectionClass($this))->getShortName();
95131

96132
$this->construct();
97133
}

src/Storage/FileStorage.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ class FileStorage extends OAuthStorageAbstract{
3333

3434
final protected const ENCRYPT_FORMAT = Utilities::ENCRYPT_FORMAT_BINARY;
3535

36+
/**
37+
* A *unique* ID to identify the user within your application, e.g. database row id or UUID
38+
*/
39+
protected string|int $oauthUser;
40+
3641
/**
3742
* OAuthStorageAbstract constructor.
3843
*/
3944
public function __construct(
40-
/** A *unique* ID to identify the user within your application, e.g. database row id or UUID */
41-
protected string|int $oauthUser,
42-
/** The options instance */
43-
protected OAuthOptions|SettingsContainerInterface $options = new OAuthOptions,
44-
/** A PSR-3 logger */
45-
protected LoggerInterface $logger = new NullLogger
45+
string|int $oauthUser,
46+
OAuthOptions|SettingsContainerInterface $options = new OAuthOptions,
47+
LoggerInterface $logger = new NullLogger
4648
){
49+
$this->oauthUser = $oauthUser;
50+
4751
parent::__construct($options, $logger);
4852
}
4953

src/Storage/OAuthStorageAbstract.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,38 @@ abstract class OAuthStorageAbstract implements OAuthStorageInterface{
2626
final protected const KEY_STATE = 'STATE';
2727
final protected const KEY_VERIFIER = 'VERIFIER';
2828

29+
/**
30+
* Output format for encrypted data
31+
*
32+
* @var int
33+
*/
2934
protected const ENCRYPT_FORMAT = Utilities::ENCRYPT_FORMAT_HEX;
3035

36+
/**
37+
* The options instance
38+
*/
39+
protected OAuthOptions|SettingsContainerInterface $options;
40+
41+
/**
42+
* A PSR-3 logger
43+
*/
44+
protected LoggerInterface $logger;
45+
3146
/**
3247
* OAuthStorageAbstract constructor.
3348
*/
3449
public function __construct(
35-
/** The options instance */
36-
protected OAuthOptions|SettingsContainerInterface $options = new OAuthOptions,
37-
/** A PSR-3 logger */
38-
protected LoggerInterface $logger = new NullLogger
50+
OAuthOptions|SettingsContainerInterface $options = new OAuthOptions,
51+
LoggerInterface $logger = new NullLogger
3952
){
4053

4154
if($this->options->useStorageEncryption === true && empty($this->options->storageEncryptionKey)){
4255
throw new OAuthStorageException('no encryption key given');
4356
}
4457

58+
$this->options = $options;
59+
$this->logger = $logger;
60+
4561
$this->construct();
4662
}
4763

0 commit comments

Comments
 (0)