-
Notifications
You must be signed in to change notification settings - Fork 791
Fix generator xrange() example #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
KodyWiremane
wants to merge
3
commits into
php:master
from
KodyWiremane:fix-generator-xrange-example
Closed
Fix generator xrange() example #4
KodyWiremane
wants to merge
3
commits into
php:master
from
KodyWiremane:fix-generator-xrange-example
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nikic
reviewed
Jul 13, 2019
Thanks! I don't think it's necessary to match range() exactly, as long as the code is correct and illustrates the generator usage. @php-pulls merge |
salathe
pushed a commit
to salathe/phpdoc-en
that referenced
this pull request
Jul 13, 2019
Patch by KodyWiremane. Closes php/doc-en#4. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@347735 c90b9560-bf6c-de11-be94-00142212c4b1
heiglandreas
pushed a commit
to phpdoctest/en
that referenced
this pull request
Feb 4, 2020
Patch by KodyWiremane. Closes php/doc-en#4. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@347735 c90b9560-bf6c-de11-be94-00142212c4b1
salathe
pushed a commit
to salathe/phpdoc-en
that referenced
this pull request
Sep 3, 2020
Patch by KodyWiremane. Closes php/doc-en#4. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@347735 c90b9560-bf6c-de11-be94-00142212c4b1
Firehed
added a commit
to Firehed/doc-en
that referenced
this pull request
Mar 18, 2021
The documented parameters differ from the names exposed in reflection/source code. Now that named parameters are supported in PHP 8, this discrepancy is confusing and impactful. ``` $ php --rf fgetcsv Function [ <internal:standard> function fgetcsv ] { - Parameters [5] { Parameter #0 [ <required> $stream ] Parameter php#1 [ <optional> ?int $length = null ] Parameter php#2 [ <optional> string $separator = "," ] Parameter php#3 [ <optional> string $enclosure = "\"" ] Parameter php#4 [ <optional> string $escape = "\\" ] } - Return [ array|false ] } ```
php-pulls
pushed a commit
that referenced
this pull request
Mar 18, 2021
The documented parameters differ from the names exposed in reflection/source code. Now that named parameters are supported in PHP 8, this discrepancy is confusing and impactful. ``` $ php --rf fgetcsv Function [ <internal:standard> function fgetcsv ] { - Parameters [5] { Parameter #0 [ <required> $stream ] Parameter #1 [ <optional> ?int $length = null ] Parameter #2 [ <optional> string $separator = "," ] Parameter #3 [ <optional> string $enclosure = "\"" ] Parameter #4 [ <optional> string $escape = "\\" ] } - Return [ array|false ] } ``` Closes GH-493.
aghArdeshir
added a commit
to aghArdeshir/doc-en
that referenced
this pull request
Aug 9, 2023
in this example, `$count--` at the end of the function helps with nothing. Its existence also does not harm anything. But because in the same file, in "Example php#4 Example demonstrating need for static variables" we were talking about how useless `$a++` is in that example, putting a useless `$count--` can be misleading in this example, because the reader may look for the philosophy/reason behind existence of this statement.
kamil-tekiela
added a commit
to kamil-tekiela/doc-en
that referenced
this pull request
Dec 5, 2024
Girgias
pushed a commit
that referenced
this pull request
Dec 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, the increment part in the
else
branch's loop must be+=
, not-=
, because$step
is negative there.Second,
$start == $limit
is OK forrange()
, the resulting sequence will simply contain only one value.Also, I've noticed some deviation from how
range()
behaves: it ignores$step
's sign, and derives it from which of$start
and$limit
is greater. It also emits a warning if$start != $limit && abs($step) > abs($limit - $start)
, and returnsfalse
(as well as if$step == 0
).If
xrange()
is thought of as an equivalent ofrange()
, this should be addressed. Though, personally, I more likexrange()
the way it is (except for the two errors initially mentioned), as it looks more consistent.To check for [dis]similarities between
range()
andxrange()
, I've usedthe following code