Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter typing in Apiv4 #25706

Merged
merged 1 commit into from
Mar 1, 2023
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 Civi/Api4/Service/Spec/RequestSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getEntityTableName(): ?string {
* @param string $action
* @param array $values
*/
public function __construct($entity, $action, $values = []) {
public function __construct(string $entity, string $action, array $values = []) {
$this->entity = $entity;
$this->action = $action;
$this->entityTableName = CoreUtil::getTableName($entity);
Expand Down
6 changes: 4 additions & 2 deletions Civi/Api4/Service/Spec/SpecGatherer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ class SpecGatherer extends AutoService {
/**
* Returns a RequestSpec with all the fields available. Uses spec providers
* to add or modify field specifications.
* @see \Civi\Api4\Service\Spec\Provider\CustomFieldCreationSpecProvider
*
* @param string $entity
* @param string $action
* @param bool $includeCustom
* @param array $values
*
* @return \Civi\Api4\Service\Spec\RequestSpec
* @throws \CRM_Core_Exception
* @see \Civi\Api4\Service\Spec\Provider\CustomFieldCreationSpecProvider
*
*/
public function getSpec($entity, $action, $includeCustom, $values = []) {
public function getSpec(string $entity, string $action, bool $includeCustom, array $values = []): RequestSpec {
$specification = new RequestSpec($entity, $action, $values);

// Real entities
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/Utils/CoreUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function getIdFieldName(string $entityName): string {
*
* @return string
*/
public static function getTableName($entityName) {
public static function getTableName(string $entityName) {
return self::getInfoItem($entityName, 'table_name');
}

Expand Down