pax_global_header00006660000000000000000000000064130666745170014531gustar00rootroot0000000000000052 comment=773f97c67f28de00d397be301821b06708fca0be object-reflector-1.1.1/000077500000000000000000000000001306667451700147625ustar00rootroot00000000000000object-reflector-1.1.1/.gitignore000066400000000000000000000000551306667451700167520ustar00rootroot00000000000000/.idea /.php_cs.cache /composer.lock /vendor object-reflector-1.1.1/.php_cs000066400000000000000000000056341306667451700162470ustar00rootroot00000000000000 For the full copyright and license information, please view the LICENSE file that was distributed with this source code. EOF; return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules( [ 'array_syntax' => ['syntax' => 'short'], 'binary_operator_spaces' => [ 'align_double_arrow' => true, 'align_equals' => true ], 'blank_line_after_namespace' => true, 'blank_line_before_return' => true, 'braces' => true, 'cast_spaces' => true, 'concat_space' => ['spacing' => 'one'], 'declare_strict_types' => true, 'elseif' => true, 'encoding' => true, 'full_opening_tag' => true, 'function_declaration' => true, #'header_comment' => ['header' => $header, 'separate' => 'none'], 'indentation_type' => true, 'line_ending' => true, 'lowercase_constants' => true, 'lowercase_keywords' => true, 'method_argument_space' => true, 'no_alias_functions' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_closing_tag' => true, 'no_empty_phpdoc' => true, 'no_empty_statement' => true, 'no_extra_consecutive_blank_lines' => true, 'no_leading_namespace_whitespace' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_after_function_name' => true, 'no_spaces_inside_parenthesis' => true, 'no_trailing_comma_in_list_call' => true, 'no_trailing_whitespace' => true, 'no_unused_imports' => true, 'no_whitespace_in_blank_line' => true, 'phpdoc_align' => true, 'phpdoc_indent' => true, 'phpdoc_no_access' => true, 'phpdoc_no_empty_return' => true, 'phpdoc_no_package' => true, 'phpdoc_scalar' => true, 'phpdoc_separation' => true, 'phpdoc_to_comment' => true, 'phpdoc_trim' => true, 'phpdoc_types' => true, 'phpdoc_var_without_name' => true, 'self_accessor' => true, 'simplified_null_return' => true, 'single_blank_line_at_eof' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, 'single_quote' => true, 'ternary_operator_spaces' => true, 'trim_array_spaces' => true, 'visibility_required' => true, ] ) ->setFinder( PhpCsFixer\Finder::create() ->files() ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests') ->name('*.php') ); object-reflector-1.1.1/.travis.yml000066400000000000000000000007021306667451700170720ustar00rootroot00000000000000language: 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 --coverage-clover=coverage.xml after_success: - bash <(curl -s https://codecov.io/bash) notifications: email: false object-reflector-1.1.1/ChangeLog.md000066400000000000000000000013001306667451700171250ustar00rootroot00000000000000# Change Log All notable changes to `sebastianbergmann/object-reflector` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## 1.1.1 - 2017-03-29 * Fixed [#1](https://github.com/sebastianbergmann/object-reflector/issues/1): Attributes that with non-string names are not handled correctly ## 1.1.0 - 2017-03-16 ### Changed * Changed implementation of `ObjectReflector::getattributes()` to use `(array)` cast instead of `ReflectionObject` ## 1.0.0 - 2017-03-12 * Initial release [1.1.1]: https://github.com/sebastianbergmann/object-enumerator/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/sebastianbergmann/object-enumerator/compare/1.0.0...1.1.0 object-reflector-1.1.1/LICENSE000066400000000000000000000030121306667451700157630ustar00rootroot00000000000000Object Reflector Copyright (c) 2017, Sebastian Bergmann . 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. object-reflector-1.1.1/README.md000066400000000000000000000007631306667451700162470ustar00rootroot00000000000000# Object Reflector Allows reflection of object attributes, including inherited and non-public ones. ## Installation You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): composer require sebastian/object-reflector 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-reflector object-reflector-1.1.1/build.xml000066400000000000000000000014321306667451700166030ustar00rootroot00000000000000 object-reflector-1.1.1/composer.json000066400000000000000000000013571306667451700175120ustar00rootroot00000000000000{ "name": "sebastian/object-reflector", "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", "license": "BSD-3-Clause", "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "require": { "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" }, "autoload": { "classmap": [ "src/" ] }, "autoload-dev": { "classmap": [ "tests/_fixture/" ] }, "extra": { "branch-alias": { "dev-master": "1.1-dev" } } } object-reflector-1.1.1/phpunit.xml000066400000000000000000000012651306667451700171770ustar00rootroot00000000000000 tests src object-reflector-1.1.1/src/000077500000000000000000000000001306667451700155515ustar00rootroot00000000000000object-reflector-1.1.1/src/Exception.php000066400000000000000000000005161306667451700202220ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector; interface Exception { } object-reflector-1.1.1/src/InvalidArgumentException.php000066400000000000000000000006201306667451700232300ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector; class InvalidArgumentException extends \InvalidArgumentException implements Exception { } object-reflector-1.1.1/src/ObjectReflector.php000066400000000000000000000022101306667451700213310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector; class ObjectReflector { /** * @param object $object * * @return array * * @throws InvalidArgumentException */ public function getAttributes($object): array { if (!is_object($object)) { throw new InvalidArgumentException; } $attributes = []; $className = get_class($object); foreach ((array) $object as $name => $value) { $name = explode("\0", (string) $name); if (count($name) === 1) { $name = $name[0]; } else { if ($name[1] !== $className) { $name = $name[1] . '::' . $name[2]; } else { $name = $name[2]; } } $attributes[$name] = $value; } return $attributes; } } object-reflector-1.1.1/tests/000077500000000000000000000000001306667451700161245ustar00rootroot00000000000000object-reflector-1.1.1/tests/ObjectReflectorTest.php000066400000000000000000000037451306667451700225620ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector; use PHPUnit\Framework\TestCase; use SebastianBergmann\ObjectReflector\TestFixture\ChildClass; use SebastianBergmann\ObjectReflector\TestFixture\ClassWithIntegerAttributeName; /** * @covers SebastianBergmann\ObjectReflector\ObjectReflector */ class ObjectReflectorTest extends TestCase { /** * @var ObjectReflector */ private $objectReflector; protected function setUp()/*: void */ { $this->objectReflector = new ObjectReflector; } public function testReflectsAttributesOfObject()/*: void */ { $o = new ChildClass; $this->assertEquals( [ 'privateInChild' => 'private', 'protectedInChild' => 'protected', 'publicInChild' => 'public', 'undeclared' => 'undeclared', 'SebastianBergmann\ObjectReflector\TestFixture\ParentClass::privateInParent' => 'private', 'SebastianBergmann\ObjectReflector\TestFixture\ParentClass::protectedInParent' => 'protected', 'SebastianBergmann\ObjectReflector\TestFixture\ParentClass::publicInParent' => 'public', ], $this->objectReflector->getAttributes($o) ); } public function testReflectsAttributeWithIntegerName()/*: void */ { $o = new ClassWithIntegerAttributeName; $this->assertEquals( [ 1 => 2 ], $this->objectReflector->getAttributes($o) ); } public function testRaisesExceptionWhenPassedArgumentIsNotAnObject()/*: void */ { $this->expectException(InvalidArgumentException::class); $this->objectReflector->getAttributes(null); } } object-reflector-1.1.1/tests/_fixture/000077500000000000000000000000001306667451700177515ustar00rootroot00000000000000object-reflector-1.1.1/tests/_fixture/ChildClass.php000066400000000000000000000011011306667451700224640ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector\TestFixture; class ChildClass extends ParentClass { private $privateInChild = 'private'; private $protectedInChild = 'protected'; private $publicInChild = 'public'; public function __construct() { $this->undeclared = 'undeclared'; } } object-reflector-1.1.1/tests/_fixture/ClassWithIntegerAttributeName.php000066400000000000000000000007061306667451700263710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector\TestFixture; class ClassWithIntegerAttributeName { public function __construct() { $i = 1; $this->$i = 2; } } object-reflector-1.1.1/tests/_fixture/ParentClass.php000066400000000000000000000007301306667451700227010ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types=1); namespace SebastianBergmann\ObjectReflector\TestFixture; class ParentClass { private $privateInParent = 'private'; private $protectedInParent = 'protected'; private $publicInParent = 'public'; }