Skip to content

Commit

Permalink
Merge pull request #25706 from eileenmcnaughton/strict
Browse files Browse the repository at this point in the history
Stricter typing in Apiv4
  • Loading branch information
eileenmcnaughton authored Mar 1, 2023
2 parents 1c922f2 + 76e83c2 commit 716a8dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit 716a8dc

Please sign in to comment.