whoami7 - Manager
:
/
proc
/
self
/
root
/
home
/
kckglobal
/
public_html
/
update
/
Upload File:
files >> //proc/self/root/home/kckglobal/public_html/update/comparator.zip
PK �t�ZZpR� � src/NumericComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function abs; use function is_float; use function is_infinite; use function is_nan; use function is_numeric; use function is_string; use function sprintf; use SebastianBergmann\Exporter\Exporter; final class NumericComparator extends ScalarComparator { public function accepts(mixed $expected, mixed $actual): bool { // all numerical values, but not if both of them are strings return is_numeric($expected) && is_numeric($actual) && !(is_string($expected) && is_string($actual)); } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void { if ($this->isInfinite($actual) && $this->isInfinite($expected)) { return; } if (($this->isInfinite($actual) xor $this->isInfinite($expected)) || ($this->isNan($actual) || $this->isNan($expected)) || abs($actual - $expected) > $delta) { $exporter = new Exporter; throw new ComparisonFailure( $expected, $actual, '', '', sprintf( 'Failed asserting that %s matches expected %s.', $exporter->export($actual), $exporter->export($expected), ), ); } } private function isInfinite(mixed $value): bool { return is_float($value) && is_infinite($value); } private function isNan(mixed $value): bool { return is_float($value) && is_nan($value); } } PK �t�Z��q�� � src/TypeComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function gettype; use function sprintf; use SebastianBergmann\Exporter\Exporter; final class TypeComparator extends Comparator { public function accepts(mixed $expected, mixed $actual): bool { return true; } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void { if (gettype($expected) != gettype($actual)) { throw new ComparisonFailure( $expected, $actual, // we don't need a diff '', '', sprintf( '%s does not match expected type "%s".', (new Exporter)->shortenedExport($actual), gettype($expected), ), ); } } } PK �t�Z���'� � src/ExceptionComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function assert; use Exception; /** * Compares Exception instances for equality. */ final class ExceptionComparator extends ObjectComparator { public function accepts(mixed $expected, mixed $actual): bool { return $expected instanceof Exception && $actual instanceof Exception; } protected function toArray(object $object): array { assert($object instanceof Exception); $array = parent::toArray($object); unset( $array['file'], $array['line'], $array['trace'], $array['string'], $array['xdebug_message'], ); return $array; } } PK �t�Z�:�H� � src/ResourceComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function assert; use function is_resource; use SebastianBergmann\Exporter\Exporter; final class ResourceComparator extends Comparator { public function accepts(mixed $expected, mixed $actual): bool { return is_resource($expected) && is_resource($actual); } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void { assert(is_resource($expected)); assert(is_resource($actual)); $exporter = new Exporter; if ($actual != $expected) { throw new ComparisonFailure( $expected, $actual, $exporter->export($expected), $exporter->export($actual), ); } } } PK �t�Z�+ [X X src/Factory.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function array_unshift; final class Factory { private static ?Factory $instance = null; /** * @psalm-var list<Comparator> */ private array $customComparators = []; /** * @psalm-var list<Comparator> */ private array $defaultComparators = []; public static function getInstance(): self { if (self::$instance === null) { self::$instance = new self; // @codeCoverageIgnore } return self::$instance; } public function __construct() { $this->registerDefaultComparators(); } public function getComparatorFor(mixed $expected, mixed $actual): Comparator { foreach ($this->customComparators as $comparator) { if ($comparator->accepts($expected, $actual)) { return $comparator; } } foreach ($this->defaultComparators as $comparator) { if ($comparator->accepts($expected, $actual)) { return $comparator; } } throw new RuntimeException('No suitable Comparator implementation found'); } /** * Registers a new comparator. * * This comparator will be returned by getComparatorFor() if its accept() method * returns TRUE for the compared values. It has higher priority than the * existing comparators, meaning that its accept() method will be invoked * before those of the other comparators. */ public function register(Comparator $comparator): void { array_unshift($this->customComparators, $comparator); $comparator->setFactory($this); } /** * Unregisters a comparator. * * This comparator will no longer be considered by getComparatorFor(). */ public function unregister(Comparator $comparator): void { foreach ($this->customComparators as $key => $_comparator) { if ($comparator === $_comparator) { unset($this->customComparators[$key]); } } } public function reset(): void { $this->customComparators = []; } private function registerDefaultComparators(): void { $this->registerDefaultComparator(new MockObjectComparator); $this->registerDefaultComparator(new DateTimeComparator); $this->registerDefaultComparator(new DOMNodeComparator); $this->registerDefaultComparator(new SplObjectStorageComparator); $this->registerDefaultComparator(new ExceptionComparator); $this->registerDefaultComparator(new ObjectComparator); $this->registerDefaultComparator(new ResourceComparator); $this->registerDefaultComparator(new ArrayComparator); $this->registerDefaultComparator(new NumericComparator); $this->registerDefaultComparator(new ScalarComparator); $this->registerDefaultComparator(new TypeComparator); } private function registerDefaultComparator(Comparator $comparator): void { $this->defaultComparators[] = $comparator; $comparator->setFactory($this); } } PK �t�Z��8 8 src/MockObjectComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function array_keys; use function assert; use function str_starts_with; use PHPUnit\Framework\MockObject\Stub; /** * Compares PHPUnit\Framework\MockObject\MockObject instances for equality. */ final class MockObjectComparator extends ObjectComparator { public function accepts(mixed $expected, mixed $actual): bool { return $expected instanceof Stub && $actual instanceof Stub; } protected function toArray(object $object): array { assert($object instanceof Stub); $array = parent::toArray($object); foreach (array_keys($array) as $key) { if (!str_starts_with($key, '__phpunit_')) { continue; } unset($array[$key]); } return $array; } } PK �t�Z��Ӄ � # src/exceptions/RuntimeException.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; final class RuntimeException extends \RuntimeException implements Exception { } PK �t�Zt�m m src/exceptions/Exception.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use Throwable; interface Exception extends Throwable { } PK �t�Zɏ>[ src/DateTimeComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function abs; use function assert; use function floor; use function sprintf; use DateInterval; use DateTimeInterface; use DateTimeZone; final class DateTimeComparator extends ObjectComparator { public function accepts(mixed $expected, mixed $actual): bool { return ($expected instanceof DateTimeInterface) && ($actual instanceof DateTimeInterface); } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void { assert($expected instanceof DateTimeInterface); assert($actual instanceof DateTimeInterface); $absDelta = abs($delta); $delta = new DateInterval(sprintf('PT%dS', $absDelta)); $delta->f = $absDelta - floor($absDelta); $actualClone = (clone $actual) ->setTimezone(new DateTimeZone('UTC')); $expectedLower = (clone $expected) ->setTimezone(new DateTimeZone('UTC')) ->sub($delta); $expectedUpper = (clone $expected) ->setTimezone(new DateTimeZone('UTC')) ->add($delta); if ($actualClone < $expectedLower || $actualClone > $expectedUpper) { throw new ComparisonFailure( $expected, $actual, $this->dateTimeToString($expected), $this->dateTimeToString($actual), 'Failed asserting that two DateTime objects are equal.', ); } } /** * Returns an ISO 8601 formatted string representation of a datetime or * 'Invalid DateTimeInterface object' if the provided DateTimeInterface was not properly * initialized. */ private function dateTimeToString(DateTimeInterface $datetime): string { $string = $datetime->format('Y-m-d\TH:i:s.uO'); return $string ?: 'Invalid DateTimeInterface object'; } } PK �t�Z�E src/ScalarComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function is_bool; use function is_object; use function is_scalar; use function is_string; use function mb_strtolower; use function method_exists; use function sprintf; use SebastianBergmann\Exporter\Exporter; /** * Compares scalar or NULL values for equality. */ class ScalarComparator extends Comparator { public function accepts(mixed $expected, mixed $actual): bool { return ((is_scalar($expected) xor null === $expected) && (is_scalar($actual) xor null === $actual)) || // allow comparison between strings and objects featuring __toString() (is_string($expected) && is_object($actual) && method_exists($actual, '__toString')) || (is_object($expected) && method_exists($expected, '__toString') && is_string($actual)); } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void { $expectedToCompare = $expected; $actualToCompare = $actual; $exporter = new Exporter; // always compare as strings to avoid strange behaviour // otherwise 0 == 'Foobar' if ((is_string($expected) && !is_bool($actual)) || (is_string($actual) && !is_bool($expected))) { $expectedToCompare = (string) $expectedToCompare; $actualToCompare = (string) $actualToCompare; if ($ignoreCase) { $expectedToCompare = mb_strtolower($expectedToCompare, 'UTF-8'); $actualToCompare = mb_strtolower($actualToCompare, 'UTF-8'); } } if ($expectedToCompare !== $actualToCompare && is_string($expected) && is_string($actual)) { throw new ComparisonFailure( $expected, $actual, $exporter->export($expected), $exporter->export($actual), 'Failed asserting that two strings are equal.', ); } if ($expectedToCompare != $actualToCompare) { throw new ComparisonFailure( $expected, $actual, // no diff is required '', '', sprintf( 'Failed asserting that %s matches expected %s.', $exporter->export($actual), $exporter->export($expected), ), ); } } } PK �t�Z�ԯ�: : src/ArrayComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function array_key_exists; use function assert; use function is_array; use function sort; use function sprintf; use function str_replace; use function trim; use SebastianBergmann\Exporter\Exporter; /** * Arrays are equal if they contain the same key-value pairs. * The order of the keys does not matter. * The types of key-value pairs do not matter. */ class ArrayComparator extends Comparator { public function accepts(mixed $expected, mixed $actual): bool { return is_array($expected) && is_array($actual); } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void { assert(is_array($expected)); assert(is_array($actual)); if ($canonicalize) { sort($expected); sort($actual); } $remaining = $actual; $actualAsString = "Array (\n"; $expectedAsString = "Array (\n"; $equal = true; $exporter = new Exporter; foreach ($expected as $key => $value) { unset($remaining[$key]); if (!array_key_exists($key, $actual)) { $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), $exporter->shortenedExport($value), ); $equal = false; continue; } try { $comparator = $this->factory()->getComparatorFor($value, $actual[$key]); $comparator->assertEquals($value, $actual[$key], $delta, $canonicalize, $ignoreCase, $processed); $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), $exporter->shortenedExport($value), ); $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), $exporter->shortenedExport($actual[$key]), ); } catch (ComparisonFailure $e) { $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), $e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : $exporter->shortenedExport($e->getExpected()), ); $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), $e->getActualAsString() ? $this->indent($e->getActualAsString()) : $exporter->shortenedExport($e->getActual()), ); $equal = false; } } foreach ($remaining as $key => $value) { $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), $exporter->shortenedExport($value), ); $equal = false; } $expectedAsString .= ')'; $actualAsString .= ')'; if (!$equal) { throw new ComparisonFailure( $expected, $actual, $expectedAsString, $actualAsString, 'Failed asserting that two arrays are equal.', ); } } private function indent(string $lines): string { return trim(str_replace("\n", "\n ", $lines)); } } PK �t�Z�C�- src/ComparisonFailure.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use RuntimeException; use SebastianBergmann\Diff\Differ; use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder; final class ComparisonFailure extends RuntimeException { private mixed $expected; private mixed $actual; private string $expectedAsString; private string $actualAsString; public function __construct(mixed $expected, mixed $actual, string $expectedAsString, string $actualAsString, string $message = '') { parent::__construct($message); $this->expected = $expected; $this->actual = $actual; $this->expectedAsString = $expectedAsString; $this->actualAsString = $actualAsString; } public function getActual(): mixed { return $this->actual; } public function getExpected(): mixed { return $this->expected; } public function getActualAsString(): string { return $this->actualAsString; } public function getExpectedAsString(): string { return $this->expectedAsString; } public function getDiff(): string { if (!$this->actualAsString && !$this->expectedAsString) { return ''; } $differ = new Differ(new UnifiedDiffOutputBuilder("\n--- Expected\n+++ Actual\n")); return $differ->diff($this->expectedAsString, $this->actualAsString); } public function toString(): string { return $this->getMessage() . $this->getDiff(); } } PK �t�Z���C C src/DOMNodeComparator.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Comparator; use function assert; use function mb_strtolower; use function sprintf; use DOMDocument; use DOMNode; use ValueError; final class DOMNodeComparator extends ObjectComparator { public function accepts(mixed $expected, mixed $actual): bool { return $expected instanceof DOMNode && $actual instanceof DOMNode; } /** * @throws ComparisonFailure */ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void { assert($expected instanceof DOMNode); assert($actual instanceof DOMNode); $expectedAsString = $this->nodeToText($expected, true, $ignoreCase); $actualAsString = $this->nodeToText($actual, true, $ignoreCase); if ($expectedAsString !== $actualAsString) { $type = $expected instanceof DOMDocument ? 'documents' : 'nodes'; throw new ComparisonFailure( $expected, $actual, $expectedAsString, $actualAsString, sprintf("Failed asserting that two DOM %s are equal.\n", $type), ); } } /** * Returns the normalized, whitespace-cleaned, and indented textual * representation of a DOMNode. */ private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase): string { if ($canonicalize) { $document = new DOMDocument; try { $c14n = $node->C14N(); assert(!empty($c14n)); @$document->loadXML($c14n); } catch (ValueError) { } $node = $document; } $document = $node instanceof DOMDocument ? $node : $node->ownerDocument; $document->formatOutput = true; $document->normalizeDocument(); $text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node); return $ignoreCase ? mb_strtolower($text, 'UTF-8') : $text; } } PK �t�ZY�0�� � "