Skip to content

Commit 48ae271

Browse files
committed
Merge pull request dingo#280 from GrahamCampbell/cs
CS Fixes
2 parents cc5fddd + 4c23321 commit 48ae271

File tree

76 files changed

+621
-523
lines changed

Some content is hidden

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

76 files changed

+621
-523
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ php:
66
- 5.6
77
- hhvm
88

9-
before_install:
10-
- composer self-update
11-
9+
sudo: false
10+
1211
install:
13-
- composer install --prefer-source --no-interaction --dev
12+
- travis_retry composer install --no-interaction --prefer-source
1413

15-
script: phpunit
14+
script:
15+
- vendor/bin/phpunit

phpunit.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10+
stopOnError="false"
1011
stopOnFailure="false"
11-
syntaxCheck="false"
12+
syntaxCheck="true"
13+
strict="false"
14+
verbose="true"
1215
>
1316
<testsuites>
14-
<testsuite name="Package Test Suite">
15-
<directory suffix=".php">./tests/</directory>
17+
<testsuite name="API Test Suite">
18+
<directory suffix="Test.php">./tests</directory>
1619
</testsuite>
1720
</testsuites>
21+
<filter>
22+
<whitelist processUncoveredFilesFromWhitelist="true">
23+
<directory suffix=".php">./src</directory>
24+
<exclude>
25+
<directory>./src/config</directory>
26+
</exclude>
27+
</whitelist>
28+
</filter>
1829
</phpunit>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Refer to the [Wiki](https://github.com/dingo/api/wiki) for installation instruct
1010

1111
## License
1212

13-
This package is licensed under the [BSD 3-Clause license](http://opensource.org/licenses/BSD-3-Clause).
13+
This package is licensed under the [BSD 3-Clause license](http://opensource.org/licenses/BSD-3-Clause).

src/Auth/Authenticator.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ class Authenticator
4848
/**
4949
* Create a new authenticator instance.
5050
*
51-
* @param \Dingo\Api\Routing\Router $router
52-
* @param \Illuminate\Container\Container $container
53-
* @param array $providers
51+
* @param \Dingo\Api\Routing\Router $router
52+
* @param \Illuminate\Container\Container $container
53+
* @param array $providers
54+
*
5455
* @return void
5556
*/
5657
public function __construct(Router $router, Container $container, array $providers)
@@ -63,9 +64,11 @@ public function __construct(Router $router, Container $container, array $provide
6364
/**
6465
* Authenticate the current request.
6566
*
66-
* @param array $providers
67-
* @return mixed
67+
* @param array $providers
68+
*
6869
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
70+
*
71+
* @return mixed
6972
*/
7073
public function authenticate(array $providers = [])
7174
{
@@ -96,9 +99,11 @@ public function authenticate(array $providers = [])
9699
/**
97100
* Throw the first exception from the exception stack.
98101
*
99-
* @param array $exceptionStack
100-
* @return void
102+
* @param array $exceptionStack
103+
*
101104
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
105+
*
106+
* @return void
102107
*/
103108
protected function throwUnauthorizedException(array $exceptionStack)
104109
{
@@ -114,7 +119,8 @@ protected function throwUnauthorizedException(array $exceptionStack)
114119
/**
115120
* Filter the requested providers from the available providers.
116121
*
117-
* @param array $providers
122+
* @param array $providers
123+
*
118124
* @return array
119125
*/
120126
protected function filterProviders(array $providers)
@@ -140,7 +146,7 @@ public function getUser()
140146
try {
141147
return $this->user = $this->authenticate();
142148
} catch (Exception $exception) {
143-
return null;
149+
return;
144150
}
145151
}
146152

@@ -157,7 +163,8 @@ public function user()
157163
/**
158164
* Set the authenticated user.
159165
*
160-
* @param \Illuminate\Auth\GenericUser|\Illuminate\Database\Eloquent\Model $user
166+
* @param \Illuminate\Auth\GenericUser|\Illuminate\Database\Eloquent\Model $user
167+
*
161168
* @return \Dingo\Api\Auth\Authenticator
162169
*/
163170
public function setUser($user)
@@ -190,8 +197,9 @@ public function getProviderUsed()
190197
/**
191198
* Extend the authentication layer with a custom provider.
192199
*
193-
* @param string $key
194-
* @param object|callable $provider
200+
* @param string $key
201+
* @param object|callable $provider
202+
*
195203
* @return void
196204
*/
197205
public function extend($key, $provider)

src/Auth/AuthorizationProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ abstract class AuthorizationProvider implements ProviderInterface
1818
/**
1919
* Validate the requests authorization header for the provider.
2020
*
21-
* @param \Illuminate\Http\Request $request
22-
* @return bool
21+
* @param \Illuminate\Http\Request $request
22+
*
2323
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
24+
*
25+
* @return bool
2426
*/
2527
public function validateAuthorizationHeader(Request $request)
2628
{

src/Auth/BasicProvider.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class BasicProvider extends AuthorizationProvider
2626
/**
2727
* Create a new basic provider instance.
2828
*
29-
* @param \Illuminate\Auth\AuthManager $auth
30-
* @param string $identifier
29+
* @param \Illuminate\Auth\AuthManager $auth
30+
* @param string $identifier
31+
*
3132
* @return void
3233
*/
3334
public function __construct(AuthManager $auth, $identifier = 'email')
@@ -39,8 +40,9 @@ public function __construct(AuthManager $auth, $identifier = 'email')
3940
/**
4041
* Authenticate request with Basic.
4142
*
42-
* @param \Illuminate\Http\Request $request
43-
* @param \Illuminate\Routing\Route $route
43+
* @param \Illuminate\Http\Request $request
44+
* @param \Illuminate\Routing\Route $route
45+
*
4446
* @return mixed
4547
*/
4648
public function authenticate(Request $request, Route $route)

src/Auth/JWTProvider.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class JWTProvider extends AuthorizationProvider
1313
{
1414
/**
15-
* The JWTAuth instance
15+
* The JWTAuth instance.
1616
*
1717
* @var \Tymon\JWTAuth\JWTAuth
1818
*/
@@ -21,7 +21,8 @@ class JWTProvider extends AuthorizationProvider
2121
/**
2222
* Create a new JWT provider instance.
2323
*
24-
* @param \Tymon\JWTAuth\JWTAuth $auth
24+
* @param \Tymon\JWTAuth\JWTAuth $auth
25+
*
2526
* @return void
2627
*/
2728
public function __construct(JWTAuth $auth)
@@ -30,10 +31,11 @@ public function __construct(JWTAuth $auth)
3031
}
3132

3233
/**
33-
* Authenticate request with a JWT
34+
* Authenticate request with a JWT.
35+
*
36+
* @param \Illuminate\Http\Request $request
37+
* @param \Dingo\Api\Routing\Route $route
3438
*
35-
* @param \Illuminate\Http\Request $request
36-
* @param \Dingo\Api\Routing\Route $route
3739
* @return mixed
3840
*/
3941
public function authenticate(Request $request, Route $route)
@@ -48,9 +50,10 @@ public function authenticate(Request $request, Route $route)
4850
}
4951

5052
/**
51-
* Get the JWT from the request
53+
* Get the JWT from the request.
54+
*
55+
* @param \Illuminate\Http\Request $request
5256
*
53-
* @param \Illuminate\Http\Request $request
5457
* @return string
5558
*/
5659
protected function getToken(Request $request)
@@ -69,9 +72,10 @@ protected function getToken(Request $request)
6972
}
7073

7174
/**
72-
* Parse JWT from the authorization header
75+
* Parse JWT from the authorization header.
76+
*
77+
* @param \Illuminate\Http\Request $request
7378
*
74-
* @param \Illuminate\Http\Request $request
7579
* @return string
7680
*/
7781
protected function parseAuthorizationHeader(Request $request)

src/Auth/LeagueOAuth2Provider.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ class LeagueOAuth2Provider extends AuthorizationProvider
4444
/**
4545
* Create a new OAuth 2.0 provider instance.
4646
*
47-
* @param \League\OAuth2\Server\ResourceServer $resource
48-
* @param bool $httpHeadersOnly
47+
* @param \League\OAuth2\Server\ResourceServer $resource
48+
* @param bool $httpHeadersOnly
49+
*
4950
* @return void
5051
*/
5152
public function __construct(ResourceServer $resource, $httpHeadersOnly = false)
@@ -57,10 +58,12 @@ public function __construct(ResourceServer $resource, $httpHeadersOnly = false)
5758
/**
5859
* Authenticate request with the OAuth 2.0 resource server.
5960
*
60-
* @param \Illuminate\Http\Request $request
61-
* @param \Illuminate\Routing\Route $route
62-
* @return mixed
61+
* @param \Illuminate\Http\Request $request
62+
* @param \Illuminate\Routing\Route $route
63+
*
6364
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
65+
*
66+
* @return mixed
6467
*/
6568
public function authenticate(Request $request, Route $route)
6669
{
@@ -86,7 +89,8 @@ public function authenticate(Request $request, Route $route)
8689
/**
8790
* Resolve the resource owner.
8891
*
89-
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
92+
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
93+
*
9094
* @return mixed
9195
*/
9296
protected function resolveResourceOwner(AccessTokenEntity $token)
@@ -103,10 +107,12 @@ protected function resolveResourceOwner(AccessTokenEntity $token)
103107
/**
104108
* Validate a routes scopes.
105109
*
106-
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
107-
* @param \Dingo\Api\Routing\Route $route
108-
* @return bool
110+
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
111+
* @param \Dingo\Api\Routing\Route $route
112+
*
109113
* @throws \League\OAuth2\Server\Exception\InvalidScopeException
114+
*
115+
* @return bool
110116
*/
111117
protected function validateRouteScopes(AccessTokenEntity $token, Route $route)
112118
{
@@ -128,7 +134,8 @@ protected function validateRouteScopes(AccessTokenEntity $token, Route $route)
128134
/**
129135
* Set the resolver to fetch a user.
130136
*
131-
* @param callable $resolver
137+
* @param callable $resolver
138+
*
132139
* @return \Dingo\Api\Auth\LeagueOAuth2Provider
133140
*/
134141
public function setUserResolver(callable $resolver)
@@ -141,7 +148,8 @@ public function setUserResolver(callable $resolver)
141148
/**
142149
* Set the resolver to fetch a client.
143150
*
144-
* @param callable $resolver
151+
* @param callable $resolver
152+
*
145153
* @return \Dingo\Api\Auth\LeagueOAuth2Provider
146154
*/
147155
public function setClientResolver(callable $resolver)

src/Auth/ProviderInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ interface ProviderInterface
1010
/**
1111
* Authenticate the request and return the authenticated user instance.
1212
*
13-
* @param \Illuminate\Http\Request $request
14-
* @param \Dingo\Api\Routing\Route $route
13+
* @param \Illuminate\Http\Request $request
14+
* @param \Dingo\Api\Routing\Route $route
15+
*
1516
* @return mixed
1617
*/
1718
public function authenticate(Request $request, Route $route);

src/Config.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class Config
4242
/**
4343
* Create a new config instance.
4444
*
45-
* @param string $version
46-
* @param string $prefix
47-
* @param string $domain
48-
* @param string $vendor
49-
* @param string $format
45+
* @param string $version
46+
* @param string $prefix
47+
* @param string $domain
48+
* @param string $vendor
49+
* @param string $format
50+
*
5051
* @return void
5152
*/
5253
public function __construct($version = 'v1', $prefix = null, $domain = null, $vendor = null, $format = 'json')
@@ -111,7 +112,8 @@ public function getFormat()
111112
/**
112113
* Set the API version.
113114
*
114-
* @param string $version
115+
* @param string $version
116+
*
115117
* @return void
116118
*/
117119
public function setVersion($version)
@@ -122,7 +124,8 @@ public function setVersion($version)
122124
/**
123125
* Set the API format.
124126
*
125-
* @param string $format
127+
* @param string $format
128+
*
126129
* @return void
127130
*/
128131
public function setFormat($format)
@@ -133,7 +136,8 @@ public function setFormat($format)
133136
/**
134137
* Set the API vendor.
135138
*
136-
* @param string $vendor
139+
* @param string $vendor
140+
*
137141
* @return void
138142
*/
139143
public function setVendor($vendor)
@@ -144,7 +148,8 @@ public function setVendor($vendor)
144148
/**
145149
* Set the API domain.
146150
*
147-
* @param string $domain
151+
* @param string $domain
152+
*
148153
* @return void
149154
*/
150155
public function setDomain($domain)
@@ -155,7 +160,8 @@ public function setDomain($domain)
155160
/**
156161
* Set the API prefix.
157162
*
158-
* @param string $prefix
163+
* @param string $prefix
164+
*
159165
* @return void
160166
*/
161167
public function setPrefix($prefix)

0 commit comments

Comments
 (0)