Skip to content

A manager for all your magic strings ints and so on. This will help you manage the constants in your project

License

Notifications You must be signed in to change notification settings

GameFixxer/php-constant-manager

Repository files navigation

phpstorm-constant-manager-plugin

Build Version Downloads

Template ToDo list

Php Constant Manager - Replace Magic Variables with Constants Effortlessly The Php Constant Manager plugin automates the process of identifying and refactoring "magic variables" (hard-coded string and integer literals) within PHP classes. It traverses your code, extracts these literals, and generates appropriate constants, enhancing code maintainability and reducing potential errors.

Key Features:

Automated Refactoring: Automatically detect and replace hard-coded string and integer literals in your PHP classes with well-named constants. Intelligent Naming: Generates meaningful constant names based on the literal's context, ensuring that your code remains clean and understandable. Selective Processing: Skips test classes and already defined constants, focusing only on parts of your code that need refactoring. Easy Integration: Integrates seamlessly into PhpStorm's workflow, triggered through a simple action within the IDE. Usage Instructions:

Install the Php Constant Manager plugin through the JetBrains Plugin Marketplace. Open any PHP file within PhpStorm and navigate to a class with hard-coded literals. Trigger the action by right-clicking within the editor or through the "Replace Magic Variables" -> "automatic" action in the command palette. The plugin will analyze the file, generate constants, and replace the literals, providing log information about the changes made. This plugin is ideal for developers looking to enhance code quality by reducing the reliance on hard-coded values and ensuring that constants are used consistently throughout the codebase.

Installation

  • Using the IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "php-constant-manager" > Install

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...


Plugin based on the IntelliJ Platform Plugin Template.

About

A manager for all your magic strings ints and so on. This will help you manage the constants in your project

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published