upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -1,3 +0,0 @@
/.idea
/composer.lock
/vendor

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.0.1@b1e2e30026936ef8d5bf6a354d1c3959b6231f44">
<file src="src/Context.php">
<RedundantConditionGivenDocblockType occurrences="1">
<code>is_array($array)</code>
</RedundantConditionGivenDocblockType>
</file>
</files>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="false"
totallyTyped="false"
errorBaseline=".psalm/baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@@ -1,23 +0,0 @@
language: php
php:
- 7.0
- 7.0snapshot
- 7.1
- 7.1snapshot
- master
sudo: false
before_install:
- composer self-update
- composer clear-cache
install:
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable
script:
- ./vendor/bin/phpunit
notifications:
email: false

View File

@@ -0,0 +1,33 @@
# ChangeLog
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [4.0.4] - 2020-10-26
### Fixed
* `SebastianBergmann\RecursionContext\Exception` now correctly extends `\Throwable`
## [4.0.3] - 2020-09-28
### Changed
* [#21](https://github.com/sebastianbergmann/recursion-context/pull/21): Add type annotations for in/out parameters
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
## [4.0.2] - 2020-06-26
### Added
* This component is now supported on PHP 8
## [4.0.1] - 2020-06-15
### Changed
* Tests etc. are now ignored for archive exports
[4.0.4]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.3...4.0.4
[4.0.3]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.2...4.0.3
[4.0.2]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.1...4.0.2
[4.0.1]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.0...4.0.1

View File

@@ -1,6 +1,6 @@
Recursion Context
Copyright (c) 2002-2017, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2002-2020, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,14 +1,18 @@
# Recursion Context
# sebastian/recursion-context
...
[![CI Status](https://github.com/sebastianbergmann/recursion-context/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/recursion-context/actions)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/recursion-context/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/recursion-context)
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require sebastian/recursion-context
```
composer require sebastian/recursion-context
```
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev sebastian/recursion-context
```
composer require --dev sebastian/recursion-context
```

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="recursion-context" default="setup">
<target name="setup" depends="clean,composer"/>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
</target>
<target name="composer" depends="clean" description="Install dependencies with Composer">
<exec executable="composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
<arg value="--no-suggest"/>
<arg value="--optimize-autoloader"/>
<arg value="--prefer-stable"/>
</exec>
</target>
</project>

View File

@@ -17,11 +17,19 @@
"email": "aharvey@php.net"
}
],
"prefer-stable": true,
"config": {
"platform": {
"php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"require": {
"php": ">=7.0"
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^9.3"
},
"autoload": {
"classmap": [
@@ -30,7 +38,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "4.0-dev"
}
}
}

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Recursion Context package.
*
@@ -7,9 +7,19 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\RecursionContext;
use const PHP_INT_MAX;
use const PHP_INT_MIN;
use function array_pop;
use function array_slice;
use function count;
use function is_array;
use function is_object;
use function random_int;
use function spl_object_hash;
use SplObjectStorage;
/**
* A context containing previously processed arrays and objects
* when recursively processing a value.
@@ -22,33 +32,52 @@ final class Context
private $arrays;
/**
* @var \SplObjectStorage
* @var SplObjectStorage
*/
private $objects;
/**
* Initialises the context
* Initialises the context.
*/
public function __construct()
{
$this->arrays = array();
$this->objects = new \SplObjectStorage;
$this->arrays = [];
$this->objects = new SplObjectStorage;
}
/**
* @codeCoverageIgnore
*/
public function __destruct()
{
foreach ($this->arrays as &$array) {
if (is_array($array)) {
array_pop($array);
array_pop($array);
}
}
}
/**
* Adds a value to the context.
*
* @param array|object $value The value to add.
*
* @return int|string The ID of the stored value, either as a string or integer.
* @param array|object $value the value to add
*
* @throws InvalidArgumentException Thrown if $value is not an array or object
*
* @return bool|int|string the ID of the stored value, either as a string or integer
*
* @psalm-template T
* @psalm-param T $value
* @param-out T $value
*/
public function add(&$value)
{
if (is_array($value)) {
return $this->addArray($value);
} elseif (is_object($value)) {
}
if (is_object($value)) {
return $this->addObject($value);
}
@@ -60,17 +89,23 @@ final class Context
/**
* Checks if the given value exists within the context.
*
* @param array|object $value The value to check.
*
* @return int|string|false The string or integer ID of the stored value if it has already been seen, or false if the value is not stored.
* @param array|object $value the value to check
*
* @throws InvalidArgumentException Thrown if $value is not an array or object
*
* @return false|int|string the string or integer ID of the stored value if it has already been seen, or false if the value is not stored
*
* @psalm-template T
* @psalm-param T $value
* @param-out T $value
*/
public function contains(&$value)
{
if (is_array($value)) {
return $this->containsArray($value);
} elseif (is_object($value)) {
}
if (is_object($value)) {
return $this->containsObject($value);
}
@@ -80,8 +115,6 @@ final class Context
}
/**
* @param array $array
*
* @return bool|int
*/
private function addArray(array &$array)
@@ -117,10 +150,8 @@ final class Context
/**
* @param object $object
*
* @return string
*/
private function addObject($object)
private function addObject($object): string
{
if (!$this->objects->contains($object)) {
$this->objects->attach($object);
@@ -130,9 +161,7 @@ final class Context
}
/**
* @param array $array
*
* @return int|false
* @return false|int
*/
private function containsArray(array &$array)
{
@@ -144,7 +173,7 @@ final class Context
/**
* @param object $value
*
* @return string|false
* @return false|string
*/
private function containsObject($value)
{
@@ -154,14 +183,4 @@ final class Context
return false;
}
public function __destruct()
{
foreach ($this->arrays as &$array) {
if (is_array($array)) {
array_pop($array);
array_pop($array);
}
}
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Recursion Context package.
*
@@ -7,11 +7,10 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\RecursionContext;
/**
*/
interface Exception
use Throwable;
interface Exception extends Throwable
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Recursion Context package.
*
@@ -7,11 +7,8 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\RecursionContext;
/**
*/
final class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
}

View File

@@ -1,142 +0,0 @@
<?php
/*
* This file is part of the Recursion Context package.
*
* (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\RecursionContext;
use PHPUnit\Framework\TestCase;
/**
* @covers SebastianBergmann\RecursionContext\Context
*/
class ContextTest extends TestCase
{
/**
* @var \SebastianBergmann\RecursionContext\Context
*/
private $context;
protected function setUp()
{
$this->context = new Context();
}
public function failsProvider()
{
return array(
array(true),
array(false),
array(null),
array('string'),
array(1),
array(1.5),
array(fopen('php://memory', 'r'))
);
}
public function valuesProvider()
{
$obj2 = new \stdClass();
$obj2->foo = 'bar';
$obj3 = (object) array(1,2,"Test\r\n",4,5,6,7,8);
$obj = new \stdClass();
//@codingStandardsIgnoreStart
$obj->null = null;
//@codingStandardsIgnoreEnd
$obj->boolean = true;
$obj->integer = 1;
$obj->double = 1.2;
$obj->string = '1';
$obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
$obj->object = $obj2;
$obj->objectagain = $obj2;
$obj->array = array('foo' => 'bar');
$obj->array2 = array(1,2,3,4,5,6);
$obj->array3 = array($obj, $obj2, $obj3);
$obj->self = $obj;
$storage = new \SplObjectStorage();
$storage->attach($obj2);
$storage->foo = $obj2;
return array(
array($obj, spl_object_hash($obj)),
array($obj2, spl_object_hash($obj2)),
array($obj3, spl_object_hash($obj3)),
array($storage, spl_object_hash($storage)),
array($obj->array, 0),
array($obj->array2, 0),
array($obj->array3, 0)
);
}
/**
* @covers SebastianBergmann\RecursionContext\Context::add
* @uses SebastianBergmann\RecursionContext\InvalidArgumentException
* @dataProvider failsProvider
*/
public function testAddFails($value)
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('Only arrays and objects are supported');
$this->context->add($value);
}
/**
* @covers SebastianBergmann\RecursionContext\Context::contains
* @uses SebastianBergmann\RecursionContext\InvalidArgumentException
* @dataProvider failsProvider
*/
public function testContainsFails($value)
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('Only arrays and objects are supported');
$this->context->contains($value);
}
/**
* @covers SebastianBergmann\RecursionContext\Context::add
* @dataProvider valuesProvider
*/
public function testAdd($value, $key)
{
$this->assertEquals($key, $this->context->add($value));
// Test we get the same key on subsequent adds
$this->assertEquals($key, $this->context->add($value));
}
/**
* @covers SebastianBergmann\RecursionContext\Context::contains
* @uses SebastianBergmann\RecursionContext\Context::add
* @depends testAdd
* @dataProvider valuesProvider
*/
public function testContainsFound($value, $key)
{
$this->context->add($value);
$this->assertEquals($key, $this->context->contains($value));
// Test we get the same key on subsequent calls
$this->assertEquals($key, $this->context->contains($value));
}
/**
* @covers SebastianBergmann\RecursionContext\Context::contains
* @dataProvider valuesProvider
*/
public function testContainsNotFound($value)
{
$this->assertFalse($this->context->contains($value));
}
}