Problem/Motivation

In #3406971: Non-silenced deprecation message in \Drupal\options\Plugin\Field\FieldType\ListItemBase::extractAllowedValues we discovered that there are unsilenced (so without the @-prefix) deprecation warnings.

I wondered if Coder could help us out to detect them.
Building on the excellent FunctionTriggerErrorSniff that might be quite easy.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Spokje created an issue. See original summary.

spokje’s picture

Issue summary: View changes
spokje’s picture

Status: Active » Needs review
klausi’s picture

Status: Needs review » Needs work

Thanks, just one minor comments from me.

Could this disrupt custom Drupal projects where developers use trigger_error() for deprecations in their own project? Maybe this is not common. Developers can also disable individual rules, so there are workarounds in such a case.

In my projects we don't use trigger_error() and mostly rely on custom PHPStan rules that flag deprecated function invocations.

spokje’s picture

Status: Needs work » Needs review

Thanks for the review @Klausi!

Added fixer and addressed your comments.

Could this disrupt custom Drupal projects where developers use trigger_error() for deprecations in their own project?

If and when core turns this rule on it would.

Maybe this is not common.

Found 5 occurrences with http://codcontrib.hank.vps-private.net/search?text=E_USER_DEPRECATED&fil...
One of them (bat) even has a convenient // phpcs:ignore straight above it.

So I would say not very common indeed, and as you said disable-able if no @ there on purpose.

  • 40d9024d committed on 8.3.x
    feat(UnsilencedDeprecation): Add sniff for unsilenced trigger_error()...
klausi’s picture

Status: Needs review » Fixed

Ok, then let's do this! Thanks a lot for your patience and rerolling.

klausi’s picture

Forgot credits.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.