Skip to content

Commit

Permalink
refactor: Use friendsofphp/php-cs-fixer instead of squizlabs/php_code…
Browse files Browse the repository at this point in the history
…sniffer (#22)
  • Loading branch information
roadiz-ci committed Nov 6, 2024
1 parent 25e99dd commit d66210e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ jobs:
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install Dependencies
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs --extensions=php --warning-severity=0 --standard=PSR12 -p ./src
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"symfony/http-client": "6.4.*"
},
"require-dev": {
"phpstan/phpstan": "^1.5.3",
"squizlabs/php_codesniffer": "^3.5"
"phpstan/phpstan": "^1.5.3"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 0 additions & 14 deletions phpcs.xml.dist

This file was deleted.

8 changes: 2 additions & 6 deletions src/Validation/Constraint/HostedDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ public function assert(Token $token): void
{
if ($token instanceof Token\Plain && !empty($this->hostedDomain)) {
if (!$token->claims()->has('hd')) {
throw new ConstraintViolation(
'Token does not expose any Hosted Domain.'
);
throw new ConstraintViolation('Token does not expose any Hosted Domain.');
}
/*
* Check that Hosted Domain is the same as required by Roadiz
*/
if ($token->claims()->get('hd') !== $this->hostedDomain) {
throw new ConstraintViolation(
'User (' . $token->claims()->get('hd') . ') does not belong to Hosted Domain.'
);
throw new ConstraintViolation('User ('.$token->claims()->get('hd').') does not belong to Hosted Domain.');
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/Validation/Constraint/UserInfoEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ public function assert(Token $token): void
try {
$response = $this->client->request('GET', $this->userInfoEndpoint, [
'headers' => [
'Authorization' => 'Bearer ' . $token->toString(),
'Authorization' => 'Bearer '.$token->toString(),
],
]);
// Trigger lazy request
$response->getContent();
} catch (ExceptionInterface $e) {
throw new ConstraintViolation(
'Userinfo cannot be fetch from Identity provider'
);
throw new ConstraintViolation('Userinfo cannot be fetch from Identity provider');
}
}
}

0 comments on commit d66210e

Please sign in to comment.