ArrayShape.php 871 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace JetBrains\PhpStorm;
  3. use Attribute;
  4. /**
  5. * The attribute specifies possible array keys and their types.
  6. *
  7. * If applied, an IDE will suggest the specified array keys, infer the specified types, and highlight non-specified keys in array access expressions.
  8. *
  9. * Array shapes should be specified with the required $shape parameter whose values should be array literals.<br />
  10. *
  11. * Example: <br />
  12. * <b>#[ArrayShape(["f" => "int", "string", "x" => "float"])]</b>
  13. * This usage applied on an element effectively means that the array has 3 dimensions, the keys are "f", 1, and "x", and the corresponding types are "int", "string", and "float".
  14. */
  15. #[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER | Attribute::TARGET_PROPERTY)]
  16. class ArrayShape {
  17. public function __construct(array $shape)
  18. {
  19. }
  20. }