1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/applications/diffusion/controller
epriestley a5903d2a53 Use head_key() and last_key() to explicitly communicate intent
Summary:
PHP arrays have an internal "current position" marker. (I think because foreach() wasn't introduced until PHP 4 and there was no way to get rid of it by then?)

A few functions affect the position of the marker, like reset(), end(), each(), next(), and prev(). A few functions read the position of the marker, like each(), next(), prev(), current() and key().

For the most part, no one uses any of this because foreach() is vastly easier and more natural. However, we sometimes want to select the first or last key from an array. Since key() returns the key //at the current position//, and you can't guarantee that no one will introduce some next() calls somewhere, the right way to do this is reset() + key(). This is cumbesome, so we introduced head_key() and last_key() (like head() and last()) in D2161.

Switch all the reset()/end() + key() (or omitted reset() since I was feeling like taking risks + key()) calls to head_key() or last_key().

Test Plan: Verified most of these by visiting the affected pages.

Reviewers: btrahan, vrana, jungejason, Koolvin

Reviewed By: jungejason

CC: aran

Differential Revision: https://secure.phabricator.com/D2169
2012-04-09 11:08:59 -07:00
..
base Fix Jump to HEAD link 2012-04-03 18:39:58 -07:00
browse Respect view mode on deleted path in Diffusion 2012-04-02 11:16:46 -07:00
change Add "final" to all Phabricator "Controller" classes 2012-03-09 15:46:25 -08:00
commit Fix typo 2012-04-07 11:45:31 -07:00
diff Add "View Options" dropdown to Differential / Audit 2012-03-19 19:57:41 -07:00
external Use head_key() and last_key() to explicitly communicate intent 2012-04-09 11:08:59 -07:00
file Highlighting blame is broken if there is an unavailable commit 2012-04-09 01:14:36 -07:00
history Render pretty graphical traces for commit branches, etc 2012-03-23 17:11:15 -07:00
home Minor, fix Diffusion home for untracked repositories. 2012-04-03 13:54:10 -07:00
inline Add inline comments to Diffusion/Audit 2012-03-14 12:56:01 -07:00
lastmodified Add "final" to all Phabricator "Controller" classes 2012-03-09 15:46:25 -08:00
pathcomplete Fix many encoding and architecture problems in Diffusion request and URI handling 2012-03-19 19:52:14 -07:00
pathvalidate Fix many encoding and architecture problems in Diffusion request and URI handling 2012-03-19 19:52:14 -07:00
repository Render pretty graphical traces for commit branches, etc 2012-03-23 17:11:15 -07:00
symbol Disable autoload in search for internal class 2012-04-06 12:46:12 -07:00