commitall

This commit is contained in:
Sampanna Rimal
2024-07-10 18:28:19 +05:45
parent 140abda4e6
commit 9cd05ef3cb
15723 changed files with 4818733 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use SebastianBergmann\Comparator\Comparator;
use SebastianBergmann\Comparator\ComparisonFailure;
/**
* Closure comparator.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
final class ClosureComparator extends Comparator
{
public function accepts($expected, $actual)
{
return is_object($expected) && $expected instanceof \Closure
&& is_object($actual) && $actual instanceof \Closure;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
{
if ($expected !== $actual) {
throw new ComparisonFailure(
$expected,
$actual,
// we don't need a diff
'',
'',
false,
'all closures are different if not identical'
);
}
}
}

View File

@ -0,0 +1,47 @@
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use SebastianBergmann\Comparator\Factory as BaseFactory;
/**
* Prophecy comparator factory.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
final class Factory extends BaseFactory
{
/**
* @var Factory
*/
private static $instance;
public function __construct()
{
parent::__construct();
$this->register(new ClosureComparator());
$this->register(new ProphecyComparator());
}
/**
* @return Factory
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new Factory;
}
return self::$instance;
}
}

View File

@ -0,0 +1,28 @@
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use Prophecy\Prophecy\ProphecyInterface;
use SebastianBergmann\Comparator\ObjectComparator;
class ProphecyComparator extends ObjectComparator
{
public function accepts($expected, $actual)
{
return is_object($expected) && is_object($actual) && $actual instanceof ProphecyInterface;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
{
parent::assertEquals($expected, $actual->reveal(), $delta, $canonicalize, $ignoreCase, $processed);
}
}