{"id":13608943,"url":"https://github.com/JetBrains/phpstorm-attributes","last_synced_at":"2025-04-12T17:33:20.241Z","repository":{"id":39295875,"uuid":"312297957","full_name":"JetBrains/phpstorm-attributes","owner":"JetBrains","description":"PhpStorm specific attributes","archived":false,"fork":false,"pushed_at":"2024-11-11T15:00:34.000Z","size":21,"stargazers_count":402,"open_issues_count":7,"forks_count":13,"subscribers_count":231,"default_branch":"master","last_synced_at":"2025-04-11T04:11:21.624Z","etag":null,"topics":["php8","phpstorm"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/jetbrains/phpstorm-attributes","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JetBrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T14:16:29.000Z","updated_at":"2025-04-10T06:23:17.000Z","dependencies_parsed_at":"2024-04-23T11:01:23.898Z","dependency_job_id":"d4b96eb0-174e-40e5-a532-74fb19e0ef32","html_url":"https://github.com/JetBrains/phpstorm-attributes","commit_stats":{"total_commits":11,"total_committers":7,"mean_commits":"1.5714285714285714","dds":0.7272727272727273,"last_synced_commit":"45d6bef62cfcb07f8db1f4253f078beb572cbd73"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fphpstorm-attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fphpstorm-attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fphpstorm-attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetBrains%2Fphpstorm-attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JetBrains","download_url":"https://codeload.github.com/JetBrains/phpstorm-attributes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248605418,"owners_count":21132165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php8","phpstorm"],"created_at":"2024-08-01T19:01:31.203Z","updated_at":"2025-04-12T17:33:15.229Z","avatar_url":"https://github.com/JetBrains.png","language":"PHP","readme":"[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\n\n# PhpStorm attributes\n\nUse these PHP 8 attributes in PhpStorm to get more advanced code completion and analysis.\n\nLearn more in the [blog post](https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-4/).\n\n## Installation\nThe attributes are available in PhpStorm 2020.3 and later. They are bundled with PhpStorm so you don’t need to install them separately.\n\nIf you are using other static analysis tools and don’t want to get Class not found issues, then you might want to add the attributes package to your composer.json as a dev dependency:\n\n```\ncomposer require --dev jetbrains/phpstorm-attributes\n```\n\n## `#[Deprecated]`\nUse this attribute when you want to notify users that an entity will be removed in the future.\n\nProvide the explanation tip in `reason`  and updating suggestion in `replacement`.\n\n```PHP\n#[Deprecated(\n    reason: 'since Symfony 5.2, use setPublic() instead',\n    replacement: '%class%-\u003esetPublic(!%parameter0%)'\n)]\n```\n![Deprecated](https://blog.jetbrains.com/wp-content/uploads/2020/10/deprecated_symfony.gif)\n\n## `#[ArrayShape]`\nUse Array Shape when you deal with object-like arrays and want to specify the keys’ names and types for values to get better coding assistance.\n\n```PHP\n#[ArrayShape([\n // 'key' =\u003e 'type',\n    'key1' =\u003e 'int',\n    'key2' =\u003e 'string',\n    'key3' =\u003e 'Foo',\n    'key3' =\u003e App\\PHP8\\Foo::class,\n])]\nfunction functionName(...): array\n```\n\n\u003e The attribute works with PHP ≤ 7.4 if specified in one line.\n\n![ArrayShape](https://blog.jetbrains.com/wp-content/uploads/2020/10/arrayshape.gif)\n\n\n## `#[ObjectShape]`\nThe attribute specifies possible object field names and their types. If applied, an IDE will suggest the specified field names and infer the specified types.\n\n```PHP\n#[ObjectShape([\"age\" =\u003e \"int\", \"name\" =\u003e \"string\"])]\nfunction functionName(): object {...}\n\n$obj = functionName();\n```\n\nThis usage effectively means that the `$obj` has 2 fields, the names are `age` and `name`, and the corresponding types are `int` and `string`.\n\n## `#[Immutable]`\nMark properties or entire objects with this attribute if you want to guarantee they won't be changed after initialization.\n\n```PHP\n#[Immutable]\nclass DTO\n{\n    public string $val;\n\n    public function __construct(string $val)\n    {\n        $this-\u003eval = $val;\n    }\n}\n```\n\n\u003e The attribute works with PHP ≤ 7.4 if specified in one line.\n\n![Immutable](https://blog.jetbrains.com/wp-content/uploads/2020/10/immutable.png)\n\n## `#[Pure]`\nUse this attribute for functions that do not produce any side effects. All such PHP internal functions are already marked in PhpStorm.\n\n```PHP\n#[Pure]\nfunction compare(Foo $a, Foo $b): int\n{\n    return $a-\u003ea \u003c=\u003e $b-\u003eb;\n}\n```\n\n![Pure](https://blog.jetbrains.com/wp-content/uploads/2020/10/pure_add.png)\n\n## `#[ExpectedValues]`\nUse this attribute to specify which values exactly a function accepts as parameters and which it can return. This will improve coding assistance.\n\n```PHP\nfunction response(\n    #[ExpectedValues(valuesFromClass: Response::class)] $httpStatusCode,\n    //...\n) {\n    //...\n}\n```\n\n![ExpectedValues](https://blog.jetbrains.com/wp-content/uploads/2020/10/count_expectedvalue.png)\n\n## `#[NoReturn]`\nMark functions that terminate script execution as exit points with this attribute to get a more accurate control flow analysis.\n\n```PHP\n#[NoReturn]\nfunction redirect(): void {\n   //...\n   exit();\n}\n```\n\n![NoReturn](https://blog.jetbrains.com/wp-content/uploads/2020/10/noreturn.gif)\n\n## `#[Language]`\nAdd this attribute to mark string parameters that contain text in some other [programming] language, for example, RegExp, SQL, and so on. This will improve highlighting and reveal additional features of PhpStorm for you.\n\n![Language](https://blog.jetbrains.com/wp-content/uploads/2020/12/attribute_language.gif)\n\n## Bugs and feature requests\nPlease report any issues to the PhpStorm issue tracker https://youtrack.jetbrains.com/newIssue?project=WI.\n\nPull requests are also welcome.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2Fphpstorm-attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJetBrains%2Fphpstorm-attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetBrains%2Fphpstorm-attributes/lists"}