“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.



You can also introduce constants in string literals



Develop with pleasure!

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

This entry was posted in Cool Feature, PhpStorm and tagged , , . Bookmark the permalink.

3 Responses to “Introduce Constant” refactoring for PHP

  1. OZ says:

    Has used today – very handy :)

  2. ragtek says:

    The help doesn’t work.

    When clicking on the help button
    http://blogs.jetbrains.com/webide/wp-content/uploads/2011/02/introduce_constant_1_before.png i’m getting this error:

    Help topic “refactoring.introduceConstant” not found

  3. Nikolay Matveev says:

    Thanks for report! We have took steps.

Comments are closed.