ConstantName.ConstantStart sniff is broken in 8.3.19 and 8.3.20

Created on 26 June 2023, about 1 year ago
Updated 18 July 2023, 12 months ago

Problem/Motivation

As of coder 8.3.19, define() constants in quotes (either single or double) start throwing warnings about incorrect module name prefixes.

<?php

/**
 * @file
 * Code for the OCT integration.
 */

/**
 * OCT URL.
 */
define('OCHA_OCT_API_URL', "https://example.org/");
FILE: .../ocha_oct/ocha_oct.module
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 11 | WARNING | All constants defined by a module must be prefixed with the module's name, expected "OCHA_OCT_'OCHA_OCT_API_URL'" but found
    |         | "'OCHA_OCT_API_URL'"
------------------------------------------------------------------------------------------------------------------------

Time: 222ms; Memory: 12MB

Steps to reproduce

Install coder 8.3.19 or newer, run PHPCS against a file containing the above code snippet, see the warning.

Downgrade to coder 8.3.18, file passes checks without warnings.

🐛 Bug report
Status

Fixed

Version

8.3

Component

Coder Sniffer

Created by

🇦🇺Australia cafuego

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024