Alias for a define() function

Hello,

 

Let's say I have the following code:

 

<?php
define('TEST', 'a');

echo TEST;

 

I would like to replace the define() function with a wrapper, like so:

<?php

function config($key, $value) {
    define($key, @$_ENV[$key] ?: $value);
}

config('TEST', 'a');

echo TEST;

 

The problem is that now PhpStorm tells me that the `echo` line contains an undefined constant, and I also lose the ability to Cmd + Click on the constant name to find it's usages.

 

Is there a way to tell PhpStorm to treat the custom function as the define() function and keep all the functionality of the IDE the same?

 

 

Thanks!

0
2 comments

Hi there,

Unfortunately, it is not possible at the moment and IDE is unable to detect constants with dynamically assigned names. I have submitted a feature request, please feel free to vote & comment on:

https://youtrack.jetbrains.com/issue/WI-68688

1

Please sign in to leave a comment.