diff --git a/composer.json b/composer.json index 25dd92e..6dd7fd4 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "require": { "php": ">=8.3", - "bedita/php-sdk": "^4.1.0", + "bedita/php-sdk": "^4.2.0", "cakephp/cakephp": "^5.0", "firebase/php-jwt": "^6.9", "cakephp/twig-view": "^2" diff --git a/src/ApiClientProvider.php b/src/ApiClientProvider.php index f018223..095f23a 100644 --- a/src/ApiClientProvider.php +++ b/src/ApiClientProvider.php @@ -72,7 +72,7 @@ protected function createClient(array $options = []): BEditaClient Configure::read('API.apiBaseUrl'), Configure::read('API.apiKey'), [], - Configure::read('API.guzzleConfig', []) + Configure::read('API.guzzleConfig', []), ); $logOptions = !empty($options['Log']) ? $options['Log'] : Configure::read('API.log'); if (!empty($logOptions)) { diff --git a/src/Authenticator/OAuth2Authenticator.php b/src/Authenticator/OAuth2Authenticator.php index 16fe5b4..6fb06c0 100644 --- a/src/Authenticator/OAuth2Authenticator.php +++ b/src/Authenticator/OAuth2Authenticator.php @@ -76,7 +76,7 @@ class OAuth2Authenticator extends AbstractAuthenticator public function __construct(IdentifierInterface $identifier, array $config = []) { // Setup default URL resolver - $this->setConfig('urlResolver', fn ($route) => Router::url($route, true)); + $this->setConfig('urlResolver', fn($route) => Router::url($route, true)); parent::__construct($identifier, $config); } diff --git a/src/Controller/ApiProxyTrait.php b/src/Controller/ApiProxyTrait.php index bf7018f..4ff83ba 100644 --- a/src/Controller/ApiProxyTrait.php +++ b/src/Controller/ApiProxyTrait.php @@ -206,7 +206,7 @@ protected function apiRequest(array $options): void } else { $response = call_user_func_array( [$this->apiClient, $method], // call 'post', 'patch' or 'delete' - [$options['path'], $options['body'], $options['headers']] + [$options['path'], $options['body'], $options['headers']], ); } diff --git a/src/Controller/Component/ApiCacheComponent.php b/src/Controller/Component/ApiCacheComponent.php index 02e4090..672f09a 100644 --- a/src/Controller/Component/ApiCacheComponent.php +++ b/src/Controller/Component/ApiCacheComponent.php @@ -116,7 +116,7 @@ public function get(string $path, ?array $query = null): array function () use ($key, $path, $query) { return (array)ApiClientProvider::getApiClient()->get($path, $query); }, - $this->getConfig('cache') + $this->getConfig('cache'), ); $this->updateCacheIndex($key, compact('path', 'query')); diff --git a/src/Controller/Component/ApiFormatterComponent.php b/src/Controller/Component/ApiFormatterComponent.php index 95571c6..ff12f87 100644 --- a/src/Controller/Component/ApiFormatterComponent.php +++ b/src/Controller/Component/ApiFormatterComponent.php @@ -128,7 +128,7 @@ public function replaceWithTranslation(array $response, string $lang): array if (!Hash::numeric(array_keys($data))) { $response['data']['attributes'] = array_merge( $response['data']['attributes'], - $this->extractTranslatedFields($data, $lang) + $this->extractTranslatedFields($data, $lang), ); return $response; @@ -169,7 +169,7 @@ protected function extractTranslatedFields(array $data, string $lang): array */ public function cleanResponse( array $response, - array $options = ['included', 'links', 'schema', 'relationships', 'attributes' => []] + array $options = ['included', 'links', 'schema', 'relationships', 'attributes' => []], ): array { return ApiTools::cleanResponse($response, $options); } diff --git a/src/Http/BaseClient.php b/src/Http/BaseClient.php index 2674fd9..36cff31 100644 --- a/src/Http/BaseClient.php +++ b/src/Http/BaseClient.php @@ -102,7 +102,7 @@ protected function validateConf(Validator $validator): void $errors = $validator->validate($this->getConfig()); if (!empty($errors)) { throw new InvalidArgumentException( - sprintf('%s client config not valid: %s', static::class, json_encode($errors)) + sprintf('%s client config not valid: %s', static::class, json_encode($errors)), ); } } @@ -172,7 +172,7 @@ protected function logCall(string $call, string $url, string $payload, Response $url, $response->getStatusCode(), (string)$response->getBody(), - $payload + $payload, ); $message = trim($message); $this->log($message, $level); diff --git a/src/Identifier/ApiIdentifier.php b/src/Identifier/ApiIdentifier.php index 8e5604b..52bcc84 100644 --- a/src/Identifier/ApiIdentifier.php +++ b/src/Identifier/ApiIdentifier.php @@ -60,7 +60,7 @@ public function identify(array $data): ArrayAccess|array|null try { $result = $apiClient->authenticate( $data[$usernameField], - $data[$passwordField] + $data[$passwordField], ); if (empty($result['meta'])) { $this->setError('Invalid username or password'); diff --git a/src/Media/UploadTrait.php b/src/Media/UploadTrait.php index 95bbeac..e1431ae 100644 --- a/src/Media/UploadTrait.php +++ b/src/Media/UploadTrait.php @@ -51,7 +51,7 @@ protected function uploadMedia(UploadedFileInterface $file, string $type, bool $ return $apiClient->post( sprintf('/%s/upload/%s%s', $type, $file->getClientFilename(), $query), $fileTmp, - $headers + $headers, ); } } diff --git a/src/Policy/RequestPolicy.php b/src/Policy/RequestPolicy.php index b996e71..2903a29 100644 --- a/src/Policy/RequestPolicy.php +++ b/src/Policy/RequestPolicy.php @@ -120,7 +120,7 @@ public function canAccess(?IdentityInterface $identity, ServerRequest $request): throw new LogicException(sprintf( 'Invalid rule for %s::%s() in RequestPolicy', $request->getParam('controller'), - $request->getParam('action') + $request->getParam('action'), )); } diff --git a/src/Utility/ApiTools.php b/src/Utility/ApiTools.php index abf10a0..6c8e3f4 100644 --- a/src/Utility/ApiTools.php +++ b/src/Utility/ApiTools.php @@ -38,7 +38,7 @@ public static function removeAttributes(array $response, array $keysToRemove): a if (isset($response['data']['attributes'])) { $response['data']['attributes'] = array_diff_key( $response['data']['attributes'], - array_flip($keysToRemove) + array_flip($keysToRemove), ); // remove attributes from included entities @@ -46,7 +46,7 @@ public static function removeAttributes(array $response, array $keysToRemove): a foreach ($response['included'] as $key => $entity) { $response['included'][$key]['attributes'] = array_diff_key( $entity['attributes'], - array_flip($keysToRemove) + array_flip($keysToRemove), ); } } @@ -63,7 +63,7 @@ public static function removeAttributes(array $response, array $keysToRemove): a foreach ($response['included'] as $key => $entity) { $response['included'][$key]['attributes'] = array_diff_key( $entity['attributes'], - array_flip($keysToRemove) + array_flip($keysToRemove), ); } } @@ -137,7 +137,7 @@ public static function recursiveRemoveKey(array $data, string $key): array function ($k) use ($key) { return $k !== $key; }, - ARRAY_FILTER_USE_KEY + ARRAY_FILTER_USE_KEY, ); } @@ -150,7 +150,7 @@ function ($k) use ($key) { */ public static function cleanResponse( array $response, - array $options = ['included', 'links', 'schema', 'relationships', 'attributes' => []] + array $options = ['included', 'links', 'schema', 'relationships', 'attributes' => []], ): array { foreach ($options as $key => $option) { if (is_string($key) && is_array($option)) { diff --git a/src/View/Helper/HtmlHelper.php b/src/View/Helper/HtmlHelper.php index a364a4b..c6ee1d6 100644 --- a/src/View/Helper/HtmlHelper.php +++ b/src/View/Helper/HtmlHelper.php @@ -374,7 +374,7 @@ public function assets(string $name, array $options = []): ?string return sprintf( '%s%s', (string)$this->css($name, $options), - (string)$this->script($name, $options) + (string)$this->script($name, $options), ); } } diff --git a/src/View/Helper/ThumbHelper.php b/src/View/Helper/ThumbHelper.php index b3fef2b..18a3297 100644 --- a/src/View/Helper/ThumbHelper.php +++ b/src/View/Helper/ThumbHelper.php @@ -100,14 +100,14 @@ public function initialize(array $config): void public function status( int|string|null $imageId, ?array $options = ['preset' => 'default'], - ?string &$url = '' + ?string &$url = '', ): ?int { if (empty($imageId) && empty($options['ids'])) { return static::NOT_ACCEPTABLE; } try { $apiClient = ApiClientProvider::getApiClient(); - $response = $apiClient->thumbs($imageId, $options); + $response = $apiClient->thumbs($imageId, (array)$options); if (empty($response['meta']['thumbnails'][0])) { return static::NOT_AVAILABLE; } @@ -220,7 +220,7 @@ public function getUrl(?array $image, array $options = []): string function () use ($image, $options) { return $this->url($image['id'], $options); }, - $this->getConfig('cache') + $this->getConfig('cache'), ); } } diff --git a/src/View/Helper/WebComponentsHelper.php b/src/View/Helper/WebComponentsHelper.php index 4b77345..85c9e63 100644 --- a/src/View/Helper/WebComponentsHelper.php +++ b/src/View/Helper/WebComponentsHelper.php @@ -62,13 +62,13 @@ public function props(array $properties): array } if (!empty($statements)) { - // @codingStandardsIgnoreStart + // @phpcs:disable $content = sprintf( '(function(){var elem = document.querySelector(\'[data-wc="%s"]\');%s}());if(document.currentScript)document.currentScript.parentNode.removeChild(document.currentScript);', $id, - join('', $statements) + join('', $statements), ); - // @codingStandardsIgnoreEnd + // @phpcs:enable $this->Html->scriptBlock($content, [ 'block' => 'scriptsComponents' ]); } diff --git a/src/View/Twig/BeditaTwigExtension.php b/src/View/Twig/BeditaTwigExtension.php index 6581a04..d29c268 100644 --- a/src/View/Twig/BeditaTwigExtension.php +++ b/src/View/Twig/BeditaTwigExtension.php @@ -60,7 +60,7 @@ function (array $array) { shuffle($array); return $array; - } + }, ), new TwigFilter( 'ksort', @@ -68,7 +68,7 @@ function (array $array) { ksort($array); return $array; - } + }, ), new TwigFilter( 'krsort', @@ -76,7 +76,7 @@ function (array $array) { krsort($array); return $array; - } + }, ), ]; } diff --git a/tests/TestCase/Authenticator/OAuth2AuthenticatorTest.php b/tests/TestCase/Authenticator/OAuth2AuthenticatorTest.php index b2a39dd..8003a6c 100644 --- a/tests/TestCase/Authenticator/OAuth2AuthenticatorTest.php +++ b/tests/TestCase/Authenticator/OAuth2AuthenticatorTest.php @@ -64,7 +64,7 @@ public static function authenticateProvider(): array 'url' => '/ext/login/gustavo', ], [ - 'urlResolver' => fn () => '', + 'urlResolver' => fn() => '', 'providers' => [ 'gustavo' => [ 'class' => TestProvider::class, @@ -81,7 +81,7 @@ public static function authenticateProvider(): array 'url' => '/ext/login/gustavo?code=1&state=1', ], [ - 'urlResolver' => fn () => '', + 'urlResolver' => fn() => '', 'providers' => [ 'gustavo' => [ 'class' => TestProvider::class, @@ -103,7 +103,7 @@ public static function authenticateProvider(): array ], ], [ - 'urlResolver' => fn () => '', + 'urlResolver' => fn() => '', 'providers' => [ 'gustavo' => [ 'class' => TestProvider::class, @@ -156,7 +156,7 @@ public function testAuthenticate( $expected, array $reqConfig, array $authConfig = [], - array $identity = ['id' => 1] + array $identity = ['id' => 1], ): void { if ($expected instanceof Exception) { $this->expectException(get_class($expected)); @@ -222,7 +222,7 @@ public function getErrors(): array $request = $request->withAttribute('session', $session); $authenticator = new OAuth2Authenticator($identifier, [ - 'urlResolver' => fn () => '', + 'urlResolver' => fn() => '', 'providers' => [ 'gustavo' => [ 'class' => TestProvider::class, diff --git a/tests/TestCase/Controller/Component/ApiCacheComponentTest.php b/tests/TestCase/Controller/Component/ApiCacheComponentTest.php index bc3142c..e631700 100644 --- a/tests/TestCase/Controller/Component/ApiCacheComponentTest.php +++ b/tests/TestCase/Controller/Component/ApiCacheComponentTest.php @@ -79,7 +79,7 @@ public function testInitialize(): void 'engine' => 'File', 'prefix' => sprintf('%s_', $expected), 'serialize' => true, - ] + ], ); $registry = new ComponentRegistry(); $this->ApiCache = new ApiCacheComponent($registry); @@ -103,7 +103,7 @@ public function testInitializeCustomConfig(): void 'engine' => 'File', 'prefix' => sprintf('%s_', $expected), 'serialize' => true, - ] + ], ); $registry = new ComponentRegistry(); $this->ApiCache = new ApiCacheComponent($registry, ['cache' => $expected]); diff --git a/tests/TestCase/Identifier/ApiIdentifierTest.php b/tests/TestCase/Identifier/ApiIdentifierTest.php index 316b1d5..cf66448 100644 --- a/tests/TestCase/Identifier/ApiIdentifierTest.php +++ b/tests/TestCase/Identifier/ApiIdentifierTest.php @@ -148,7 +148,7 @@ protected function createUserAndRole(string $username, string $role): void 'type' => 'roles', 'id' => Hash::get($this->role, 'data.id'), ], - ] + ], ); $this->apiClient->setupTokens($currentJwt); diff --git a/tests/TestCase/Identifier/OAuth2IdentifierTest.php b/tests/TestCase/Identifier/OAuth2IdentifierTest.php index 897d20a..2b6846a 100644 --- a/tests/TestCase/Identifier/OAuth2IdentifierTest.php +++ b/tests/TestCase/Identifier/OAuth2IdentifierTest.php @@ -91,7 +91,7 @@ public function testNullIdentify(): void ->onlyMethods(['post']) ->getMock(); $apiClientMock->method('post')->willThrowException( - new BEditaClientException('', 404) + new BEditaClientException('', 404), ); $identifier = new OAuth2Identifier(); @@ -121,7 +121,7 @@ function () use (&$count) { } return ['meta' => ['jwt' => 'gustavo']]; - } + }, ); $apiClientMock->method('get')->willReturn([ 'data' => ['id' => 1], diff --git a/tests/TestCase/Media/UploadTraitTest.php b/tests/TestCase/Media/UploadTraitTest.php index df9a2a1..d0362b6 100644 --- a/tests/TestCase/Media/UploadTraitTest.php +++ b/tests/TestCase/Media/UploadTraitTest.php @@ -70,7 +70,7 @@ public function testUpload(): void filesize($path), UPLOAD_ERR_OK, 'test.png', - mime_content_type($resource) + mime_content_type($resource), ); $expected = [ diff --git a/tests/TestCase/View/Helper/ThumbHelperTest.php b/tests/TestCase/View/Helper/ThumbHelperTest.php index 404bd2f..29b2ccd 100644 --- a/tests/TestCase/View/Helper/ThumbHelperTest.php +++ b/tests/TestCase/View/Helper/ThumbHelperTest.php @@ -167,7 +167,7 @@ public function testInitializeCustomConfig(): void 'engine' => 'File', 'prefix' => sprintf('%s_', $expected), 'serialize' => true, - ] + ], ); $this->Thumb = new ThumbHelper(new View(), ['cache' => $expected]); $actual = $this->Thumb->getConfig('cache');