Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Proposal: Forbidding constant "overriding"

Open
#37 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
devtools

Research direction

Start with the proposal and its linked Slevomat coding-standard request, then investigate PHP constant overriding with static:: and $object::. Define how the tree-member NAME edge case should be treated and identify the relevant rule entry point and tests; the work is complete when the scope and expected diagnostics are agreed.

Written by the indexing model from the issue text.

Description

Const overrides violate const invariants and are not LSP-compliant (types can be changed randomly).

There may be dragons when constants are used with static:: (sniff request to forbid that: https://github.com/slevomat/coding-standard/issues/473) or $object::.

Any occurence of a constant override should be (abstract) method instead.

Edge case: constants like NAME on each member of a tree?

Dominant language
PHP
Stars
711
Forks
62
Avg merge
35m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-strict-rules

All issues in phpstan/phpstan-strict-rules

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.