# jetbrains **Repository Path**: edims/jetbrains ## Basic Information - **Project Name**: jetbrains - **Description**: php8 phpstorm注解帮助 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-01 - **Last Updated**: 2026-02-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JetBrains PhpStorm Attributes Library ## Introduction This is a PHP library containing various attribute annotations required by the JetBrains PhpStorm IDE. These attributes are features introduced in PHP 8, used to provide additional type information and metadata to PhpStorm, enabling more accurate code completion, type checking, and error detection. All attributes in this library are defined under the `JetBrains\PhpStorm` namespace and can be used directly in your project. ## Features This library provides a rich set of attribute annotations covering the following scenarios: - **Type Definition**: Define the exact structure of arrays using `ArrayShape` - **Deprecation Marking**: Use `Deprecated` to mark deprecated code and provide replacement suggestions - **Expected Value Constraints**: `ExpectedValues` restricts permissible values for parameters or properties - **Immutability Constraints**: `Immutable` marks properties or classes as immutable - **Pure Function Identification**: `Pure` marks functions as side-effect-free - **Special Return Types**: `NoReturn` identifies functions that never return - **Language Specifications**: `Language` specifies type hints for specific language versions ## System Requirements - PHP 8.0 or higher - A PHP framework or IDE supporting PHP attributes ## Installation Install via Composer: ```bash composer require jetbrains/phpstorm-attributes ``` ## Core Attributes ### ArrayShape Defines the exact structure of an array, helping the IDE understand the keys and types of each element. ```php use JetBrains\PhpStorm\ArrayShape; #[ArrayShape([ 'id' => 'int', 'name' => 'string', 'email' => 'string|null' ])] function getUser(): array { // ... } ``` ### Deprecated Marks code elements as deprecated, with optional reason, replacement, and recommended PHP version. ```php use JetBrains\PhpStorm\Deprecated; #[Deprecated('Use newMethod() instead', 'newMethod', '8.0')] function oldMethod(): void { // ... } ``` ### ExpectedValues Restricts the allowed values for parameters or properties, supporting values from class constants. ```php use JetBrains\PhpStorm\ExpectedValues; function configureOption( #[ExpectedValues(['debug', 'release'])] string $mode ): void { // ... } ``` ### Immutable Marks properties or classes as immutable, ensuring their values cannot be modified after initialization. ```php use JetBrains\PhpStorm\Immutable; #[Immutable] class Configuration { #[Immutable(Immutable::PRIVATE_WRITE_SCOPE)] public string $name; } ``` ### Pure Marks a function as pure—i.e., it has no side effects and its return value depends solely on its input parameters. ```php use JetBrains\PhpStorm\Pure; #[Pure] function calculate(int $a, int $b): int { return $a + $b; } ``` ### NoReturn Marks functions that never return (e.g., those that throw exceptions or call `exit()`). ```php use JetBrains\PhpStorm\NoReturn; #[NoReturn] function terminate(): void { // Log and exit exit(1); } ``` ## Internal Attributes The following attributes are primarily intended for internal use by PhpStorm and generally do not need to be used directly by developers: - `LanguageLevelTypeAware`: Provides type awareness based on PHP language level - `PhpStormStubsElementAvailable`: Marks stub elements available in specific PHP versions - `ReturnTypeContract`: Provides constraints for conditional return types ## Version Compatibility The `Deprecated` attribute in this library supports deprecation markers for the following PHP versions: - 5.3 - 5.6 - 7.0 - 7.4 - 8.0 ## Contribution Guidelines Contributions from the community are welcome! Please ensure: 1. Follow PSR code standards 2. Add appropriate unit tests 3. Update relevant documentation 4. Submit clear and meaningful commit messages ## License This project is licensed under the [MIT License](LICENSE). ## Related Resources - [PhpStorm Official Documentation](https://www.jetbrains.com/phpstorm/) - [PHP Attributes Documentation](https://www.php.net/manual/en/language.attributes.php) - [Project Issues](https://gitee.com/edims/jetbrains/issues)