Skip to content

Commit

Permalink
Merge branch '2.8' into 3.3
Browse files Browse the repository at this point in the history
* 2.8:
  Username and password in basic auth are allowed to contain '.'
  Remove obsolete PHPDoc from UriSigner
  [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed
  [PropertyInfo] Add support for the iterable type
  pdo session fix
  Fixed unsetting from loosely equal keys OrderedHashMap
  [Debug] Fix same vendor detection in class loader
  Updated the source text and translation
  reject remember-me token if user check fails
  • Loading branch information
fabpot committed Oct 18, 2017
2 parents af5aa5c + 36487dd commit c75c4de
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Resources/translations/validators.sv.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<target>Den uppladdade filen var för stor. Försök ladda upp en mindre fil.</target>
</trans-unit>
<trans-unit id="30">
<source>The CSRF token is invalid.</source>
<target>CSRF-symbolen är inte giltig.</target>
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRF-elementet är inte giltigt. Försök att skicka formuläret igen.</target>
</trans-unit>
</body>
</file>
Expand Down
20 changes: 20 additions & 0 deletions Tests/Util/OrderedHashMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public function testInsertNullKeys()
$this->assertSame(array(0 => 1, 'foo' => 2, 1 => 3), iterator_to_array($map));
}

public function testInsertLooselyEqualKeys()
{
$map = new OrderedHashMap();
$map['1 as a string'] = '1 as a string';
$map[1] = 1;

$this->assertSame(array('1 as a string' => '1 as a string', 1 => 1), iterator_to_array($map));
}

/**
* Updates should not change the position of an element, otherwise we could
* turn foreach loops into endless loops if they change the current
Expand Down Expand Up @@ -111,6 +120,17 @@ public function testUnset()
$this->assertSame(array('second' => 2), iterator_to_array($map));
}

public function testUnsetFromLooselyEqualKeysHashMap()
{
$map = new OrderedHashMap();
$map['1 as a string'] = '1 as a string';
$map[1] = 1;

unset($map[1]);

$this->assertSame(array('1 as a string' => '1 as a string'), iterator_to_array($map));
}

public function testUnsetNonExistingSucceeds()
{
$map = new OrderedHashMap();
Expand Down
4 changes: 2 additions & 2 deletions Util/OrderedHashMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function offsetSet($key, $value)
: 1 + (int) max($this->orderedKeys);
}

$this->orderedKeys[] = $key;
$this->orderedKeys[] = (string) $key;
}

$this->elements[$key] = $value;
Expand All @@ -144,7 +144,7 @@ public function offsetSet($key, $value)
*/
public function offsetUnset($key)
{
if (false !== ($position = array_search($key, $this->orderedKeys))) {
if (false !== ($position = array_search((string) $key, $this->orderedKeys))) {
array_splice($this->orderedKeys, $position, 1);
unset($this->elements[$key]);

Expand Down
8 changes: 7 additions & 1 deletion Util/OrderedHashMapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ public function next()
*/
public function key()
{
return $this->key;
if (null === $this->key) {
return null;
}

$array = array($this->key => null);

return key($array);
}

/**
Expand Down

0 comments on commit c75c4de

Please sign in to comment.