Skip to content

Add declare( strict_types = 1 ) to all PHP files#2424

Open
meravi wants to merge 12 commits intoWordPress:trunkfrom
meravi:add-strict-types
Open

Add declare( strict_types = 1 ) to all PHP files#2424
meravi wants to merge 12 commits intoWordPress:trunkfrom
meravi:add-strict-types

Conversation

@meravi
Copy link
Copy Markdown

@meravi meravi commented Mar 20, 2026

Adds declare( strict_types = 1 ); to all PHP source files across the monorepo.
Fixes #2348

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 20, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: meravi <ravikhadka@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@meravi
Copy link
Copy Markdown
Author

meravi commented Mar 24, 2026

@westonruter would appreciate a quick look when you have a moment 🙏

performance.php Outdated
@@ -1,4 +1,5 @@
<?php
declare( strict_types = 1 );
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.

Should be after the plugin info.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, thanks! Moved it after the plugin header.

@westonruter westonruter added the [Type] Enhancement A suggestion for improvement of an existing feature label Mar 24, 2026
@westonruter westonruter added this to the performance-lab n.e.x.t milestone Mar 24, 2026
performance.php Outdated
* @package performance
*/

declare( strict_types = 1 );
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.

Suggested change
declare( strict_types = 1 );
declare( strict_types = 1 );

Copy link
Copy Markdown
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

In addition to the trivial PHPCS issue which I left a suggestion for, there are unit test failures related to the new strict types. This will need to be fixed.

@westonruter
Copy link
Copy Markdown
Member

@meravi why remove the strict types? The underlying type problem should be fixed so the strict types can exist in all the files.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.33%. Comparing base (404dcd1) to head (3b461d2).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2424   +/-   ##
=======================================
  Coverage   69.33%   69.33%           
=======================================
  Files          90       90           
  Lines        7749     7749           
=======================================
  Hits         5373     5373           
  Misses       2376     2376           
Flag Coverage Δ
multisite 69.33% <100.00%> (ø)
single 35.73% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@meravi
Copy link
Copy Markdown
Author

meravi commented Mar 25, 2026

I reverted it temporarily for testing, but it’s added back now.
@westonruter

@meravi meravi requested a review from westonruter March 25, 2026 08:50
@westonruter
Copy link
Copy Markdown
Member

@meravi ok, you can see that the unit tests are still failing. Once they are passing this will be ready for review.

@westonruter westonruter marked this pull request as draft March 25, 2026 22:54
@meravi
Copy link
Copy Markdown
Author

meravi commented Mar 26, 2026

@meravi ok, you can see that the unit tests are still failing. Once they are passing this will be ready for review.

I’ve fixed the issues, and the unit tests are now passing 🟢
Ready for review when you have a moment :)

…options/helper.php

Co-authored-by: Weston Ruter <westonruter@gmail.com>
meravi and others added 3 commits March 26, 2026 10:53
…options/helper.php

Co-authored-by: Weston Ruter <westonruter@gmail.com>
…options/helper.php

Co-authored-by: Weston Ruter <westonruter@gmail.com>
@mukeshpanchal27 mukeshpanchal27 marked this pull request as ready for review March 26, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider declaring strict_types

3 participants