This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270924 - Missing hint for invalid constant name
Summary: Missing hint for invalid constant name
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: issues@php
Depends on:
Reported: 2017-06-21 13:02 UTC by nexxer
Modified: 2017-06-21 13:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description nexxer 2017-06-21 13:02:04 UTC
Netbeans allows defining a constant with a dot (".") in it without raising an error.

PHP constants must be made up of the following characters (from the documentation):

"The name of a constant follows the same rules as any label in PHP. A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thusly: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"

Steps to reproduce:

error_reporting(E_ALL) ;
ini_set('display_errors', 1) ;
define('some.constant', 5) ;
echo some.constant ;

Expected behavior:

Netbeans should alert me that "some.constant" is an invalid constant due to the dot.

Actual behavior:

Netbeans allows this. Running the above code returns:

"Notice: Use of undefined constant some - assumed 'some' in test.php on line 7

Call Stack:
    0.0011     196328   1. {main}() test.php:0

Notice: Use of undefined constant constant - assumed 'constant' in test.php on line 7

Call Stack:
    0.0011     196328   1. {main}() test.php:0