Skip to content

Commit

Permalink
Merge pull request #14 from TomHAnderson/feature/2.0
Browse files Browse the repository at this point in the history
Feature/2.0
  • Loading branch information
TomHAnderson authored Apr 12, 2024
2 parents c5079b4 + 3f58e83 commit d50f119
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.3.0"
with:
php-version: '8.0'
php-version: '8.1'
composer-options: '--prefer-dist --ignore-platform-req=php'

7 changes: 4 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "highest"
optional-dependencies:
- true
- false
include:
- php-version: "8.0"
- php-version: "8.1"
dependencies: "lowest"
optional-dependencies: false
- php-version: "8.0"
- php-version: "8.1"
dependencies: "lowest"
optional-dependencies: true

Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Run test suite
# run: composer run-script test
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.0'
php-version: '8.1'
- uses: actions/checkout@v2
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
Expand Down
27 changes: 19 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
}
],
"require": {
"php": "^8.0",
"laravel-doctrine/orm": "^1.6",
"php": "^8.1",
"laravel-doctrine/orm": "^2.0",
"api-skeletons/laravel-api-problem": "^1.0.1"
},
"require-dev": {
"doctrine/coding-standard": "^9.0",
"doctrine/dbal": "^3.1.1",
"doctrine/annotations": "^1.13.2",
"orchestra/testbench": "^6.23",
"doctrine/coding-standard": "^12.0",
"doctrine/dbal": "^3.8",
"doctrine/annotations": "^2.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.15"
"vimeo/psalm": "^4.15",
"orchestra/testbench": "^7.41",
"php-parallel-lint/php-parallel-lint": "^1.4"
},
"extra": {
"laravel": {
Expand All @@ -40,6 +41,16 @@
}
},
"scripts": {
"test": "vendor/bin/phpcs && vendor/bin/phpunit && vendor/bin/psalm"
"test": [
"parallel-lint src/ test/",
"vendor/bin/phpcs",
"vendor/bin/psalm",
"vendor/bin/phpunit"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
14 changes: 3 additions & 11 deletions src/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@

abstract class Command extends IlluminateCommand
{
protected ApiKeyService $apiKeyService;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(ApiKeyService $apiKeyService)
public function __construct(protected ApiKeyService $apiKeyService)
{
parent::__construct();

$this->apiKeyService = $apiKeyService;
}

/**
* @param ApiKey[] $apiKeys
*/
/** @param ApiKey[] $apiKeys */
protected function printApiKeys(array $apiKeys): void
{
$headers = ['name', 'api_key', 'status', 'scopes'];
Expand All @@ -53,9 +47,7 @@ protected function printApiKeys(array $apiKeys): void
$this->table($headers, $rows);
}

/**
* @param Scope[] $scopes
*/
/** @param Scope[] $scopes */
protected function printScopes(array $scopes): void
{
$headers = ['name', 'apikey count'];
Expand Down
7 changes: 2 additions & 5 deletions src/Http/Middleware/AuthorizeApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@

class AuthorizeApiKey
{
private ApiKeyService $apiKeyService;

public function __construct(ApiKeyService $apiKeyService)
public function __construct(private ApiKeyService $apiKeyService)
{
$this->apiKeyService = $apiKeyService;
}

/**
* Handle request
*/
public function handle(Request $request, Closure $next, ?string $scope = null): mixed
public function handle(Request $request, Closure $next, string|null $scope = null): mixed
{
$header = $request->header('Authorization');
if (! $header) {
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/ApiKeyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function removeScope(ApiKey $apiKey, Scope $scope): ApiKey

if (! $found) {
throw new ApiKeyDoesNotHaveScope(
'The requested Scope to remove does not exist on the ApiKey'
'The requested Scope to remove does not exist on the ApiKey',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Service/ApiKeyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class ApiKeyService
{
private ?EntityManager $entityManager = null;
private EntityManager|null $entityManager = null;

public function getEntityManager(): EntityManager
{
Expand Down

0 comments on commit d50f119

Please sign in to comment.