Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClientProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Authenticator/OAuth2Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ApiProxyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']],
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/ApiCacheComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/ApiFormatterComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Http/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
}
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Identifier/ApiIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Media/UploadTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
2 changes: 1 addition & 1 deletion src/Policy/RequestPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
));
}

Expand Down
10 changes: 5 additions & 5 deletions src/Utility/ApiTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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
if (isset($response['included'])) {
foreach ($response['included'] as $key => $entity) {
$response['included'][$key]['attributes'] = array_diff_key(
$entity['attributes'],
array_flip($keysToRemove)
array_flip($keysToRemove),
);
}
}
Expand All @@ -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),
);
}
}
Expand Down Expand Up @@ -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,
);
}

Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
}
6 changes: 3 additions & 3 deletions src/View/Helper/ThumbHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'),
);
}
}
6 changes: 3 additions & 3 deletions src/View/Helper/WebComponentsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]);
}

Expand Down
6 changes: 3 additions & 3 deletions src/View/Twig/BeditaTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ function (array $array) {
shuffle($array);

return $array;
}
},
),
new TwigFilter(
'ksort',
function (array $array) {
ksort($array);

return $array;
}
},
),
new TwigFilter(
'krsort',
function (array $array) {
krsort($array);

return $array;
}
},
),
];
}
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Authenticator/OAuth2AuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function authenticateProvider(): array
'url' => '/ext/login/gustavo',
],
[
'urlResolver' => fn () => '',
'urlResolver' => fn() => '',
'providers' => [
'gustavo' => [
'class' => TestProvider::class,
Expand All @@ -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,
Expand All @@ -103,7 +103,7 @@ public static function authenticateProvider(): array
],
],
[
'urlResolver' => fn () => '',
'urlResolver' => fn() => '',
'providers' => [
'gustavo' => [
'class' => TestProvider::class,
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/Component/ApiCacheComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testInitialize(): void
'engine' => 'File',
'prefix' => sprintf('%s_', $expected),
'serialize' => true,
]
],
);
$registry = new ComponentRegistry();
$this->ApiCache = new ApiCacheComponent($registry);
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Identifier/ApiIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Identifier/OAuth2IdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testNullIdentify(): void
->onlyMethods(['post'])
->getMock();
$apiClientMock->method('post')->willThrowException(
new BEditaClientException('', 404)
new BEditaClientException('', 404),
);

$identifier = new OAuth2Identifier();
Expand Down Expand Up @@ -121,7 +121,7 @@ function () use (&$count) {
}

return ['meta' => ['jwt' => 'gustavo']];
}
},
);
$apiClientMock->method('get')->willReturn([
'data' => ['id' => 1],
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Media/UploadTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testUpload(): void
filesize($path),
UPLOAD_ERR_OK,
'test.png',
mime_content_type($resource)
mime_content_type($resource),
);

$expected = [
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/ThumbHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down