FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge branch 'feature/array-merge-performance-upgrade' · xiaochen-php/klein.php@6e1f228 · GitHub

Repository navigation

Commit 6e1f228

Browse files
committed
Merge branch 'feature/array-merge-performance-upgrade'
2 parents 088050d + 30e63f6 commit 6e1f228

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎Klein/DataCollection/DataCollection.php‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,10 @@ public function all($mask = null, $fill_with_nulls = true)
9595
* Remove all of the keys from the attributes
9696
* that aren't in the passed mask
9797
*/
98-
return array_merge(
99-
$attributes,
100-
array_intersect_key(
101-
$this->attributes,
102-
array_flip($mask)
103-
)
104-
);
98+
return array_intersect_key(
99+
$this->attributes,
100+
array_flip($mask)
101+
) + $attributes;
105102
}
106103

107104
return $this->attributes;

‎tests/Klein/Tests/RequestTest.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function testGlobalsCreation()
7878
public function testUniversalParams()
7979
{
8080
// Test data
81-
$params_get = array('page' => 2, 'per_page' => 10, 'num' => 1);
82-
$params_post = array('first_name' => 'Trevor', 'last_name' => 'Suarez', 'num' => 2);
83-
$cookies = array('user' => 'Rican7', 'PHPSESSID' => 'randomstring', 'num' => 3);
81+
$params_get = array('page' => 2, 'per_page' => 10, 'num' => 1, 5 => 'ok', 'empty' => null, 'blank' => '');
82+
$params_post = array('first_name' => 'Trevor', 'last_name' => 'Suarez', 'num' => 2, 3 => 'hmm', 4 => 'thing');
83+
$cookies = array('user' => 'Rican7', 'PHPSESSID' => 'randomstring', 'num' => 3, 4 => 'dog');
8484
$named = array('id' => '1f8ae', 'num' => 4);
8585

8686
// Create the request
@@ -104,9 +104,9 @@ public function testUniversalParams()
104104
public function testUniversalParamsWithFilter()
105105
{
106106
// Test data
107-
$params_get = array('page' => 2, 'per_page' => 10, 'num' => 1);
108-
$params_post = array('first_name' => 'Trevor', 'last_name' => 'Suarez', 'num' => 2);
109-
$cookies = array('user' => 'Rican7', 'PHPSESSID' => 'randomstring', 'num' => 3);
107+
$params_get = array('page' => 2, 'per_page' => 10, 'num' => 1, 5 => 'ok', 'empty' => null, 'blank' => '');
108+
$params_post = array('first_name' => 'Trevor', 'last_name' => 'Suarez', 'num' => 2, 3 => 'hmm', 4 => 'thing');
109+
$cookies = array('user' => 'Rican7', 'PHPSESSID' => 'randomstring', 'num' => 3, 4 => 'dog');
110110

111111
// Create our filter and expected results
112112
$filter = array('page', 'user', 'num', 'this-key-never-showed-up-anywhere');

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL