Features Releases

“Introduce Constant” refactoring for PHP

The “Introduce Constant” refactoring is very similar to the “Introduce Variable” refactoring – it creates a constant which holds the selected expression as the value and replaces it occurrences by reference to this newly created constant.


In order to invoke the refactoring, select an expression to be replaced with a constant or place the caret before such expression and press Ctrl+Alt+C(for Windows) or Cmd+Opt+C(for Mac).

The result of the refactoring depends on the context it is invoked in. If the refactoring is invoked inside a class, the constant will be introduced in the class. Otherwise, the constant will be introduced in the current file/namespace.

Before

After

You can also introduce constants in string literals

Before

After

Develop with pleasure!

image description