Skip to content

Commit

Permalink
[phpstorm-stubs] WI-72923 add ObjectShape attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
isfedorov committed Jun 18, 2023
1 parent 1b9d13f commit c3394be
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions meta/attributes/ObjectShape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace JetBrains\PhpStorm;

use Attribute;

/**
* The attribute specifies possible object field names and their types.
*
* If applied, an IDE will suggest the specified field names and infer the specified types.
*
* Example:
* <pre>#[ObjectShape(["age" => "int", "name" => "string"])]</pre>
*
* This usage applied on an element effectively means that the object has 2 fields, the names are <code>"age"</code> and <code>"name"</code>, and the corresponding types are <code>"int"</code> and <code>"string"</code>.
*/
#[Attribute(Attribute::TARGET_FUNCTION|Attribute::TARGET_METHOD|Attribute::TARGET_PARAMETER|Attribute::TARGET_PROPERTY)]
class ObjectShape
{
public function __construct(array $shape) {}
}

0 comments on commit c3394be

Please sign in to comment.