BlogComparisons · October 23, 2026 · 7 min read

Contact Form 7 PHP Checks: PHPStan vs Psalm vs PHP_CodeSniffer vs PHP CS Fixer vs Rector

Choose PHP tools for reviewing CF7 custom code, from type analysis to coding standards and reviewed refactoring.

Code sheet surrounded by a magnifier, bracket blocks, ruler, brush and circular arrows.
Conceptual illustration; not a product screenshot or measured result.

Custom Contact Form 7 code can fail before a visitor ever reaches a submission test. A callback might receive the wrong type, a branch might return an unexpected value, or a broad automated rewrite might change behavior. PHPStan, Psalm, PHP_CodeSniffer, PHP CS Fixer and Rector address different parts of that review.

This is a task-based comparison of development tools, based on official documentation and upstream licenses checked on October 23, 2026. It is not a benchmark or a claim that these tools were run against your CF7 installation. We operate CF7 Analytics; none of these five tools is our product. For choosing runtime test frameworks, see the separate integration-test comparison.

Start with the question your check must answer

Type analysis, coding-standard checks, formatting and refactoring are different activities. None automatically establishes that a CF7 hook runs at the right time or that the intended email reaches its destination. Scope the tool to your custom plugin or integration code, preserve the production source, and review changes in a development checkout before staging them.

Product Primary job Useful CF7 task Main boundary
PHPStan Static type and logic analysis Review typed mapping and callback code Needs accurate symbol and type knowledge
Psalm Type analysis with optional taint analysis Review data flow in custom adapters Dynamic hooks need modeling
PHP_CodeSniffer Ruleset-based coding-standard checks Apply WordPress code conventions Depends on installed sniffs
PHP CS Fixer Formatting and configured code transformations Keep maintained custom code consistent Writes require diff review
Rector Automated refactoring and upgrades Modernize a bounded custom-code module Does not infer business intent

PHPStan

PHPStan analyzes PHP source for issues such as invalid argument usage and incompatible types. Its configurable strictness makes gradual adoption possible. In a CF7 customization, it is especially useful when raw input is converted into a clearly defined array or object before reaching an external service.

Strengths: early feedback on the code you own and an incremental route toward stronger type definitions. A small adapter with declared inputs and outputs gives the analyzer something concrete to check. Include the necessary definitions for WordPress, CF7 and your dependencies through suitable discovery or stubs; unknown symbols should be investigated before they are suppressed.

Limitations: PHPStan cannot know every dynamically registered hook contract by intuition. An inaccurate stub can make incorrect code look acceptable. A baseline records accepted existing findings; it is not proof they were fixed. The core is MIT-licensed and free. PHPStan Pro is a separate paid offering, not required for this core comparison. Choose PHPStan when type-driven feedback fits your team and you can maintain the project model.

Psalm

Psalm is another static analyzer, with type-related checks and optional taint analysis. For CF7 integration code, its useful question is how data moves from an untrusted answer through validation and transformation toward a destination. That is broader than whether the final PHP file parses.

Strengths: detailed types and a way to model data flow. A custom connector that reads a field, constructs a payload and calls a service can benefit from explicit source and sink definitions. Keep the modeled boundary small enough to understand, and write down which WordPress and CF7 functions your configuration recognizes.

Limitations: taint analysis is only as informative as its coverage and configuration. It does not certify an installation as secure, and a dynamic callback system may need additional annotations or extensions. Investigate findings rather than adding a blanket suppression around every WordPress interaction. Psalm’s upstream core is MIT-licensed and has no software license charge. Choose it when your team values its type system and has time to maintain meaningful analysis configuration, especially for custom data-handling code.

PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP and reports violations of a selected coding standard. Its companion phpcbf can correct supported violations. For WordPress work, the separately installed WordPress Coding Standards rulesets provide relevant conventions rather than assuming the tool’s default rules cover the platform.

Strengths: repeatable review criteria and findings that can be tied to individual source locations. It is a useful first layer for a team maintaining CF7 callbacks in a small custom plugin. A shared ruleset reduces arguments about formatting and can surface selected WordPress-specific patterns, depending on the sniffs enabled.

Limitations: checking a standard is not the same as proving the callback’s runtime behavior. Install and configure the intended rules, then read their findings in context. Keep reporting and automatic fixing as separate review steps. PHP_CodeSniffer is BSD-3-Clause licensed; the WordPress Coding Standards package has its own MIT license. Both cores are available without license fees. Choose it when WordPress conventions and consistent team review are the immediate need.

PHP CS Fixer

PHP CS Fixer applies configured formatting and code-transformation rules. Its check or dry-run mode can show the work needed before modifying files. This makes it useful for consistent maintenance of the custom code surrounding CF7, especially when different contributors otherwise produce noisy style changes.

Strengths: repeatable changes and a reviewable diff. Define the owned paths and rules in project configuration, exclude generated or third-party code, and begin with a non-writing check. A narrow pass over one maintained module is easier to assess than a repository-wide rewrite mixed with a form behavior change.

Limitations: some rules are explicitly classed as risky because they may change behavior. Do not enable them merely to obtain a clean report. Coordinate overlapping formatting tools so they do not continually reverse each other’s decisions. The upstream code is MIT-licensed and free; development, review and CI execution still have costs. Choose it when automatic consistency is the main goal and the team will inspect diffs before deployment.

Rector

Rector performs configured automated refactoring and upgrades. It can help modernize a custom integration module as the supported PHP version changes. Its role is transforming selected patterns, rather than providing a general pass/fail verdict on a CF7 workflow.

Strengths: systematic transformations and a dry-run view of proposed edits. Set the target PHP and library context deliberately, select a small rule set and review one bounded change at a time. For a CF7 project, start with code you maintain instead of rewriting the vendor plugin, where your edits would be replaced during an update.

Limitations: Rector cannot infer why a business rule routes a particular inquiry or whether an external connector expects a particular payload shape. An upgrade-oriented transformation still needs behavior checks. Large rule sets can produce a diff that is difficult to review accurately. The upstream core is MIT-licensed and free; commercial assistance is a separate service. Choose it for a planned code modernization task with an explicit target and verification budget.

Use a representative CF7 customization

Compare the tools on the same small module, such as a custom validation callback or a payload-building adapter. First record its expected inputs, outputs and hook registration. Include one invalid input case, one optional empty value and one downstream failure in your behavioral checks. Static tools can help inspect the source, while those cases establish what the running code does.

Keep original findings, configuration and the reviewed diff. If an analyzer reports an unknown CF7 function, correct the model before claiming a product defect. If a fixer changes formatting, do not describe that as fixing a broken submission. The hook-boundary guide helps keep mail lifecycle claims precise, and the custom-validation guide provides a narrow business-rule context.

Choose a combination you can maintain

For type feedback, evaluate PHPStan or Psalm against your actual code model. For WordPress conventions, PHP_CodeSniffer with the relevant rules is a natural starting point. Add PHP CS Fixer when you want a reviewed formatting workflow, and use Rector for deliberate modernization. These are complementary jobs; installing all five is not a requirement.

Pin development dependencies, document the command and keep automatic writes away from production. Count the time needed to understand findings and maintain stubs, not just the zero-dollar core license price. A small, understood configuration is more useful than an impressive report whose warnings everyone ignores.

After deploying a verified customization, our free Svetlik Analytics for Contact Form 7 plugin can support submission statistics. This is our product’s website. Statistics complement operational review; they do not establish static-analysis coverage, connector correctness, visitor abandonment or inbox delivery.

Sources and licenses