Skip to content

Add PHP 8.2 strict types, PHPCS, and PHPStan linting#2

Merged
PatelUtkarsh merged 1 commit into
masterfrom
feature/php82-strict-linting
Feb 10, 2026
Merged

Add PHP 8.2 strict types, PHPCS, and PHPStan linting#2
PatelUtkarsh merged 1 commit into
masterfrom
feature/php82-strict-linting

Conversation

@PatelUtkarsh
Copy link
Copy Markdown
Owner

Summary

  • Bumps minimum PHP to >=8.2 and adds declare(strict_types=1) to all PHP files
  • Adds PHPCS (WordPress Coding Standards 3.0) and PHPStan (level 6 with WordPress extensions) as dev dependencies
  • Adds GitHub Actions CI workflow that runs both linters on push to master and on PRs

Changes

Composer

  • Min PHP >=8.2, type changed from package to library
  • Dev deps: wpcs ^3.0, phpcompatibility-wp ^2.1, phpstan ^2.0, szepeviktor/phpstan-wordpress ^2.0, dealerdirect/phpcodesniffer-composer-installer ^1.0
  • Scripts: phpcs, phpcbf, phpstan, lint

Code Quality Fixes

  • All esc_html__() calls now include the shadow-taxonomy text domain
  • File and class docblocks added to all files
  • @param tags added for WP-CLI command $args/$assoc_args parameters
  • Return type fixes in get_associated_post() and get_related_post_by_slug() (now properly returns WP_Post|false)
  • Simplified post_type_already_in_sync() — removed always-true isset checks and unreachable code
  • Intentional phpcs:ignore comments for slow DB queries and unused public API parameters

New Files

  • phpcs.xml.dist — WordPress coding standards config
  • phpstan.neon.dist — PHPStan level 6 config (CLI file excluded from analysis due to missing WP-CLI stubs)
  • .github/workflows/lint.yml — CI pipeline

Breaking Changes

Adding declare(strict_types=1) means PHP will enforce strict type checking for function arguments in these files. Callers passing incorrect types (e.g. string where int is expected) will now get TypeError instead of silent coercion.

- Bump minimum PHP to >=8.2, add declare(strict_types=1) to all files
- Change composer type from package to library
- Add PHPCS with WordPress coding standards (WPCS 3.0)
- Add PHPStan at level 6 with szepeviktor/phpstan-wordpress
- Add GitHub Actions CI workflow for linting on push/PR
- Fix all esc_html__() calls to include shadow-taxonomy text domain
- Add file/class docblocks, @param tags for WP-CLI methods
- Suppress intentional slow query and unused parameter warnings
- Fix return type issues in get_associated_post and get_related_post_by_slug
- Simplify post_type_already_in_sync (remove always-true isset checks)
@PatelUtkarsh PatelUtkarsh merged commit 27ff272 into master Feb 10, 2026
2 checks passed
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.

1 participant