If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.
(mongodb >=1.0.0)
MongoDB\BSON\ObjectId::__construct — Constrói um novo ObjectId
id
(string)Uma string hexadecimal de 24 caracteres Se não informada, a extensão irá gerar um ObjectId.
id
não for uma string hexadecimal de 24 caracteres.Exemplo #1 Exemplo de MongoDB\BSON\ObjectId::__construct()
<?php
var_dump(new MongoDB\BSON\ObjectId());
var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));
?>
O exemplo acima produzirá algo semelhante a:
object(MongoDB\BSON\ObjectId)#1 (1) { ["oid"]=> string(24) "56732d3dda14d81214634921" } object(MongoDB\BSON\ObjectId)#1 (1) { ["oid"]=> string(24) "000000000000000000000001" }
If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.