php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78093 mt_rand returns NULL in some cases
Submitted: 2019-05-31 14:47 UTC Modified: 2019-05-31 14:51 UTC
From: sidorovmarat1995 at gmail dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 7.2.19 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sidorovmarat1995 at gmail dot com
New email:
PHP Version: OS:

 

 [2019-05-31 14:47 UTC] sidorovmarat1995 at gmail dot com
Description:
------------
In mt_rand docs I can't find possibility of returning NULL.
I suggest return false in this situation(see test script).

Test script:
---------------
<?php
var_dump(mt_rand(INF,INF));
var_dump(mt_rand(INF,NULL));

Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
NULL
NULL

Patches

mt-rand (last revision 2019-05-31 14:48 UTC by sidorovmarat1995 at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-31 14:48 UTC] sidorovmarat1995 at gmail dot com
The following patch has been added/updated:

Patch Name: mt-rand
Revision:   1559314100
URL:        https://bugs.php.net/patch-display.php?bug=78093&patch=mt-rand&revision=1559314100
 [2019-05-31 14:50 UTC] sidorovmarat1995 at gmail dot com
Sorry, I don't know how to fix this issue.
And you can see my path is only random txt file from my PC.
 [2019-05-31 14:51 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-05-31 14:51 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

https://3v4l.org/TviI3 See the warnings?

https://www.php.net/manual/en/functions.internal.php
> Note: If the parameters given to a function are not what it expects, such as passing an array where a string is
> expected, the return value of the function is undefined. In this case it will likely return NULL but this is just
> a convention, and cannot be relied upon.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 20:01:23 2020 UTC