Skip to content

ini_get() of a core setting no longer includes false - #14809

Merged
alies-dev merged 3 commits into
vimeo:masterfrom
alies-dev:ini-get-core-settings-return-type
Nov 24, 2026
Merged

alies-dev merged 3 commits into
vimeo:masterfrom
alies-dev:ini-get-core-settings-return-type

Conversation

@alies-dev

@alies-dev alies-dev commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Context

final class AllowMemoryConsumingRequest
{
    private static ?string $bootMemoryLimit = null;

    public function handle(): string
    {
        return self::$bootMemoryLimit ??= ini_get('memory_limit');
    }
}

Psalm reports PossiblyFalsePropertyAssignmentValue, FalsableReturnStatement and InvalidFalsableReturnType, because the call map types ini_get() as false|string for any setting. It returns false only for a setting nothing has registered, and memory_limit is always registered. PHPStan already knows this (IniGetReturnTypeExtension), so the usual workarounds conflict: a === false check or a (string) cast satisfies Psalm, but PHPStan reports it as always false or as a useless cast.

Solution

ini_get() of a literal core setting now returns string, so the example above has no issues. The settings are the ones PHPStan narrows: date.timezone, default_socket_timeout, max_execution_time, max_input_time, memory_limit and precision, plus max_memory_limit when analysing for PHP 8.5+. Any other setting, or a non-literal argument, keeps false|string.

Unlike PHPStan, the numeric settings are not numeric-string: ini_get() returns the raw INI text, so after ini_set('max_execution_time', '30s') or php -d max_input_time=30s it returns "30s".

The two (string) ini_get('memory_limit') casts in Psalm's own code became redundant and are removed.

ini_get() returns false only for a setting nothing has registered, so
the call map's false|string made code like
`$limit ??= ini_get('memory_limit')` report PossiblyFalse* issues.
Same settings PHPStan's IniGetReturnTypeExtension narrows.
@alies-dev alies-dev added the release:feature The PR will be included in 'Features' section of the release notes label Nov 24, 2026
@alies-dev alies-dev self-assigned this Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: decreased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 747 59.2 $\color{gray}{\textsf{-0.7\%}}$ 25 785 $\color{red}{\textsf{+1}}$ $\color{green}{\textsf{-2}}$ 53 052 $\color{green}{\textsf{-3}}$ 743 0
✅ symfony 3 619 219.0 $\color{gray}{\textsf{+2.9\%}}$ 51 753 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-1}}$ 100 487 $\color{green}{\textsf{-3}}$ 1 585 0
✅ doctrine-orm 381 27.5 $\color{gray}{\textsf{+0.5\%}}$ 3 453 6 194 0 0
✅ psl 618 30.5 $\color{gray}{\textsf{-2.5\%}}$ 1 396 5 647 1 0
✅ phpunit 427 20.9 $\color{gray}{\textsf{+0.6\%}}$ 1 590 2 403 18 0
✅ php-parser 226 13.9 $\color{gray}{\textsf{-0.4\%}}$ 17 113 21 177 0 0
✅ tempest 887 38.6 $\color{gray}{\textsf{+2.3\%}}$ 5 094 10 549 275 0
✅ amphp-amp 48 $\color{gray}{\textsf{+0.1\%}}$ 1.5 $\color{gray}{\textsf{+0.7\%}}$ 31 53 0 0
✅ webmozarts-assert 274 4.6 $\color{gray}{\textsf{-0.4\%}}$ 576 2 720 0 0
✅ guzzle-promises 46 1.6 $\color{gray}{\textsf{+1.2\%}}$ 155 433 2 0
✅ monolog 134 5.7 $\color{gray}{\textsf{+0.7\%}}$ 918 2 491 11 0
✅ drupal 4 767 155.5 $\color{gray}{\textsf{-6.8\%}}$ 97 829 $\color{red}{\textsf{+1}}$ $\color{green}{\textsf{-4}}$ 169 274 $\color{green}{\textsf{-8}}$ 575 0
✅ wordpress 2 012 119.1 $\color{gray}{\textsf{-6.1\%}}$ 143 502 $\color{red}{\textsf{+3}}$ $\color{green}{\textsf{-7}}$ 678 358 $\color{green}{\textsf{-11}}$ 505 1
Total 15 186 697.7 $\color{gray}{\textsf{-1.9\%}}$ 349 195 $\color{red}{\textsf{+5}}$ $\color{green}{\textsf{-14}}$ 1 052 838 $\color{green}{\textsf{-25}}$ 3 715 1
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +10 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Its wall time warns above +5 % (±5 % is noise); the other thresholds apply per project.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.
✅ laravel: issues +1 −2

Memory 1 747 → 1 747 MB (+0.0 %) · Wall 59.7 → 59.2 s (−0.7 %)

Weighted 53 055 → 53 052 (−3, −0.01 %): L3 −1

Issue type added removed
ArgumentTypeCoercion 1 1
PossiblyFalseArgument 0 1

Changed in place (1)

@​@​ src/Illuminate/Queue/Worker.php:1087 @​@​
- ArgumentTypeCoercion:  Argument 1 of ini_parse_quantity expects non-empty-string, but parent type false|string provided
- PossiblyFalseArgument: Argument 1 of ini_parse_quantity cannot be false, possibly non-empty-string value expected
+ ArgumentTypeCoercion:  Argument 1 of ini_parse_quantity expects non-empty-string, but parent type string provided
✅ symfony: issues +0 −1

Memory 3 619 → 3 619 MB (+0.0 %) · Wall 212.9 → 219.0 s (+2.9 %)

Weighted 100 490 → 100 487 (−3, <0.01 %): L3 −1

Issue type added removed
PossiblyFalseArgument 0 1

Removed (1)

  • src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php:38 PossiblyFalseArgument (error): Argument 1 of MemoryDataCollector::convertToBytes cannot be false, possibly string value expected
✅ drupal: issues +1 −4

Memory 4 767 → 4 767 MB (<0.1 %) · Wall 166.9 → 155.5 s (−6.8 %)

Weighted 169 282 → 169 274 (−8, <0.01 %): L2 −1 · L3 −2

Issue type added removed
InvalidPropertyAssignmentValue 1 1
PossiblyFalseArgument 0 2
RiskyTruthyFalsyComparison 0 1

Changed in place (1)

@​@​ core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php:87 InvalidPropertyAssignmentValue @​@​
- …declared type 'int' cannot be assigned type 'false|string'
+ …declared type 'int' cannot be assigned type 'string'

Removed (3)

  • core/lib/Drupal/Component/Utility/Environment.php:37 RiskyTruthyFalsyComparison (error): Operand of type false|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
  • core/modules/system/src/Hook/SystemRequirementsHooks.php:521 PossiblyFalseArgument (error): Argument 2 of Environment::checkMemoryLimit cannot be false, possibly null|string value expected
  • core/modules/system/src/Install/Requirements/SystemRequirements.php:352 PossiblyFalseArgument (error): Argument 2 of Environment::checkMemoryLimit cannot be false, possibly null|string value expected
✅ wordpress: issues +3 −7

Memory 2 012 → 2 012 MB (<0.1 %) · Wall 126.9 → 119.1 s (−6.1 %)

Weighted 678 369 → 678 358 (−11, <0.01 %): L2 −1 · L3 −3

Issue type added removed
MissingPropertyType 1 1
PossiblyFalseArgument 0 3
PossiblyInvalidArgument 1 1
PossiblyInvalidPropertyAssignmentValue 1 1
RiskyTruthyFalsyComparison 0 1

Changed in place (3)

@​@​ src/wp-admin/includes/class-wp-site-health.php:23 MissingPropertyType @​@​
- …does not have a declared type - consider false|string
+ …does not have a declared type - consider string

@​@​ src/wp-includes/ID3/getid3.php:417 PossiblyInvalidPropertyAssignmentValue @​@​
- …cannot be assigned possibly different type 'false|float|int|string'
+ …cannot be assigned possibly different type 'float|int|string'

@​@​ src/wp-includes/functions.php:8778 PossiblyInvalidArgument @​@​
- …expects int|null, but possibly different type false|float|int|string provided
+ …expects int|null, but possibly different type float|int|string provided

Removed (4)

  • src/wp-admin/includes/class-pclzip.php:1841 PossiblyFalseArgument (error): Argument 1 of trim cannot be false, possibly string value expected
  • src/wp-admin/includes/class-wp-debug-data.php:1882 RiskyTruthyFalsyComparison (error): Operand of type false|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
  • src/wp-includes/ID3/getid3.php:410 PossiblyFalseArgument (error): Argument 2 of preg_match cannot be false, possibly string value expected
  • src/wp-includes/ID3/getid3.php:413 PossiblyFalseArgument (error): Argument 2 of preg_match cannot be false, possibly string value expected

head 76427d6 · base 90dd884 (merge-base) · workflow run

@alies-dev alies-dev changed the title ini_get() of a core setting no longer includes false ini_get() of a core setting no longer includes false Nov 24, 2026
ini_get() returns the raw INI text, so ini_set('max_execution_time', '30s') or php -d max_input_time=30s leave a non-numeric value behind.
@alies-dev alies-dev added release:fix The PR will be included in 'Fixes' section of the release notes and removed release:feature The PR will be included in 'Features' section of the release notes labels Nov 24, 2026
@alies-dev
alies-dev merged commit 3b0dfbe into vimeo:master Nov 24, 2026
71 of 72 checks passed
@alies-dev
alies-dev deleted the ini-get-core-settings-return-type branch November 24, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix The PR will be included in 'Fixes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant