Skip to content

Commit abe9d03

Browse files
committed
Fixed phpcs Warnings
1 parent e6cfe0a commit abe9d03

19 files changed

Lines changed: 139 additions & 63 deletions

lib/Controller/ConfigurationController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,8 @@ private function importFromSource(callable $fetchConfig, array $params, string $
12421242

12431243
$configuration = $this->configurationMapper->insert($configuration);
12441244

1245-
$msg = '[ConfigurationController] Created configuration'." entity with ID {$configuration->getId()} for app {$appId}";
1245+
$configId = $configuration->getId();
1246+
$msg = "[ConfigurationController] Created configuration entity with ID {$configId} for app {$appId}";
12461247
$this->logger->info(
12471248
message: $msg,
12481249
context: ['file' => __FILE__, 'line' => __LINE__]
@@ -1267,7 +1268,8 @@ private function importFromSource(callable $fetchConfig, array $params, string $
12671268
// But we need to save the sync status.
12681269
$this->configurationMapper->update($configuration);
12691270

1270-
$msg = '[ConfigurationController] Successfully imported'." configuration {$configuration->getTitle()} from {$sourceType}";
1271+
$configTitle = $configuration->getTitle();
1272+
$msg = "[ConfigurationController] Successfully imported configuration {$configTitle} from {$sourceType}";
12711273
$this->logger->info(
12721274
message: $msg,
12731275
context: ['file' => __FILE__, 'line' => __LINE__]

lib/Controller/RegistersController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ public function index(): JSONResponse
303303
schemas: $expandedSchemas
304304
);
305305

306-
$msg = '[RegistersController] Schema counts for register '.$register['id'].': '.json_encode($schemaCounts);
306+
$registerId = $register['id'];
307+
$countsJson = json_encode($schemaCounts);
308+
$msg = "[RegistersController] Schema counts for register {$registerId}: {$countsJson}";
307309
$this->logger->debug(
308310
message: $msg,
309311
context: ['file' => __FILE__, 'line' => __LINE__]
@@ -326,7 +328,8 @@ public function index(): JSONResponse
326328
$schema['stats'] = [
327329
'objects' => $schemaCounts[$schemaId],
328330
];
329-
$msg = '[RegistersController] Set stats for schema '."{$schemaId}: ".json_encode($schema['stats']);
331+
$statsJson = json_encode($schema['stats']);
332+
$msg = "[RegistersController] Set stats for schema {$schemaId}: {$statsJson}";
330333
$this->logger->debug(
331334
message: $msg,
332335
context: ['file' => __FILE__, 'line' => __LINE__]

lib/Db/MagicMapper.php

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ public function __construct(
298298
self::$constructCount++;
299299
file_put_contents('/tmp/or-debug.log', "MagicMapper::__construct #".self::$constructCount."\n", FILE_APPEND);
300300
if (self::$constructCount > 2) {
301-
file_put_contents('/tmp/or-debug.log', "CIRCULAR! Stack:\n".(new \Exception())->getTraceAsString()."\n", FILE_APPEND);
301+
file_put_contents(
302+
'/tmp/or-debug.log',
303+
"CIRCULAR! Stack:\n".(new \Exception())->getTraceAsString()."\n",
304+
FILE_APPEND
305+
);
302306
return;
303307
}
304308

@@ -878,8 +882,10 @@ public function getSimpleFacetsFromRegisterSchemaTable(array $query, Register $r
878882
schemaSlug: $schema->getSlug()
879883
);
880884
if ($isMagicEnabled === true) {
885+
// phpcs:ignore Generic.Files.LineLength.TooLong -- log message string cannot be shortened
886+
$infoMsg = '[MagicMapper] Register+schema table does not exist but magic mapping enabled, creating table for facets';
881887
$this->logger->info(
882-
message: '[MagicMapper] Register+schema table does not exist but magic mapping enabled, creating table for facets',
888+
message: $infoMsg,
883889
context: [
884890
'file' => __FILE__,
885891
'line' => __LINE__,
@@ -1107,8 +1113,10 @@ private function searchAcrossMultipleTablesWithUnion(array $query, array $regist
11071113
schemaSlug: $schema->getSlug()
11081114
);
11091115
if ($isMagicEnabled === true) {
1116+
// phpcs:ignore Generic.Files.LineLength.TooLong -- log message string cannot be shortened
1117+
$infoMsg = '[MagicMapper] Register+schema table does not exist but magic mapping enabled, creating table for cross-search';
11101118
$this->logger->info(
1111-
message: '[MagicMapper] Register+schema table does not exist but magic mapping enabled, creating table for cross-search',
1119+
message: $infoMsg,
11121120
context: [
11131121
'file' => __FILE__,
11141122
'line' => __LINE__,
@@ -1607,6 +1615,7 @@ private function checkTableExistsInDatabase(string $tableName): bool
16071615
$isPostgres = stripos($platform::class, 'PostgreSQL') !== false;
16081616

16091617
if ($isPostgres === true) {
1618+
// phpcs:ignore Generic.Files.LineLength.TooLong -- SQL query cannot be shortened
16101619
$sql = "SELECT 1 FROM information_schema.tables WHERE table_name = ? AND table_schema = current_schema() LIMIT 1";
16111620
} else {
16121621
// MySQL/MariaDB/SQLite.
@@ -1868,7 +1877,9 @@ public function syncTableForRegisterSchema(Register $register, Schema $schema):
18681877
// Calculate regular properties (excluding metadata).
18691878
$regularPropCount = count($requiredColumns) - $metadataCount;
18701879

1871-
$unchangedCount = count($currentColumns) - count($columnStats['columnsAdded']) - count($columnStats['columnsDropped']);
1880+
$addedCount = count($columnStats['columnsAdded']);
1881+
$droppedCount = count($columnStats['columnsDropped']);
1882+
$unchangedCount = count($currentColumns) - $addedCount - $droppedCount;
18721883

18731884
$result = [
18741885
'success' => true,
@@ -3158,8 +3169,10 @@ private function prepareObjectDataForTable(array $objectData, Register $register
31583169
&& (($propertyConfig['items']['type'] ?? '') === 'file');
31593170

31603171
if ($isFileProperty === true && is_string($value) === true && strpos($value, 'data:') === 0) {
3172+
// phpcs:ignore Generic.Files.LineLength.TooLong -- log message string cannot be shortened
3173+
$warnMsg = '[MagicMapper] File property contains unprocessed base64 data URL - setting to null to prevent DB error';
31613174
$this->logger->warning(
3162-
message: '[MagicMapper] File property contains unprocessed base64 data URL - setting to null to prevent DB error',
3175+
message: $warnMsg,
31633176
context: [
31643177
'file' => __FILE__,
31653178
'line' => __LINE__,
@@ -3175,8 +3188,10 @@ private function prepareObjectDataForTable(array $objectData, Register $register
31753188
$cleanedArray = [];
31763189
foreach ($value as $item) {
31773190
if (is_string($item) === true && strpos($item, 'data:') === 0) {
3191+
// phpcs:ignore Generic.Files.LineLength.TooLong -- log message string cannot be shortened
3192+
$warnMsg = '[MagicMapper] Array file item contains unprocessed base64 data URL - skipping item';
31783193
$this->logger->warning(
3179-
message: '[MagicMapper] Array file item contains unprocessed base64 data URL - skipping item',
3194+
message: $warnMsg,
31803195
context: [
31813196
'file' => __FILE__,
31823197
'line' => __LINE__,
@@ -6253,7 +6268,8 @@ public function findByRelationBatchInSchema(
62536268
// PostgreSQL: Handle both array and object formats.
62546269
// - For arrays: use @> containment operator (can't use ? as it conflicts with PDO placeholders).
62556270
// - For objects: use jsonb_each_text to search values.
6256-
$arrSql = "(jsonb_typeof(_relations)='array' AND _relations @> to_jsonb(?::text))";
6271+
$arrSql = "(jsonb_typeof(_relations)='array' AND _relations @> to_jsonb(?::text))";
6272+
// phpcs:ignore Generic.Files.LineLength.TooLong -- SQL query cannot be shortened
62576273
$objSql = "(jsonb_typeof(_relations)='object' AND EXISTS(SELECT 1 FROM jsonb_each_text(_relations) kv WHERE kv.value=?))";
62586274
$conditions[] = "({$arrSql} OR {$objSql})";
62596275
$params[] = $uuid;
@@ -8104,11 +8120,12 @@ public function searchObjectsPaginated(
81048120
*
81058121
* @return array{results: ObjectEntity[], total: int, registers: array, schemas: array}
81068122
*
8107-
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) Flags control security filtering behavior
8123+
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
8124+
* Flags control security filtering behavior
81088125
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
81098126
* @SuppressWarnings(PHPMD.NPathComplexity)
81108127
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
8111-
* @psalm-suppress UnusedParam Parameters reserved for future per-schema security filtering.
8128+
* @psalm-suppress UnusedParam Reserved for future per-schema security filtering.
81128129
*/
81138130
private function searchObjectsPaginatedMultiSchema(
81148131
array $searchQuery,

lib/Db/MagicMapper/MagicFacetHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,8 +1960,9 @@ private function batchResolveUuidLabels(
19601960
);
19611961
$this->warmedFields[$fieldCacheKey] = true;
19621962
} catch (\Exception $e) {
1963+
$eMsg = $e->getMessage();
19631964
$this->logger->warning(
1964-
message: '[MagicFacetHandler] Failed to persist facet labels to distributed cache: '.$e->getMessage(),
1965+
message: "[MagicFacetHandler] Failed to persist facet labels to distributed cache: {$eMsg}",
19651966
context: ['file' => __FILE__, 'line' => __LINE__]
19661967
);
19671968
}

lib/Service/AuthenticationService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,12 @@ public function fetchJWTToken(array $configuration): string
409409
$jwk = $this->getJWK(configuration: $configuration);
410410

411411
if (isset($configuration['x5t']) === true) {
412-
return $this->generateJWT(payload: $payload, jwk: $jwk, algorithm: $configuration['algorithm'], x5t: $configuration['x5t']);
412+
return $this->generateJWT(
413+
payload: $payload,
414+
jwk: $jwk,
415+
algorithm: $configuration['algorithm'],
416+
x5t: $configuration['x5t']
417+
);
413418
}
414419

415420
return $this->generateJWT(payload: $payload, jwk: $jwk, algorithm: $configuration['algorithm']);

lib/Service/Configuration/ImportHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ class ImportHandler
7575
* which could trigger another dependency check. This flag prevents infinite recursion.
7676
*
7777
* @var boolean
78-
*
79-
* @SuppressWarnings(PHPMD.UnusedPrivateField)
8078
*/
8179
private static bool $depCheckActive = false;
8280

@@ -203,8 +201,6 @@ class ImportHandler
203201
* OpenConnector configuration service for optional integration.
204202
*
205203
* @var mixed The OpenConnector configuration service or null.
206-
*
207-
* @SuppressWarnings(PHPMD.UnusedPrivateField)
208204
*/
209205
private mixed $connectorConfigSvc = null;
210206

0 commit comments

Comments
 (0)