Skip to content

Commit

Permalink
constants: Fix type for set_constant() value (#37606)
Browse files Browse the repository at this point in the history
PHP's `define()` allows any of int|float|string|bool|array|null, so
let's go with that to match.

This fixes 57 Phan issues across the monorepo.

---

Just as I was about to create this PR, #36968 changed it to `scalar`.
Which fixed 54 of those 57 errors, but as it left out the possibility of
array and null 3 were still left.
  • Loading branch information
anomiex authored May 28, 2024
1 parent 1b8cb0f commit f8d5a25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 1 addition & 4 deletions projects/packages/constants/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
* (can be combined with --load-baseline)
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgumentProbablyReal : 3 occurrences

// This baseline has no suppressions
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'tests/php/test-constants.php' => ['PhanTypeMismatchArgumentProbablyReal'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix phpdoc type on `Constants::set_constant()` value parameter.
4 changes: 2 additions & 2 deletions projects/packages/constants/src/class-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static function get_constant( $name ) {
/**
* Sets the value of the "constant" within constants Manager.
*
* @param string $name The name of the constant.
* @param scalar $value The value of the constant.
* @param string $name The name of the constant.
* @param int|float|string|bool|array|null $value The value of the constant.
*/
public static function set_constant( $name, $value ) {
self::$set_constants[ $name ] = $value;
Expand Down

0 comments on commit f8d5a25

Please sign in to comment.