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

Fix php comments #22515

Merged
merged 1 commit into from
Jan 16, 2022
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
11 changes: 7 additions & 4 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2556,19 +2556,22 @@ public static function getContactActivitySelector(&$params) {

/**
* Get the right links depending on the activity type and other factors.
*
* @param array $values
* @param int $activityId
* @param ?int $contactId
* @param int|null $contactId
* @param bool $isViewOnly Is this a special type that shouldn't be edited
* @param ?string $context
* @param ?int $mask
* @param bool $dontBreakCaseActivities Originally this function was
* @param string|null $context
* @param int|null $mask
* @param bool $dontBreakCaseActivities
* Originally this function was
* part of another function that was only used on the contact's activity
* tab and this parameter would only be false when you're not displaying
* case activities anyway and so was effectively never used. And I'm not
* sure why for the purposes of links you would ever want a case activity
* to link to the regular form, so I think this can be removed, but am
* leaving it as-is for now.
*
* @return string HTML string
*/
public static function getActionLinks(
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ public static function getWhereClause($params, $fields, &$tables, &$whereTables,
* Search on primary location. See note below.
* @param int $mode
* Determines search mode based on bitwise MODE_* constants.
* @param string|NULL $apiEntity
* @param string|null $apiEntity
* Determines search mode based on entity by string.
*
* The $primaryLocation flag only seems to be used when
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Task/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function setDefaultValues() {
/**
* Process the form after the input has been submitted and validated.
*
* @param array|NULL $params
* @param array|null $params
*/
public function postProcess($params = NULL) {
$fv = $params ?: $this->controller->exportValues($this->_name);
Expand Down
7 changes: 4 additions & 3 deletions CRM/Contact/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,12 +815,13 @@ public static function isOrQuery() {
*
* @param int $cid
* @param int $oid
* @param "dupe-nondupe|nondupe-dupe" $oper
Copy link
Contributor

@braders braders Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param dupenondupe|nondupedupe $oper is defining that the param should be either a dupenondupe or nondupedupe class - not quite what was expected.

Currently the de-facto standards (https://docs.phpdoc.org/guide/references/phpdoc/types.html and https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md only allow for @param string @oper which the available strings documented as a comment.

If prefered, we could do 'dupenondupe'|'nondupedupe' which whilst non-standard, is a format supported by at least one tool (https://psalm.dev/docs/annotating_code/typing_in_psalm/). There is also discussion of other syntaxes here, but unfortunately without much consensus phpDocumentor/phpDocumentor#557.

So probably sticking with @param string @oper for now is best.

(note this applies to the change in CRM/Core/BAO/CustomField.php too)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@braders yep that definiely seems to be the easier approach. I had it in mind that there was a way to list available strings that is agreed - I think the definitive place for standards is psr5 now - https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md - but I haven't read it through

* @param string $oper
* 'nondupe-dupe' or 'dupe-nondupe'
*
* @return \CRM_Core_DAO|mixed|null
*/
public static function markNonDuplicates($cid, $oid, $oper) {
if ($oper == 'dupe-nondupe') {
if ($oper === 'dupe-nondupe') {
try {
civicrm_api3('Exception', 'create', ['contact_id1' => $cid, 'contact_id2' => $oid]);
return TRUE;
Expand All @@ -841,7 +842,7 @@ public static function markNonDuplicates($cid, $oid, $oper) {
$exception->find(TRUE);
$status = NULL;

if ($oper == 'nondupe-dupe') {
if ($oper === 'nondupe-dupe') {
$status = $exception->delete();
}
return $status;
Expand Down
8 changes: 6 additions & 2 deletions CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2708,12 +2708,16 @@ private static function getOptionsForField(&$field, $optionGroupName) {
}

/**
* Prepare params for the create operation.
*
* @param CRM_Core_DAO_CustomField $field
* @param 'add|modify|delete' $operation
* @param string $operation
* add|modify|delete
*
* @return array
* @throws \CRM_Core_Exception
*/
protected static function prepareCreateParams($field, $operation) {
protected static function prepareCreateParams($field, $operation): array {
$tableName = CRM_Core_DAO::getFieldValue(
'CRM_Core_DAO_CustomGroup',
$field->custom_group_id,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function isDBUpdateRequired() {
/**
* Checks that the current DB schema is at least $min version
*
* @param string|number $min
* @param string|int $min
* @return bool
*/
public static function isDBVersionAtLeast($min) {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/BAO/SchemaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static function buildPrimaryKeySQL($params, $separator, $prefix) {
* @param array $params
* @param string $separator
* @param string $prefix
* @param string|NULL $existingIndex
* @param string|null $existingIndex
*
* @return NULL|string
*/
Expand Down Expand Up @@ -609,7 +609,7 @@ public static function addIndexSignature($table, &$indices) {
* @param bool $dropFalseIndices
* If set - this function deletes false indices present in the DB which mismatches the expected
* values of xml file so that civi re-creates them with correct values using createMissingIndices() function.
* @param array|FALSE $tables
* @param array|false $tables
* An optional array of tables - if provided the results will be restricted to these tables.
*
* @return array
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function getEntityFields() {
* Given a constant list of of id/name/label options, convert to the
* format required by pseudoconstant.
*
* @param string|NULL $context
* @param string|null $context
* @param array $options
* List of options, each as a record of id+name+label.
* Ex: [['id' => 123, 'name' => 'foo_bar', 'label' => 'Foo Bar']]
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ public static function getWeight($ufGroupId = NULL) {
* @param bool $skipPermission
* @param int $op
* Which operation (view, edit, create, etc) to check permission for.
* @param array|NULL $returnFields list of UFGroup fields to return; NULL for default
* @param array|null $returnFields
*
* @return array
* array of ufgroups for a module
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Payment/BaseIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private function cancelParticipant($participantID) {
* @todo This is part of a bigger refactor for dev/core/issues/927 - "duplicate" functionality exists in CRM_Contribute_BAO_Contribution::cancel()
* @param \CRM_Member_BAO_Membership $membership
* @param int $membershipStatusID
* @param boolean $onlyCancelPendingMembership
* @param bool $onlyCancelPendingMembership
* Do we only cancel pending memberships? OR memberships in any status? (see CRM-18688)
* @fixme Historically failed() cancelled membership in any status, cancelled() cancelled only pending memberships so we retain that behaviour for now.
* @deprecated
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public static function isFullyFormedUrl($url) {
}

/**
* @param string|NULL $region
* @param string|null $region
* Optional request for a specific region. If NULL/omitted, use global default.
* @return \CRM_Core_Region
*/
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Resources/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class CRM_Core_Resources_Bundle implements CRM_Core_Resources_CollectionInterfac
public $name;

/**
* @param string|NULL $name
* @param string[]|NULL $types
* @param string|null $name
* @param string[]|null $types
* List of resource-types to permit in this bundle. NULL for a default list.
* Ex: ['styleFile', 'styleUrl']
* The following aliases are allowed: '*all*', '*default*', '*script*', '*style*'
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Resources/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CRM_Core_Resources_Common {
*
* @param string $name
* Symbolic name of the bundle.
* @param callable|NULL $init
* @param callable|null $init
* Optional initialization function. Populate default resources.
* Signature: `function($bundle): void`
* Example: `function myinit($b) { $b->addScriptFile(...)->addStyleFile(...); }`
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Smarty/plugins/modifier.print_array.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* Purpose: formats array for output in DAO files and in APIv3 Examples
* To find where this is used do a grep in Smarty templates for |@print_array
* @param array|object $var
* @param integer $depth
* @param integer $length
* @param int $depth
* @param int $length
* @return string
*/
function smarty_modifier_print_array($var, $depth = 0, $length = 40) {
Expand Down