for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the GitElephant package.
*
* (c) Matteo Giachino <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Just for fun...
*/
namespace GitElephant\Command;
use GitElephant\TestCase;
* DiffCommandTest
* @author Matteo Giachino <[email protected]>
class DiffCommandTest extends TestCase
{
* @var \GitElephant\Command\DiffCommand
private $diffCommand;
* set up
public function setUp(): void
$this->initRepository();
$this->getRepository()->init();
$this->addFile('foo');
$this->getRepository()->commit('first commit', true);
$this->diffCommand = new DiffCommand();
}
* diff test
public function testDiff(): void
$commit = $this->getRepository()->init()->getCommit();
$this->assertEquals(
DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' 'HEAD^..HEAD'",
$this->diffCommand->diff('HEAD')
'HEAD'
string
object<GitElephant\Objects\TreeishInterface>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
);
DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' 'branch2..HEAD' -- 'foo'",
$this->diffCommand->diff('HEAD', 'branch2', 'foo')
'branch2'
object<GitElephant\Objects\TreeishInterface>|null
sprintf(
DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' '%s^..%s'",
$commit->getSha(),
$commit->getSha()
),
$this->diffCommand->diff($commit)
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: