Skip to content

Instantly share code, notes, and snippets.

@dmertl
Last active May 16, 2024 23:06
Show Gist options
  • Save dmertl/9cf2357fc1ef829a1e439f53f7c9c288 to your computer and use it in GitHub Desktop.
Save dmertl/9cf2357fc1ef829a1e439f53f7c9c288 to your computer and use it in GitHub Desktop.
PHP Cheatsheet

Doc Comment Typing

PHPDoc, but specifically working with PHPStorm IDE.

/**
 * Array of datetimes like [DateTime(), DateTime()]
 * 
 * @var DateTime[]
 */
 protected array $updates;

/**
 * Map of customer processors by type ['customer' => ['type' => [Processor(), Processor()]]]
 *
 * @var array<string,array<string,Processor[]>>
 */
 protected array $customerOverrides;
 
/**
 * Constructor.
 * 
 * Default options: ['url' => 'https://example.com', 'timeout' => 5]
 *
 * @param array{url: string, timeout: int} $config
 */
 public function __construct(array $config) {}
 
/**
 * Get related record metadata like ['User', 254, 'John Doe'].
 *
 * @return array{0: string, 1: int, 2: string} Record type, ID, and name.
 */
 public function recordMeta(): array {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment