1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-06-11 08:35:03 +02:00
Files
php-debugbar/src/DebugBar/RequestIdGeneratorInterface.php
James Johnston 7102278c9e RequestIdGeneratorInterface now returns more random values (#336)
Implementers of RequestIdGeneratorInterface::generate() need to be sure
that each call to generate() will return a unique ID.

This could fail to happen in the existing implementation if microtime()
returns the same value on two successive generate() calls that come
within the same microsecond.  For example, in a tight ID-generating
loop.  It was unlikely, but now it is practically impossible.

Additionally, implementers should make sure that the return value is not
all-numeric to avoid any mixed data types when IDs are used as keys in
PHP arrays.  (For example, numeric IDs could result in bugs when
array_merge is used.)
2017-07-21 08:20:20 +02:00

26 lines
693 B
PHP

<?php
/*
* This file is part of the DebugBar package.
*
* (c) 2013 Maxime Bouroumeau-Fuseau
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DebugBar;
interface RequestIdGeneratorInterface
{
/**
* Generates a unique id for the current request. If called repeatedly, a new unique id must
* always be returned on each call to generate() - even across different object instances.
*
* To avoid any potential confusion in ID --> value maps, the returned value must be
* guaranteed to not be all-numeric.
*
* @return string
*/
function generate();
}