Skip to content

Instantly share code, notes, and snippets.

@renepardon
Last active August 31, 2015 13:49
Show Gist options
  • Select an option

  • Save renepardon/9a325e45da4aba639b10 to your computer and use it in GitHub Desktop.

Select an option

Save renepardon/9a325e45da4aba639b10 to your computer and use it in GitHub Desktop.
Scalar type hints in PHP 7 - check if all elements of $numbers are of type int
<?php
declare(strict_types=1);
class Test
{
public static function sum(int ... $numbers): int
{
return array_sum($numbers);
}
}
echo Test::sum('1', 2, 3, 4) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment