first commit
This commit is contained in:
		
							
								
								
									
										8
									
								
								vendor/sebastian/object-enumerator/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								vendor/sebastian/object-enumerator/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
.idea
 | 
			
		||||
composer.lock
 | 
			
		||||
composer.phar
 | 
			
		||||
vendor/
 | 
			
		||||
cache.properties
 | 
			
		||||
build/LICENSE
 | 
			
		||||
build/README.md
 | 
			
		||||
build/*.tgz
 | 
			
		||||
							
								
								
									
										67
									
								
								vendor/sebastian/object-enumerator/.php_cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								vendor/sebastian/object-enumerator/.php_cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,67 @@
 | 
			
		||||
<?php
 | 
			
		||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
 | 
			
		||||
    ->files()
 | 
			
		||||
    ->in('src')
 | 
			
		||||
    ->in('tests')
 | 
			
		||||
    ->name('*.php');
 | 
			
		||||
 | 
			
		||||
return Symfony\CS\Config\Config::create()
 | 
			
		||||
    ->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
 | 
			
		||||
    ->fixers(
 | 
			
		||||
        array(
 | 
			
		||||
            'align_double_arrow',
 | 
			
		||||
            'align_equals',
 | 
			
		||||
            'braces',
 | 
			
		||||
            'concat_with_spaces',
 | 
			
		||||
            'duplicate_semicolon',
 | 
			
		||||
            'elseif',
 | 
			
		||||
            'empty_return',
 | 
			
		||||
            'encoding',
 | 
			
		||||
            'eof_ending',
 | 
			
		||||
            'extra_empty_lines',
 | 
			
		||||
            'function_call_space',
 | 
			
		||||
            'function_declaration',
 | 
			
		||||
            'indentation',
 | 
			
		||||
            'join_function',
 | 
			
		||||
            'line_after_namespace',
 | 
			
		||||
            'linefeed',
 | 
			
		||||
            'list_commas',
 | 
			
		||||
            'lowercase_constants',
 | 
			
		||||
            'lowercase_keywords',
 | 
			
		||||
            'method_argument_space',
 | 
			
		||||
            'multiple_use',
 | 
			
		||||
            'namespace_no_leading_whitespace',
 | 
			
		||||
            'no_blank_lines_after_class_opening',
 | 
			
		||||
            'no_empty_lines_after_phpdocs',
 | 
			
		||||
            'parenthesis',
 | 
			
		||||
            'php_closing_tag',
 | 
			
		||||
            'phpdoc_indent',
 | 
			
		||||
            'phpdoc_no_access',
 | 
			
		||||
            'phpdoc_no_empty_return',
 | 
			
		||||
            'phpdoc_no_package',
 | 
			
		||||
            'phpdoc_params',
 | 
			
		||||
            'phpdoc_scalar',
 | 
			
		||||
            'phpdoc_separation',
 | 
			
		||||
            'phpdoc_to_comment',
 | 
			
		||||
            'phpdoc_trim',
 | 
			
		||||
            'phpdoc_types',
 | 
			
		||||
            'phpdoc_var_without_name',
 | 
			
		||||
            'remove_lines_between_uses',
 | 
			
		||||
            'return',
 | 
			
		||||
            'self_accessor',
 | 
			
		||||
            'short_array_syntax',
 | 
			
		||||
            'short_tag',
 | 
			
		||||
            'single_line_after_imports',
 | 
			
		||||
            'single_quote',
 | 
			
		||||
            'spaces_before_semicolon',
 | 
			
		||||
            'spaces_cast',
 | 
			
		||||
            'ternary_spaces',
 | 
			
		||||
            'trailing_spaces',
 | 
			
		||||
            'trim_array_spaces',
 | 
			
		||||
            'unused_use',
 | 
			
		||||
            'visibility',
 | 
			
		||||
            'whitespacy_lines'
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
    ->finder($finder);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								vendor/sebastian/object-enumerator/.travis.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								vendor/sebastian/object-enumerator/.travis.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
language: php
 | 
			
		||||
 | 
			
		||||
php:
 | 
			
		||||
  - 5.6
 | 
			
		||||
  - 7.0
 | 
			
		||||
  - 7.1
 | 
			
		||||
  - nightly
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								vendor/sebastian/object-enumerator/ChangeLog.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								vendor/sebastian/object-enumerator/ChangeLog.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
# Change Log
 | 
			
		||||
 | 
			
		||||
All notable changes to `sebastianbergmann/object-enumerator` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
 | 
			
		||||
 | 
			
		||||
## [2.0.1] - 2017-02-18
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
 | 
			
		||||
* Fixed [#2](https://github.com/sebastianbergmann/phpunit/pull/2): Exceptions in `ReflectionProperty::getValue()` are not handled
 | 
			
		||||
 | 
			
		||||
## [2.0.0] - 2016-11-19
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 | 
			
		||||
* This component is now compatible with `sebastian/recursion-context: ~1.0.4`
 | 
			
		||||
 | 
			
		||||
## 1.0.0 - 2016-02-04
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
 | 
			
		||||
* Initial release
 | 
			
		||||
 | 
			
		||||
[2.0.1]: https://github.com/sebastianbergmann/object-enumerator/compare/2.0.0...2.0.1
 | 
			
		||||
[2.0.0]: https://github.com/sebastianbergmann/object-enumerator/compare/1.0...2.0.0
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										33
									
								
								vendor/sebastian/object-enumerator/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								vendor/sebastian/object-enumerator/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
Object Enumerator
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2016, Sebastian Bergmann <sebastian@phpunit.de>.
 | 
			
		||||
All rights reserved.
 | 
			
		||||
 | 
			
		||||
Redistribution and use in source and binary forms, with or without
 | 
			
		||||
modification, are permitted provided that the following conditions
 | 
			
		||||
are met:
 | 
			
		||||
 | 
			
		||||
 * Redistributions of source code must retain the above copyright
 | 
			
		||||
   notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 | 
			
		||||
 * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
   notice, this list of conditions and the following disclaimer in
 | 
			
		||||
   the documentation and/or other materials provided with the
 | 
			
		||||
   distribution.
 | 
			
		||||
 | 
			
		||||
 * Neither the name of Sebastian Bergmann nor the names of his
 | 
			
		||||
   contributors may be used to endorse or promote products derived
 | 
			
		||||
   from this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
			
		||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 | 
			
		||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 | 
			
		||||
POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
							
								
								
									
										14
									
								
								vendor/sebastian/object-enumerator/README.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								vendor/sebastian/object-enumerator/README.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
# Object Enumerator
 | 
			
		||||
 | 
			
		||||
Traverses array structures and object graphs to enumerate all referenced objects.
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
 | 
			
		||||
 | 
			
		||||
    composer require sebastian/object-enumerator
 | 
			
		||||
 | 
			
		||||
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/object-enumerator
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								vendor/sebastian/object-enumerator/build.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								vendor/sebastian/object-enumerator/build.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project name="object-enumerator" 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">
 | 
			
		||||
            <env key="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
 | 
			
		||||
            <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>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										34
									
								
								vendor/sebastian/object-enumerator/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								vendor/sebastian/object-enumerator/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "sebastian/object-enumerator",
 | 
			
		||||
    "description": "Traverses array structures and object graphs to enumerate all referenced objects",
 | 
			
		||||
    "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
 | 
			
		||||
    "license": "BSD-3-Clause",
 | 
			
		||||
    "authors": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Sebastian Bergmann",
 | 
			
		||||
            "email": "sebastian@phpunit.de"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "require": {
 | 
			
		||||
        "php": ">=5.6",
 | 
			
		||||
        "sebastian/recursion-context": "~2.0"
 | 
			
		||||
    },
 | 
			
		||||
    "require-dev": {
 | 
			
		||||
        "phpunit/phpunit": "~5"
 | 
			
		||||
    },
 | 
			
		||||
    "autoload": {
 | 
			
		||||
        "classmap": [
 | 
			
		||||
            "src/"
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    "autoload-dev": {
 | 
			
		||||
        "classmap": [
 | 
			
		||||
            "tests/"
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    "extra": {
 | 
			
		||||
        "branch-alias": {
 | 
			
		||||
            "dev-master": "2.0.x-dev"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								vendor/sebastian/object-enumerator/phpunit.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								vendor/sebastian/object-enumerator/phpunit.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
 | 
			
		||||
         bootstrap="vendor/autoload.php"
 | 
			
		||||
         backupGlobals="false"
 | 
			
		||||
         beStrictAboutCoversAnnotation="true"
 | 
			
		||||
         beStrictAboutOutputDuringTests="true"
 | 
			
		||||
         beStrictAboutTestsThatDoNotTestAnything="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>
 | 
			
		||||
							
								
								
									
										93
									
								
								vendor/sebastian/object-enumerator/src/Enumerator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								vendor/sebastian/object-enumerator/src/Enumerator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,93 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of Object Enumerator.
 | 
			
		||||
 *
 | 
			
		||||
 * (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\ObjectEnumerator;
 | 
			
		||||
 | 
			
		||||
use SebastianBergmann\RecursionContext\Context;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Traverses array structures and object graphs
 | 
			
		||||
 * to enumerate all referenced objects.
 | 
			
		||||
 */
 | 
			
		||||
class Enumerator
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns an array of all objects referenced either
 | 
			
		||||
     * directly or indirectly by a variable.
 | 
			
		||||
     *
 | 
			
		||||
     * @param array|object $variable
 | 
			
		||||
     *
 | 
			
		||||
     * @return object[]
 | 
			
		||||
     */
 | 
			
		||||
    public function enumerate($variable)
 | 
			
		||||
    {
 | 
			
		||||
        if (!is_array($variable) && !is_object($variable)) {
 | 
			
		||||
            throw new InvalidArgumentException;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (isset(func_get_args()[1])) {
 | 
			
		||||
            if (!func_get_args()[1] instanceof Context) {
 | 
			
		||||
                throw new InvalidArgumentException;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $processed = func_get_args()[1];
 | 
			
		||||
        } else {
 | 
			
		||||
            $processed = new Context;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $objects = [];
 | 
			
		||||
 | 
			
		||||
        if ($processed->contains($variable)) {
 | 
			
		||||
            return $objects;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $array = $variable;
 | 
			
		||||
        $processed->add($variable);
 | 
			
		||||
 | 
			
		||||
        if (is_array($variable)) {
 | 
			
		||||
            foreach ($array as $element) {
 | 
			
		||||
                if (!is_array($element) && !is_object($element)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $objects = array_merge(
 | 
			
		||||
                    $objects,
 | 
			
		||||
                    $this->enumerate($element, $processed)
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            $objects[] = $variable;
 | 
			
		||||
            $reflector = new \ReflectionObject($variable);
 | 
			
		||||
 | 
			
		||||
            foreach ($reflector->getProperties() as $attribute) {
 | 
			
		||||
                $attribute->setAccessible(true);
 | 
			
		||||
 | 
			
		||||
                try {
 | 
			
		||||
                    $value = $attribute->getValue($variable);
 | 
			
		||||
                } catch (\Throwable $e) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                } catch (\Exception $e) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (!is_array($value) && !is_object($value)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                $objects = array_merge(
 | 
			
		||||
                    $objects,
 | 
			
		||||
                    $this->enumerate($value, $processed)
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $objects;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/sebastian/object-enumerator/src/Exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								vendor/sebastian/object-enumerator/src/Exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of Object Enumerator.
 | 
			
		||||
 *
 | 
			
		||||
 * (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\ObjectEnumerator;
 | 
			
		||||
 | 
			
		||||
interface Exception
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/sebastian/object-enumerator/src/InvalidArgumentException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								vendor/sebastian/object-enumerator/src/InvalidArgumentException.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of Object Enumerator.
 | 
			
		||||
 *
 | 
			
		||||
 * (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\ObjectEnumerator;
 | 
			
		||||
 | 
			
		||||
class InvalidArgumentException extends \InvalidArgumentException implements Exception
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										138
									
								
								vendor/sebastian/object-enumerator/tests/EnumeratorTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								vendor/sebastian/object-enumerator/tests/EnumeratorTest.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,138 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of Object Enumerator.
 | 
			
		||||
 *
 | 
			
		||||
 * (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\ObjectEnumerator;
 | 
			
		||||
 | 
			
		||||
use SebastianBergmann\ObjectEnumerator\Fixtures\ExceptionThrower;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @covers SebastianBergmann\ObjectEnumerator\Enumerator
 | 
			
		||||
 */
 | 
			
		||||
class EnumeratorTest extends \PHPUnit_Framework_TestCase
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Enumerator
 | 
			
		||||
     */
 | 
			
		||||
    private $enumerator;
 | 
			
		||||
 | 
			
		||||
    protected function setUp()
 | 
			
		||||
    {
 | 
			
		||||
        $this->enumerator = new Enumerator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesSingleObject()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate($a);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(1, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesArrayWithSingleObject()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate([$a]);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(1, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesArrayWithTwoReferencesToTheSameObject()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate([$a, $a]);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(1, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesArrayOfObjects()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
        $b = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate([$a, $b, null]);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(2, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
        $this->assertSame($b, $objects[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesObjectWithAggregatedObject()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
        $b = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $a->b = $b;
 | 
			
		||||
        $a->c = null;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate($a);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(2, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
        $this->assertSame($b, $objects[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesObjectWithAggregatedObjectsInArray()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
        $b = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $a->b = [$b];
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate($a);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(2, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
        $this->assertSame($b, $objects[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesObjectsWithCyclicReferences()
 | 
			
		||||
    {
 | 
			
		||||
        $a = new \stdClass;
 | 
			
		||||
        $b = new \stdClass;
 | 
			
		||||
 | 
			
		||||
        $a->b = $b;
 | 
			
		||||
        $b->a = $a;
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate([$a, $b]);
 | 
			
		||||
 | 
			
		||||
        $this->assertCount(2, $objects);
 | 
			
		||||
        $this->assertSame($a, $objects[0]);
 | 
			
		||||
        $this->assertSame($b, $objects[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testEnumeratesClassThatThrowsException()
 | 
			
		||||
    {
 | 
			
		||||
        $thrower = new ExceptionThrower();
 | 
			
		||||
 | 
			
		||||
        $objects = $this->enumerator->enumerate($thrower);
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($thrower, $objects[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testExceptionIsRaisedForInvalidArgument()
 | 
			
		||||
    {
 | 
			
		||||
        $this->setExpectedException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->enumerator->enumerate(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testExceptionIsRaisedForInvalidArgument2()
 | 
			
		||||
    {
 | 
			
		||||
        $this->setExpectedException(InvalidArgumentException::class);
 | 
			
		||||
 | 
			
		||||
        $this->enumerator->enumerate([], '');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								vendor/sebastian/object-enumerator/tests/Fixtures/ExceptionThrower.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								vendor/sebastian/object-enumerator/tests/Fixtures/ExceptionThrower.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of Object Enumerator.
 | 
			
		||||
 *
 | 
			
		||||
 * (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\ObjectEnumerator\Fixtures;
 | 
			
		||||
 | 
			
		||||
use RuntimeException;
 | 
			
		||||
 | 
			
		||||
class ExceptionThrower
 | 
			
		||||
{
 | 
			
		||||
    private $property;
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        unset($this->property);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __get($property)
 | 
			
		||||
    {
 | 
			
		||||
        throw new RuntimeException;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user