Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Commit

Permalink
phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Apr 5, 2018
1 parent 8be8848 commit 43d6c56
Show file tree
Hide file tree
Showing 29 changed files with 615 additions and 216 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,3 @@ build
/.project
/deployment.properties
/deployment.xml
test/asset/orm-autoload/oauth2.doctrine-orm.global.php
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -16,6 +16,7 @@ matrix:
- php: 7.1
env:
- EXECUTE_COVERAGE=true
- EXECUTE_CS_CHECK=true
- DEPS=lowest
- php: 7.1
env:
Expand All @@ -40,7 +41,7 @@ script:
- mkdir -p build/logs
- if [[ EXECUTE_COVERAGE == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml ; fi
- if [[ EXECUTE_COVERAGE != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs --standard=PSR2 --ignore=test/Bootstrap.php src test; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs; fi

after_script:
- php vendor/bin/coveralls
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -22,7 +22,6 @@
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "^3.1",
"zendframework/zend-form": "^2.10",
"zendframework/zend-loader": "^2.4",
"zendframework/zend-log": "^2.9",
Expand All @@ -31,7 +30,8 @@
"zendframework/zend-authentication": "^2.5",
"zendframework/zend-eventmanager": "^3.2",
"mockery/mockery": "^0.9.5",
"satooshi/php-coveralls": "^1.0"
"satooshi/php-coveralls": "^1.0",
"api-skeletons/coding-standard": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
27 changes: 27 additions & 0 deletions phpcs.xml.dist
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="API Skeletons" namespace="API-Skeletons\CS\Standard">
<description>v1.0 Coding Standard for API Skeletons</description>
<file>src</file>
<file>test</file>
<exclude-pattern type="relative">Bootstrap.php</exclude-pattern>
<exclude-pattern type="relative">*/data/*</exclude-pattern>
<arg name="colors"/>
<rule ref="PSR1"/>
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="./vendor/api-skeletons/coding-standard/phpcs/Sniffs/Strings/ConcatenationSpacingSniff.php"/>
</ruleset>
36 changes: 18 additions & 18 deletions src/Adapter/DoctrineAdapter.php
Expand Up @@ -209,7 +209,7 @@ public function checkClientCredentials($client_id, $client_secret = null)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand Down Expand Up @@ -259,7 +259,7 @@ public function isPublicClient($client_id)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand Down Expand Up @@ -315,7 +315,7 @@ public function getClientDetails($client_id)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand Down Expand Up @@ -363,7 +363,7 @@ public function setClientDetails(
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
$clientClass = $this->getConfig()->mapping->Client->entity;
$client = new $clientClass;
$client->setClientId($client_id);
Expand Down Expand Up @@ -432,7 +432,7 @@ public function checkRestrictedGrantType($client_id, $grant_type)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand Down Expand Up @@ -475,7 +475,7 @@ public function getClientScope($client_id)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand Down Expand Up @@ -528,7 +528,7 @@ public function getAccessToken($access_token)
$doctrineAccessTokenField => $access_token,
]);

if (!$accessToken) {
if (! $accessToken) {
return false;
}

Expand Down Expand Up @@ -584,7 +584,7 @@ public function setAccessToken(
$doctrineAccessTokenField => $access_token,
]);

if (!$accessToken) {
if (! $accessToken) {
$entityClass = $this->getConfig()->mapping->AccessToken->entity;

$accessToken = new $entityClass;
Expand Down Expand Up @@ -666,7 +666,7 @@ public function getAuthorizationCode($code)
$authorizationCode = false;
}

if (!$authorizationCode) {
if (! $authorizationCode) {
return false;
}

Expand Down Expand Up @@ -735,7 +735,7 @@ public function setAuthorizationCode(
$doctrineAuthorizationCodeField => $code,
]);

if (!$authorizationCode) {
if (! $authorizationCode) {
$entityClass = $this->getConfig()->mapping->AuthorizationCode->entity;

$authorizationCode = new $entityClass;
Expand Down Expand Up @@ -959,7 +959,7 @@ public function getUserClaims($username, $scope)
$doctrineUsernameField => $username,
]);

if (!$user) {
if (! $user) {
return false;
}

Expand Down Expand Up @@ -1118,7 +1118,7 @@ public function setRefreshToken(
$doctrineRefreshTokenField => $refresh_token,
]);

if (!$refreshToken) {
if (! $refreshToken) {
$entityClass = $this->getConfig()->mapping->RefreshToken->entity;

$refreshToken = new $entityClass;
Expand Down Expand Up @@ -1329,7 +1329,7 @@ public function getClientKey($client_id, $subject)
$doctrineClientIdField => $client_id,
]);

if (!$client) {
if (! $client) {
return false;
}

Expand All @@ -1347,7 +1347,7 @@ public function getClientKey($client_id, $subject)
// No result from doctrine ok
}

if (!$jwt) {
if (! $jwt) {
return false;
}

Expand Down Expand Up @@ -1434,7 +1434,7 @@ public function getJti(
$doctrineJtiField => $query['jti'],
]);

if (!$jti) {
if (! $jti) {
return false;
}

Expand Down Expand Up @@ -1521,7 +1521,7 @@ public function getPublicKey($client_id = null)
$doctrineClientIdField => $client_id,
]);

if (!$client || !$client->getPublicKey()) {
if (! $client || ! $client->getPublicKey()) {
return false;
}

Expand Down Expand Up @@ -1555,7 +1555,7 @@ public function getPrivateKey($client_id = null)
$doctrineClientIdField => $client_id,
]);

if (!$client || !$client->getPublicKey()) {
if (! $client || ! $client->getPublicKey()) {
return false;
}

Expand Down Expand Up @@ -1589,7 +1589,7 @@ public function getEncryptionAlgorithm($client_id = null)
$doctrineClientIdField => $client_id,
]);

if (!$client || !$client->getPublicKey()) {
if (! $client || ! $client->getPublicKey()) {
return false;
}

Expand Down
140 changes: 70 additions & 70 deletions src/ConfigProvider.php
@@ -1,70 +1,70 @@
<?php

namespace ZF\OAuth2\Doctrine;

use Zend\ServiceManager\Factory\InvokableFactory;

class ConfigProvider
{
/**
* Return general purpose zf-oauth2-doctrine configuration
*
* @return array
*/
public function __invoke()
{
return [
'dependencies' => $this->getDependencyConfig(),
'zf-apigility-doctrine-query-create-filter' => $this->getQueryCreateFilterConfig(),
'zf-apigility-doctrine-query-provider' => $this->getQueryProviderConfig(),
];
}

/**
* Return application-level dependency configuration.
*
* @return array
*/
public function getDependencyConfig()
{
return [
'factories' => [
Adapter\DoctrineAdapterFactory::class => InvokableFactory::class,
Mapper\MapperManager::class => InvokableFactory::class,
Adapter\DoctrineAdapter::class => InvokableFactory::class,
],
'shared' => [
Adapter\DoctrineAdapterFactory::class => false,
Mapper\MapperManager::class => false,
],
];
}

/**
* Return QueryCreateFilter configuration.
*
* @return array
*/
public function getQueryCreateFilterConfig()
{
return [
'initializers' => [
Query\OAuth2ServerInitializer::class,
],
];
}

/**
* Return QueryProvider configuration.
*
* @return array
*/
public function getQueryProviderConfig()
{
return [
'initializers' => [
Query\OAuth2ServerInitializer::class,
],
];
}
}
<?php

namespace ZF\OAuth2\Doctrine;

use Zend\ServiceManager\Factory\InvokableFactory;

class ConfigProvider
{
/**
* Return general purpose zf-oauth2-doctrine configuration
*
* @return array
*/
public function __invoke()
{
return [
'dependencies' => $this->getDependencyConfig(),
'zf-apigility-doctrine-query-create-filter' => $this->getQueryCreateFilterConfig(),
'zf-apigility-doctrine-query-provider' => $this->getQueryProviderConfig(),
];
}

/**
* Return application-level dependency configuration.
*
* @return array
*/
public function getDependencyConfig()
{
return [
'factories' => [
Adapter\DoctrineAdapterFactory::class => InvokableFactory::class,
Mapper\MapperManager::class => InvokableFactory::class,
Adapter\DoctrineAdapter::class => InvokableFactory::class,
],
'shared' => [
Adapter\DoctrineAdapterFactory::class => false,
Mapper\MapperManager::class => false,
],
];
}

/**
* Return QueryCreateFilter configuration.
*
* @return array
*/
public function getQueryCreateFilterConfig()
{
return [
'initializers' => [
Query\OAuth2ServerInitializer::class,
],
];
}

/**
* Return QueryProvider configuration.
*
* @return array
*/
public function getQueryProviderConfig()
{
return [
'initializers' => [
Query\OAuth2ServerInitializer::class,
],
];
}
}
4 changes: 2 additions & 2 deletions src/Entity/AccessToken.php
Expand Up @@ -51,14 +51,14 @@ public function __construct()

public function getArrayCopy()
{
return array(
return [
'id' => $this->getId(),
'accessToken' => $this->getAccessToken(),
'expires' => $this->getExpires(),
'client' => $this->getClient(),
'scope' => $this->getScope(),
'user' => $this->getUser(),
);
];
}

public function exchangeArray(array $array)
Expand Down

0 comments on commit 43d6c56

Please sign in to comment.