Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

array_multisort does not sort #104

Closed
dmecke opened this issue Mar 16, 2019 · 6 comments
Closed

array_multisort does not sort #104

dmecke opened this issue Mar 16, 2019 · 6 comments

Comments

@dmecke
Copy link

dmecke commented Mar 16, 2019

Given the following phpunit test case:

$integers = [3, 1, 2];

$sort = [];
foreach ($integers as $k => $value) {
    $sort[$k][] = $value;
}
array_multisort($sort, SORT_ASC, $integers);

Assert::assertSame(1, $integers[0]);
Assert::assertSame(2, $integers[1]);
Assert::assertSame(3, $integers[2]);

it passes with php's native array_mulitsort. Using Safe\array_multisort it fails, though. The array $integers is left unchanged. In the documentation (and therefore in safe) the third parameter is not a reference while php actually treats it as one.

@moufmouf
Copy link
Member

Hey @dmecke !

I just wrote a unit test to try to reproduce your problem, but I fail reproducing it.

The code you give seems to work OK with Safe and without Safe. Are you sure there is an issue? Could it be dependent on the PHP version (I'm testing with PHP 7.2)

@dmecke
Copy link
Author

dmecke commented Mar 19, 2019

Hm, yes, I just reproced it on my machine with php 7.2. I'd like to open a pull request, but I am not sure where this test should go. Is the generator/tests directory the right place? And if so, where should a function specific test like this go?

@moufmouf
Copy link
Member

A PR with a test would be nice!

You can add a test in https://github.com/thecodingmachine/safe/blob/master/generator/tests/GeneratedFilesTest.php

The Contributing guide explains how to run the tests.

@dmecke
Copy link
Author

dmecke commented Mar 25, 2019

I've created a pull request. I think travis fails because of this (so the reproduction works), but I am not sure if the error below is related to a misconfiguration on my side.

@Kharhamel
Copy link
Collaborator

this function was removed in #167

@Kharhamel
Copy link
Collaborator

This functiun was removed in the v1.0.0 release

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants