1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-27 17:22:10 +01:00
Commit Graph

7 Commits

Author SHA1 Message Date
Tim Düsterhus
215fd48515 random: Improve short descriptions for methods (#2007)
* random: Unify the short description for random_(bytes|int) with Randomizer

* random: Use imperative mood for short descriptions of engine methods

This is for consistency. The PHP manual appears to use imperative mood for the
majority of functions and all of Randomizer’s functions already too.

* random: Shorten the short description for random_int and Randomizer::getInt()
2022-11-15 17:22:51 +01:00
Tim Düsterhus
52c495140b random: Clean up cross-references for randomness related functions (#2008)
* random: Reference the corresponding Randomizer methods in random_(bytes|int)

* random: Cross-reference the Randomizer in `str_shuffle()`

* random: Cross-reference the Randomizer in `shuffle()`

* random: Cross-reference the Randomizer in `array_rand()`

* random: Cross-reference `random_bytes()` in `uniqid()`

* random: Do not cross-reference `uniqid()` in `openssl_random_pseudo_bytes()`

uniqid() really is no good alternative to *anything*. In the vast majority of
cases it is better replaced by `bin2hex(random_bytes(…))`.

* random: Replace the `mt_rand()` cross-reference in `openssl_random_pseudo_bytes()` with `random_int()`

random_int() is a CSPRNG like openssl_random_pseudo_bytes(), mt_rand() is not.
2022-11-15 11:19:28 +01:00
Tim Düsterhus
2ab45105b4 Stop referring to openssl_random_pseudo_bytes() outside of ext/openssl (#1967)
* random: Remove openssl_random_pseudo_bytes() from caution.cryptographically-insecure

The `random_bytes()` and `random_int()` alternatives are available since since
PHP 7.0, are available by default and directly map to the OS' CSPRNG and thus
are likely more secure.

Thus this commit stops mentioning `openssl_random_pseudo_bytes()` as a possible
option any more to keep things simple for the reader.

* random: Remove `openssl_random_pseudo_bytes()` from “See Also” sections for ext/random

The reasoning as with the previous commit applies.

* hash: Replace `openssl_random_pseudo_bytes()` by `random_bytes()`

* session: Replace `openssl_random_pseudo_bytes()` by `random_bytes()`
2022-11-10 14:08:01 +01:00
Tim Düsterhus
466f58e332 Extend ext/random documentation (3) (#1951)
* random: Remove redundant “Returns” prefix from return value explanation

* random: Document Engine::generate()'s return value

* random: Document Xoshiro256StarStar::generate()'s return value

* random: Document PcgOneseq128XslRr64::generate()'s return value

* random: Document Mt19937::generate()'s return value

* random: Document Secure::generate()'s return value

* random: Document the Randomizer::$engine property

* random: Clarify the int seeding for PcgOneseq128XslRr64

This change is relevant for negative seed values.

* random: Document Mt19937::__construct()'s parameter value

* random: Add description for CryptoSafeEngine

* random: Add description for RandomError

* random: Add description for RandomException

* random: Improve phrasing for MT_RAND_PHP for Mt19937

Co-authored-by: George Peter Banyard <girgias@php.net>

* random: Explain the `$mode` parameter for Mt19937 construction with a list

Co-authored-by: George Peter Banyard <girgias@php.net>
2022-11-08 17:42:23 +01:00
Tim Düsterhus
4bb7c8dab4 Extend ext/random documentation (2) (#1922)
* random: Document Randomizer::shuffleArray()'s parameter and return value

* random: Document Randomizer::shuffleBytes()' parameter and return value

* random: Document Randomizer::pickArrayKeys()' parameter and return value

* random: Unify sentence structure for integer parameter constraints

* random: Document PcgOneseq128XslRr64::jump()'s parameter and return value

* random: Add external reference links for the engines

* random: Document PcgOneseq128XslRr64::__construct()'s parameter value

* random: Document Xoshiro256StarStar::__construct()'s parameter value

* random: Fix casing of "bytes" and "bits"

* fixup! random: Document PcgOneseq128XslRr64::__construct()'s parameter value

* fixup! random: Document PcgOneseq128XslRr64::__construct()'s parameter value

* fixup! random: Document Xoshiro256StarStar::__construct()'s parameter value

* fixup! random: Document PcgOneseq128XslRr64::__construct()'s parameter value

* random: Use entities to link to the engine specifications

see php/doc-base#76

* random: Fix typo in Randomizer::getInt()'s return value description
2022-11-05 10:15:28 +01:00
Tim Düsterhus
4b1b9be99e Extend ext/random documentation (#1920)
* random: Fix Randomizer::__construct()'s default value

The parameter is nullable and the actual default value should rather be
considered `null`. `null` is then *internally* replaced with a new instance of
`Random\Engine\Secure`.

* random: Document Randomizer::__construct()'s parameters

* random: Document Randomizer::getBytes()' parameter and return value

The phrasing is adapted from and synced with `random_bytes()`.

* random: Fix classname references for CSPRNG failures

* random: Unify phrasing random_int parameter description

* random: Document Randomizer::getInt()'s parameter and return value

The phrasing is adapted from and synced with `random_int()`.

* random: Add random.engineErrors snippets

This explains that the Randomizer's methods will pass through any Throwables
thrown by the engine.

* random: Fix definition of Randomizer::$engine

* random: Improve random_int/getInt parameter descriptions

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

* random: Improve random_int return value description

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

* random: Fix link to Randomizer::$engine property

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

* random: Use `&null;` entity in Randomizer::__construct()

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2022-10-30 14:58:54 +01:00
Tim Düsterhus
2166824858 Bootstrap ext/random docs with docgen
Closes GH-1916.
2022-10-28 15:21:01 +02:00