1.2.221. Constant : With Or Without Use

This analysis collects the ways constants are called in the code : with a local import, alias or not, or with their fully qualified name.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

<?php

use const AA as BB;

// This is the fully qualified name.
echo \AA;

// If this is used 10 times or more, then it is the standard.
echo BB;

?>

1.2.221.1. Specs

Short name

Namespaces/ConstantWithUseFavorite

Rulesets

All, Preferences

Exakat since

2.3.9

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

fully-qualified-name, constant, use

Available in

Entreprise Edition, Exakat Cloud