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

Fix string handling of Hash::remove() and Hash::_simpleOp('remove') #11060

Merged
merged 3 commits into from Aug 20, 2017

Conversation

Projects
None yet
3 participants
@chinpei215
Member

chinpei215 commented Aug 19, 2017

At the momemnt,

$array = [
    'foo' => 'string',
];
Hash::remove($array, 'foo.bar');

Will cause a fatal error.

$array = [
    'foo' => [
        0 => 'a',
        1 => 'b',
    ],
];
Hash::remove($array, 'foo[1=b].0');

Will return an empty array unexpectedly.

Also, I removed a meaningless code.

if ((is_numeric($key) && (int)$key > 0 || $key === '0') &&
strpos($key, '0') !== 0
) {
$key = (int)$key;
}

Decimal keys need not to be converted to integers explicitly when using operator [].

chinpei215 added some commits Aug 19, 2017

Fix string handling of Hash::remove() and Hash::_simpleOp('remove')
Hash::remove() mishandles '0' in path strings.
Hash::_simpleOp('remove') causes a fatal error when data is a string.

@chinpei215 chinpei215 added this to the 3.5.1 milestone Aug 19, 2017

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Aug 19, 2017

Codecov Report

Merging #11060 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #11060      +/-   ##
============================================
- Coverage     94.85%   94.85%   -0.01%     
+ Complexity    12846    12843       -3     
============================================
  Files           437      437              
  Lines         32749    32747       -2     
============================================
- Hits          31065    31063       -2     
  Misses         1684     1684
Impacted Files Coverage Δ Complexity Δ
src/Utility/Hash.php 97.47% <100%> (-0.02%) 246 <0> (-3)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b082ca...e7b82b2. Read the comment docs.

codecov-io commented Aug 19, 2017

Codecov Report

Merging #11060 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #11060      +/-   ##
============================================
- Coverage     94.85%   94.85%   -0.01%     
+ Complexity    12846    12843       -3     
============================================
  Files           437      437              
  Lines         32749    32747       -2     
============================================
- Hits          31065    31063       -2     
  Misses         1684     1684
Impacted Files Coverage Δ Complexity Δ
src/Utility/Hash.php 97.47% <100%> (-0.02%) 246 <0> (-3)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b082ca...e7b82b2. Read the comment docs.

@markstory markstory merged commit fffda82 into cakephp:master Aug 20, 2017

2 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
stickler-ci No lint errors found.

@chinpei215 chinpei215 deleted the chinpei215:fix-hash-remove branch Aug 21, 2017

chinpei215 added a commit to chinpei215/cakephp that referenced this pull request Oct 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment