Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.language

Do not return nullsafe access by reference

By-reference arrow functions cannot safely return nullsafe property access.

#Metadata

Rule ID
php.correctness.nullsafe-returned-by-reference
Severity
high
Confidence
0.92
Languages
php
Presets
strict
Stability
stable
Applies to
block
Tags
correctness, php, rules-catalog

#Why it matters

Nullsafe access may evaluate to null, which cannot be returned by reference and triggers runtime errors.

#Remediation

Return a value by copy, guard against null before returning a reference, or avoid by-reference arrow functions for nullable targets.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/php/php.correctness.nullsafe-returned-by-reference.rule.yaml.