-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `RemoteActionInterface` was missing as implemented in `AbstractRemoteGetFieldsAction` so remote contact ID weren't resolved. * `AbstractRemoteGetFieldsAction` now extends `BasicGetFieldsAction` so the phpdoc type hint of `AbstractEntity::getFields()` is matched.
- Loading branch information
Dominic Tubach
committed
Dec 13, 2024
1 parent
945703e
commit 1648025
Showing
3 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2024 SYSTOPIA GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Civi\RemoteTools\Api4\Util; | ||
|
||
/** | ||
* @phpstan-type whereT list<array{string, string|list<mixed>, 2?: mixed}> | ||
* "list<mixed>" is actually a condition of a composite condition so we have | ||
* a recursion that cannot be expressed in a phpstan type. The third entry is | ||
* not given for composite conditions. | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
final class WhereUtil { | ||
|
||
/** | ||
* @phpstan-param whereT $where | ||
* | ||
* @phpstan-return array<string> | ||
* Field names used in where. | ||
*/ | ||
public static function getFields(array $where): array { | ||
$fields = []; | ||
|
||
foreach ($where as $clause) { | ||
if (is_array($clause[1])) { | ||
// Composite condition. | ||
// @phpstan-ignore argument.type | ||
$fields = array_merge($fields, self::getFields($clause[1])); | ||
} | ||
else { | ||
$fields[] = $clause[0]; | ||
} | ||
} | ||
|
||
return array_unique($fields); | ||
} | ||
|
||
} |