--TESTS--
Collections: Syntax
--FILE--
<?php
collection Articles(string => Article) { }
class Article
{
function __construct(public string $title) { }
}
$c = new Articles;
// OK:
$c["nine"] = new Article("The Ninth Planet: Pluto");
print_r($c);
// Error:
try {
$c["six"] = "Henry VIII";
} catch (Error $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Articles Object
(
[value] => Array
(
[nine] => Article Object
(
[title] => The Ninth Planet: Pluto
)
)
)
TypeError: Value type string does not match collection item type Article