Skip to content

fix: satisfy PHPStan 2.2.3#10364

Open
memleakd wants to merge 2 commits into
codeigniter4:developfrom
memleakd:fix/phpstan-2-2-3
Open

fix: satisfy PHPStan 2.2.3#10364
memleakd wants to merge 2 commits into
codeigniter4:developfrom
memleakd:fix/phpstan-2-2-3

Conversation

@memleakd

@memleakd memleakd commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes PHPStan failures after phpstan/phpstan started resolving to 2.2.3.

PHPStan now narrows ob_get_contents() / ob_get_clean() / ob_get_flush() / ob_get_length() to non-false while output buffering is active: phpstan/phpstan-src#5909

Because of that, a few existing output-buffering tests now report redundant ob_get_level() > 0 checks, and helper return types can be narrowed from false|string to string.

There is no behavior change.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

- Remove redundant output-buffer level checks after ob_start()
- Narrow output-buffer helper return types

Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While these changes make sense for the test files, I don't think command() should be treated the same way. It executes arbitrary command code that may alter the output buffer state, so we cannot assume the buffer remains active.

Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
@memleakd

memleakd commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

While these changes make sense for the test files, I don't think command() should be treated the same way. It executes arbitrary command code that may alter the output buffer state, so we cannot assume the buffer remains active.

Good point, thanks. Updated it to handle that case explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants