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 implode calls #11706

Merged
merged 1 commit into from Dec 19, 2018

Conversation

Projects
None yet
4 participants
@MathiasReker
Copy link
Contributor

MathiasReker commented Dec 11, 2018

Questions Answers
Branch? develop
Description? Fix syntax. Doc: http://php.net/manual/en/function.implode.php
Type? bug fix
Category? CO
BC breaks? Does it break backward compatibility? no
Deprecations? Does it deprecate an existing feature? no
Fixed ticket? /
How to test? /

This change is Reviewable

Fix implode call
Function implode must be called with 2 arguments in the documented order.
@PierreRambaud

This comment has been minimized.

Copy link
Contributor

PierreRambaud commented Dec 11, 2018

Any idea about how to tests?

@MathiasReker

This comment has been minimized.

Copy link
Contributor

MathiasReker commented Dec 12, 2018

I am not able to make a test case, I just follow the syntax

@MathiasReker

This comment has been minimized.

Copy link
Contributor

MathiasReker commented Dec 14, 2018

@PierreRambaud You could compare the old syntax with the new syntax and check if they output the same. The test could be done in a test environment:)

@PierreRambaud

This comment has been minimized.

Copy link
Contributor

PierreRambaud commented Dec 14, 2018

In fact, I don't know how it was able to work when I read the previous code, that's why I'm afraid to merge without QA validation :(

@MathiasReker

This comment has been minimized.

Copy link
Contributor

MathiasReker commented Dec 14, 2018

@PierreRambaud I fully agree!

@MathiasReker

This comment has been minimized.

Copy link
Contributor

MathiasReker commented Dec 18, 2018

@PierreRambaud I make a test case :)

@eternoendless

This comment has been minimized.

Copy link
Member

eternoendless commented Dec 18, 2018

In fact, I don't know how it was able to work when I read the previous code, that's why I'm afraid to merge without QA validation :(

As stated by PHP docs:

implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

After reviewing, I think that this can be merged without QA as it doesn't introduce any functional changes.

@MathiasReker

This comment has been minimized.

Copy link
Contributor

MathiasReker commented Dec 18, 2018

The output is the same:

foo; bar; qux
foo; bar; qux

Check below:

<?php

class Foo
{
    protected $title;

    public function __construct($title)
    {
        $this->title = $title;
    }

    public function __toString()
    {
        return $this->title;
    }
}

$array = [
    new Foo('foo'),
    new Foo('bar'),
    new Foo('qux'),
];

echo implode('; ', $array)
."<br>".
implode($array, '; ');
@eternoendless

This comment has been minimized.

Copy link
Member

eternoendless commented Dec 19, 2018

Thank you @MathiasReker

@eternoendless eternoendless merged commit 169f955 into PrestaShop:develop Dec 19, 2018

2 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@eternoendless eternoendless added this to the 1.7.6.0 milestone Dec 19, 2018

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