Skip to content

Commit 5abe923

Browse files
authored
PHPDoc improvements and type hinting of variables. (bshaffer#828)
1 parent 5df6668 commit 5abe923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1904
-479
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ To get the diff for a specific change, go to https://github.com/bshaffer/oauth2-
8787
* bug #346 Fixes open_basedir warning
8888
* bug #351 Adds OpenID Connect support
8989
* bug #355 Adds php 5.6 and HHVM to travis.ci testing
90-
* [BC] bug #358 Adds `getQuerystringIdentifier()` to the GrantType interface
90+
* [BC] bug #358 Adds `getQueryStringIdentifier()` to the GrantType interface
9191
* bug #363 Encryption\JWT - Allows for subclassing JWT Headers
9292
* bug #349 Bearer Tokens - adds requestHasToken method for when access tokens are optional
9393
* bug #301 Encryption\JWT - fixes urlSafeB64Encode(): ensures newlines are replaced as expected

src/OAuth2/Autoloader.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@
1010
*/
1111
class Autoloader
1212
{
13+
/**
14+
* @var string
15+
*/
1316
private $dir;
1417

18+
/**
19+
* @param string $dir
20+
*/
1521
public function __construct($dir = null)
1622
{
1723
if (is_null($dir)) {
1824
$dir = dirname(__FILE__).'/..';
1925
}
2026
$this->dir = $dir;
2127
}
28+
2229
/**
2330
* Registers OAuth2\Autoloader as an SPL autoloader.
2431
*/
@@ -31,9 +38,8 @@ public static function register($dir = null)
3138
/**
3239
* Handles autoloading of classes.
3340
*
34-
* @param string $class A class name.
35-
*
36-
* @return boolean Returns true if the class has been loaded
41+
* @param string $class - A class name.
42+
* @return boolean - Returns true if the class has been loaded
3743
*/
3844
public function autoload($class)
3945
{

src/OAuth2/ClientAssertionType/ClientAssertionTypeInterface.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
*/
1111
interface ClientAssertionTypeInterface
1212
{
13+
/**
14+
* Validate the OAuth request
15+
*
16+
* @param RequestInterface $request
17+
* @param ResponseInterface $response
18+
* @return mixed
19+
*/
1320
public function validateRequest(RequestInterface $request, ResponseInterface $response);
21+
22+
/**
23+
* Get the client id
24+
*
25+
* @return mixed
26+
*/
1427
public function getClientId();
1528
}

src/OAuth2/ClientAssertionType/HttpBasic.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use OAuth2\Storage\ClientCredentialsInterface;
66
use OAuth2\RequestInterface;
77
use OAuth2\ResponseInterface;
8+
use LogicException;
89

910
/**
1011
* Validate a client via Http Basic authentication
@@ -19,14 +20,16 @@ class HttpBasic implements ClientAssertionTypeInterface
1920
protected $config;
2021

2122
/**
22-
* @param OAuth2\Storage\ClientCredentialsInterface $clientStorage REQUIRED Storage class for retrieving client credentials information
23-
* @param array $config OPTIONAL Configuration options for the server
24-
* <code>
25-
* $config = array(
26-
* 'allow_credentials_in_request_body' => true, // whether to look for credentials in the POST body in addition to the Authorize HTTP Header
27-
* 'allow_public_clients' => true // if true, "public clients" (clients without a secret) may be authenticated
28-
* );
29-
* </code>
23+
* Config array $config should look as follows:
24+
* @code
25+
* $config = array(
26+
* 'allow_credentials_in_request_body' => true, // whether to look for credentials in the POST body in addition to the Authorize HTTP Header
27+
* 'allow_public_clients' => true // if true, "public clients" (clients without a secret) may be authenticated
28+
* );
29+
* @endcode
30+
*
31+
* @param ClientCredentialsInterface $storage Storage
32+
* @param array $config Configuration options for the server
3033
*/
3134
public function __construct(ClientCredentialsInterface $storage, array $config = array())
3235
{
@@ -37,14 +40,22 @@ public function __construct(ClientCredentialsInterface $storage, array $config =
3740
), $config);
3841
}
3942

43+
/**
44+
* Validate the OAuth request
45+
*
46+
* @param RequestInterface $request
47+
* @param ResponseInterface $response
48+
* @return bool|mixed
49+
* @throws LogicException
50+
*/
4051
public function validateRequest(RequestInterface $request, ResponseInterface $response)
4152
{
4253
if (!$clientData = $this->getClientCredentials($request, $response)) {
4354
return false;
4455
}
4556

4657
if (!isset($clientData['client_id'])) {
47-
throw new \LogicException('the clientData array must have "client_id" set');
58+
throw new LogicException('the clientData array must have "client_id" set');
4859
}
4960

5061
if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '') {
@@ -70,6 +81,11 @@ public function validateRequest(RequestInterface $request, ResponseInterface $re
7081
return true;
7182
}
7283

84+
/**
85+
* Get the client id
86+
*
87+
* @return mixed
88+
*/
7389
public function getClientId()
7490
{
7591
return $this->clientData['client_id'];
@@ -82,13 +98,14 @@ public function getClientId()
8298
* According to the spec (draft 20), the client_id can be provided in
8399
* the Basic Authorization header (recommended) or via GET/POST.
84100
*
85-
* @return
86-
* A list containing the client identifier and password, for example
101+
* @param RequestInterface $request
102+
* @param ResponseInterface $response
103+
* @return array|null A list containing the client identifier and password, for example:
87104
* @code
88-
* return array(
89-
* "client_id" => CLIENT_ID, // REQUIRED the client id
90-
* "client_secret" => CLIENT_SECRET, // OPTIONAL the client secret (may be omitted for public clients)
91-
* );
105+
* return array(
106+
* "client_id" => CLIENT_ID, // REQUIRED the client id
107+
* "client_secret" => CLIENT_SECRET, // OPTIONAL the client secret (may be omitted for public clients)
108+
* );
92109
* @endcode
93110
*
94111
* @see http://tools.ietf.org/html/rfc6749#section-2.3.1
@@ -108,7 +125,6 @@ public function getClientCredentials(RequestInterface $request, ResponseInterfac
108125
* client_secret can be null if the client's password is an empty string
109126
* @see http://tools.ietf.org/html/rfc6749#section-2.3.1
110127
*/
111-
112128
return array('client_id' => $request->request('client_id'), 'client_secret' => $request->request('client_secret'));
113129
}
114130
}

0 commit comments

Comments
 (0)