Skip to content

blockstudio/phpstan: report unknown field properties in block.json and field.json #190

Closed

Description

@Contributolo

BlockJsonShapeRule and FieldJsonShapeRule check a field's type and the nesting of containers, but not its properties. A misspelled property passes the analysis and then silently does nothing.

Example from a theme on 7.7.9 with blockstudio/phpstan 0.1.10: a text field with "translat": false instead of "translate": false. The analysis reports nothing, wp bs wpml config declares the field as translatable again, and nothing points at the typo. The same happens with editor texts such as textRemov, textMinimized on the wrong field type, or minimized on a non-repeater.

schemas/block.json already lists the properties of each field type (and is additionalProperties-closed only in a few places), so the rules could report a property that the schema does not know for that type, with the closest known name as a suggestion, similar to the existing "Did you mean" for $a['…'] access. For example:

block.json field "konto" has unknown property "translat". Did you mean "translate"?

Questions before I send a PR:

  1. Is the schema the right source of truth for the allowed properties per type, or is there a list in PHP you would rather use?
  2. Should unknown properties be an error, or a separate identifier (for example blockstudio.blockJson.unknownProperty) so projects with custom keys can ignore it?
  3. Custom field types from bs_register_field_type(): skip them, or check only the shared properties (id, label, help, conditions, …)?

Activity

  1. dnnsjsk commented on Oct 28, 2026

    @dnnsjsk
    Contributor

    Released in Blockstudio PHPStan 0.1.12, alongside Blockstudio 7.7.10.

    Unknown and misplaced built-in field properties are now reported in block.json and field.json, including nested fields, with type-aware typo suggestions and separately suppressible diagnostic identifiers. Implemented by #192, with schema alignment in #191.

    Update the standalone extension with:

    composer require --dev blockstudio/phpstan:^0.1.12

    The complete CI and distribution checks passed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions