Use union types when a value legitimately accepts multiple alternatives, and intersection types when it must satisfy multiple interfaces: ~~~php function formatId(int|string $id): string { return (string) $id; } function consume(Countable&Traversable $items): int { return count($items); } ~~~ Prefer a narrower domain type when possible and add return types to every function.
Installs into .claude/skills of the current project.
Are you the author of Php Language?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-php-language-d0d62e0b)
Use union types when a value legitimately accepts multiple alternatives, and intersection types when it must satisfy multiple interfaces:
~~~php
function formatId(int|string $id): string
{
return (string) $id;
}
function consume(Countable&Traversable $items): int
{
return count($items);
}
~~~
Prefer a narrower domain type when possible and add return types to every function.