00f100/fcphp-di
Advanced tools
| root = true | ||
| [*] | ||
| end_of_line = lf | ||
| [*.php] | ||
| insert_final_newline = true | ||
| [*.{php,xml,json,md}] | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 4 | ||
| [*.yml] | ||
| indent_style = space | ||
| indent_size = 2 |
| vendor | ||
| tests/coverage |
| language: php | ||
| php: | ||
| - 7.2 | ||
| before_script: | ||
| - travis_retry composer self-update | ||
| - travis_retry composer install --no-interaction --prefer-source --dev | ||
| script: | ||
| - vendor/bin/phpunit --coverage-clover=coverage.xml | ||
| after_success: | ||
| - bash <(curl -s https://codecov.io/bash) |
| { | ||
| "name": "00f100/fcphp-di", | ||
| "type": "package", | ||
| "version": "0.4.0", | ||
| "description": "Dependency Injection for FcPHP", | ||
| "keywords": ["dependency", "injection", "di", "php", "fcphp"], | ||
| "homepage": "https://github.com/00f100/fcphp-di", | ||
| "authors": [ | ||
| { | ||
| "name": "João Moraes", | ||
| "email": "joaomoraesbr@gmail.com", | ||
| "homepage": "https://github.com/00f100" | ||
| } | ||
| ], | ||
| "require": { | ||
| "php": ">=7.2" | ||
| }, | ||
| "require-dev": { | ||
| "00f100/phpdbug": "*", | ||
| "phpunit/phpunit": "6.*" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "FcPhp\\Di\\": "src/", | ||
| "FcPhp\\Di\\Test\\": "tests/" | ||
| } | ||
| } | ||
| } |
| { | ||
| "_readme": [ | ||
| "This file locks the dependencies of your project to a known state", | ||
| "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | ||
| "This file is @generated automatically" | ||
| ], | ||
| "content-hash": "fd9e1ef21cd165902746b43681fc1066", | ||
| "packages": [], | ||
| "packages-dev": [ | ||
| { | ||
| "name": "00f100/phpdbug", | ||
| "version": "0.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/00F100/phpdbug.git", | ||
| "reference": "ffe174fb589e1d7d7f7043d6150b4759adce2b6d" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/00F100/phpdbug/zipball/ffe174fb589e1d7d7f7043d6150b4759adce2b6d", | ||
| "reference": "ffe174fb589e1d7d7f7043d6150b4759adce2b6d", | ||
| "shasum": "" | ||
| }, | ||
| "type": "package", | ||
| "autoload": { | ||
| "files": [ | ||
| "src/functions.php" | ||
| ], | ||
| "psr-4": { | ||
| "PHPdbug\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "authors": [ | ||
| { | ||
| "name": "João Moraes", | ||
| "email": "joaomoraesbr@gmail.com", | ||
| "homepage": "https://github.com/00f100" | ||
| } | ||
| ], | ||
| "description": "Package to debug everything in PHP", | ||
| "homepage": "https://github.com/00f100/phpdbug", | ||
| "keywords": [ | ||
| "denbug", | ||
| "php" | ||
| ], | ||
| "time": "2017-07-27T14:09:24+00:00" | ||
| }, | ||
| { | ||
| "name": "doctrine/instantiator", | ||
| "version": "1.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/doctrine/instantiator.git", | ||
| "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", | ||
| "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.1" | ||
| }, | ||
| "require-dev": { | ||
| "athletic/athletic": "~0.1.8", | ||
| "ext-pdo": "*", | ||
| "ext-phar": "*", | ||
| "phpunit/phpunit": "^6.2.3", | ||
| "squizlabs/php_codesniffer": "^3.0.2" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.2.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Marco Pivetta", | ||
| "email": "ocramius@gmail.com", | ||
| "homepage": "http://ocramius.github.com/" | ||
| } | ||
| ], | ||
| "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", | ||
| "homepage": "https://github.com/doctrine/instantiator", | ||
| "keywords": [ | ||
| "constructor", | ||
| "instantiate" | ||
| ], | ||
| "time": "2017-07-22T11:58:36+00:00" | ||
| }, | ||
| { | ||
| "name": "myclabs/deep-copy", | ||
| "version": "1.8.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/myclabs/DeepCopy.git", | ||
| "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/478465659fd987669df0bd8a9bf22a8710e5f1b6", | ||
| "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.1" | ||
| }, | ||
| "replace": { | ||
| "myclabs/deep-copy": "self.version" | ||
| }, | ||
| "require-dev": { | ||
| "doctrine/collections": "^1.0", | ||
| "doctrine/common": "^2.6", | ||
| "phpunit/phpunit": "^7.1" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "psr-4": { | ||
| "DeepCopy\\": "src/DeepCopy/" | ||
| }, | ||
| "files": [ | ||
| "src/DeepCopy/deep_copy.php" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "description": "Create deep copies (clones) of your objects", | ||
| "keywords": [ | ||
| "clone", | ||
| "copy", | ||
| "duplicate", | ||
| "object", | ||
| "object graph" | ||
| ], | ||
| "time": "2018-05-29T17:25:09+00:00" | ||
| }, | ||
| { | ||
| "name": "phar-io/manifest", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phar-io/manifest.git", | ||
| "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", | ||
| "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-phar": "*", | ||
| "phar-io/version": "^1.0.1", | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Heuer", | ||
| "email": "sebastian@phpeople.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", | ||
| "time": "2017-03-05T18:14:27+00:00" | ||
| }, | ||
| { | ||
| "name": "phar-io/version", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phar-io/version.git", | ||
| "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", | ||
| "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Heuer", | ||
| "email": "sebastian@phpeople.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "Library for handling version information and constraints", | ||
| "time": "2017-03-05T17:38:23+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/reflection-common", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/ReflectionCommon.git", | ||
| "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", | ||
| "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.5" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.6" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jaap van Otterdijk", | ||
| "email": "opensource@ijaap.nl" | ||
| } | ||
| ], | ||
| "description": "Common reflection classes used by phpdocumentor to reflect the code structure", | ||
| "homepage": "http://www.phpdoc.org", | ||
| "keywords": [ | ||
| "FQSEN", | ||
| "phpDocumentor", | ||
| "phpdoc", | ||
| "reflection", | ||
| "static analysis" | ||
| ], | ||
| "time": "2017-09-11T18:02:19+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/reflection-docblock", | ||
| "version": "4.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", | ||
| "reference": "94fd0001232e47129dd3504189fa1c7225010d08" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", | ||
| "reference": "94fd0001232e47129dd3504189fa1c7225010d08", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "phpdocumentor/reflection-common": "^1.0.0", | ||
| "phpdocumentor/type-resolver": "^0.4.0", | ||
| "webmozart/assert": "^1.0" | ||
| }, | ||
| "require-dev": { | ||
| "doctrine/instantiator": "~1.0.5", | ||
| "mockery/mockery": "^1.0", | ||
| "phpunit/phpunit": "^6.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "4.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src/" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Mike van Riel", | ||
| "email": "me@mikevanriel.com" | ||
| } | ||
| ], | ||
| "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", | ||
| "time": "2017-11-30T07:14:17+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/type-resolver", | ||
| "version": "0.4.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/TypeResolver.git", | ||
| "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", | ||
| "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.5 || ^7.0", | ||
| "phpdocumentor/reflection-common": "^1.0" | ||
| }, | ||
| "require-dev": { | ||
| "mockery/mockery": "^0.9.4", | ||
| "phpunit/phpunit": "^5.2||^4.8.24" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src/" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Mike van Riel", | ||
| "email": "me@mikevanriel.com" | ||
| } | ||
| ], | ||
| "time": "2017-07-14T14:27:02+00:00" | ||
| }, | ||
| { | ||
| "name": "phpspec/prophecy", | ||
| "version": "1.7.6", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpspec/prophecy.git", | ||
| "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", | ||
| "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "doctrine/instantiator": "^1.0.2", | ||
| "php": "^5.3|^7.0", | ||
| "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", | ||
| "sebastian/comparator": "^1.1|^2.0|^3.0", | ||
| "sebastian/recursion-context": "^1.0|^2.0|^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpspec/phpspec": "^2.5|^3.2", | ||
| "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.7.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-0": { | ||
| "Prophecy\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Konstantin Kudryashov", | ||
| "email": "ever.zet@gmail.com", | ||
| "homepage": "http://everzet.com" | ||
| }, | ||
| { | ||
| "name": "Marcello Duarte", | ||
| "email": "marcello.duarte@gmail.com" | ||
| } | ||
| ], | ||
| "description": "Highly opinionated mocking framework for PHP 5.3+", | ||
| "homepage": "https://github.com/phpspec/prophecy", | ||
| "keywords": [ | ||
| "Double", | ||
| "Dummy", | ||
| "fake", | ||
| "mock", | ||
| "spy", | ||
| "stub" | ||
| ], | ||
| "time": "2018-04-18T13:57:24+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-code-coverage", | ||
| "version": "5.3.2", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-code-coverage.git", | ||
| "reference": "c89677919c5dd6d3b3852f230a663118762218ac" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", | ||
| "reference": "c89677919c5dd6d3b3852f230a663118762218ac", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-xmlwriter": "*", | ||
| "php": "^7.0", | ||
| "phpunit/php-file-iterator": "^1.4.2", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "phpunit/php-token-stream": "^2.0.1", | ||
| "sebastian/code-unit-reverse-lookup": "^1.0.1", | ||
| "sebastian/environment": "^3.0", | ||
| "sebastian/version": "^2.0.1", | ||
| "theseer/tokenizer": "^1.1" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "suggest": { | ||
| "ext-xdebug": "^2.5.5" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "5.3.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-code-coverage", | ||
| "keywords": [ | ||
| "coverage", | ||
| "testing", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-04-06T15:36:58+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-file-iterator", | ||
| "version": "1.4.5", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-file-iterator.git", | ||
| "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", | ||
| "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.3.3" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.4.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sb@sebastian-bergmann.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "FilterIterator implementation that filters files based on a list of suffixes.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", | ||
| "keywords": [ | ||
| "filesystem", | ||
| "iterator" | ||
| ], | ||
| "time": "2017-11-27T13:52:08+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-text-template", | ||
| "version": "1.2.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-text-template.git", | ||
| "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", | ||
| "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.3.3" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Simple template engine.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-text-template/", | ||
| "keywords": [ | ||
| "template" | ||
| ], | ||
| "time": "2015-06-21T13:50:34+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-timer", | ||
| "version": "1.0.9", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-timer.git", | ||
| "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", | ||
| "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.3.3 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sb@sebastian-bergmann.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Utility class for timing", | ||
| "homepage": "https://github.com/sebastianbergmann/php-timer/", | ||
| "keywords": [ | ||
| "timer" | ||
| ], | ||
| "time": "2017-02-26T11:10:40+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-token-stream", | ||
| "version": "2.0.2", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-token-stream.git", | ||
| "reference": "791198a2c6254db10131eecfe8c06670700904db" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", | ||
| "reference": "791198a2c6254db10131eecfe8c06670700904db", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-tokenizer": "*", | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.2.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Wrapper around PHP's tokenizer extension.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-token-stream/", | ||
| "keywords": [ | ||
| "tokenizer" | ||
| ], | ||
| "time": "2017-11-27T05:48:46+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/phpunit", | ||
| "version": "6.5.8", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/phpunit.git", | ||
| "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b", | ||
| "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-json": "*", | ||
| "ext-libxml": "*", | ||
| "ext-mbstring": "*", | ||
| "ext-xml": "*", | ||
| "myclabs/deep-copy": "^1.6.1", | ||
| "phar-io/manifest": "^1.0.1", | ||
| "phar-io/version": "^1.0", | ||
| "php": "^7.0", | ||
| "phpspec/prophecy": "^1.7", | ||
| "phpunit/php-code-coverage": "^5.3", | ||
| "phpunit/php-file-iterator": "^1.4.3", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "phpunit/php-timer": "^1.0.9", | ||
| "phpunit/phpunit-mock-objects": "^5.0.5", | ||
| "sebastian/comparator": "^2.1", | ||
| "sebastian/diff": "^2.0", | ||
| "sebastian/environment": "^3.1", | ||
| "sebastian/exporter": "^3.1", | ||
| "sebastian/global-state": "^2.0", | ||
| "sebastian/object-enumerator": "^3.0.3", | ||
| "sebastian/resource-operations": "^1.0", | ||
| "sebastian/version": "^2.0.1" | ||
| }, | ||
| "conflict": { | ||
| "phpdocumentor/reflection-docblock": "3.0.2", | ||
| "phpunit/dbunit": "<3.0" | ||
| }, | ||
| "require-dev": { | ||
| "ext-pdo": "*" | ||
| }, | ||
| "suggest": { | ||
| "ext-xdebug": "*", | ||
| "phpunit/php-invoker": "^1.1" | ||
| }, | ||
| "bin": [ | ||
| "phpunit" | ||
| ], | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "6.5.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "The PHP Unit Testing framework.", | ||
| "homepage": "https://phpunit.de/", | ||
| "keywords": [ | ||
| "phpunit", | ||
| "testing", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-04-10T11:38:34+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/phpunit-mock-objects", | ||
| "version": "5.0.7", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", | ||
| "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", | ||
| "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "doctrine/instantiator": "^1.0.5", | ||
| "php": "^7.0", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "sebastian/exporter": "^3.1" | ||
| }, | ||
| "conflict": { | ||
| "phpunit/phpunit": "<6.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.5" | ||
| }, | ||
| "suggest": { | ||
| "ext-soap": "*" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "5.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Mock Object library for PHPUnit", | ||
| "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", | ||
| "keywords": [ | ||
| "mock", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-05-29T13:50:43+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/code-unit-reverse-lookup", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", | ||
| "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", | ||
| "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^5.7 || ^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Looks up which function or method a line of code belongs to", | ||
| "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", | ||
| "time": "2017-03-04T06:30:41+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/comparator", | ||
| "version": "2.1.3", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/comparator.git", | ||
| "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", | ||
| "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/diff": "^2.0 || ^3.0", | ||
| "sebastian/exporter": "^3.1" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Volker Dusch", | ||
| "email": "github@wallbash.com" | ||
| }, | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@2bepublished.at" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides the functionality to compare PHP values for equality", | ||
| "homepage": "https://github.com/sebastianbergmann/comparator", | ||
| "keywords": [ | ||
| "comparator", | ||
| "compare", | ||
| "equality" | ||
| ], | ||
| "time": "2018-02-01T13:46:46+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/diff", | ||
| "version": "2.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/diff.git", | ||
| "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", | ||
| "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.2" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Kore Nordmann", | ||
| "email": "mail@kore-nordmann.de" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Diff implementation", | ||
| "homepage": "https://github.com/sebastianbergmann/diff", | ||
| "keywords": [ | ||
| "diff" | ||
| ], | ||
| "time": "2017-08-03T08:09:46+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/environment", | ||
| "version": "3.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/environment.git", | ||
| "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", | ||
| "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.1" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides functionality to handle HHVM/PHP environments", | ||
| "homepage": "http://www.github.com/sebastianbergmann/environment", | ||
| "keywords": [ | ||
| "Xdebug", | ||
| "environment", | ||
| "hhvm" | ||
| ], | ||
| "time": "2017-07-01T08:51:00+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/exporter", | ||
| "version": "3.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/exporter.git", | ||
| "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", | ||
| "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/recursion-context": "^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "ext-mbstring": "*", | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Volker Dusch", | ||
| "email": "github@wallbash.com" | ||
| }, | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@2bepublished.at" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| }, | ||
| { | ||
| "name": "Adam Harvey", | ||
| "email": "aharvey@php.net" | ||
| } | ||
| ], | ||
| "description": "Provides the functionality to export PHP variables for visualization", | ||
| "homepage": "http://www.github.com/sebastianbergmann/exporter", | ||
| "keywords": [ | ||
| "export", | ||
| "exporter" | ||
| ], | ||
| "time": "2017-04-03T13:19:02+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/global-state", | ||
| "version": "2.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/global-state.git", | ||
| "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", | ||
| "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "suggest": { | ||
| "ext-uopz": "*" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Snapshotting of global state", | ||
| "homepage": "http://www.github.com/sebastianbergmann/global-state", | ||
| "keywords": [ | ||
| "global state" | ||
| ], | ||
| "time": "2017-04-27T15:39:26+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/object-enumerator", | ||
| "version": "3.0.3", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/object-enumerator.git", | ||
| "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", | ||
| "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/object-reflector": "^1.1.1", | ||
| "sebastian/recursion-context": "^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Traverses array structures and object graphs to enumerate all referenced objects", | ||
| "homepage": "https://github.com/sebastianbergmann/object-enumerator/", | ||
| "time": "2017-08-03T12:35:26+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/object-reflector", | ||
| "version": "1.1.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/object-reflector.git", | ||
| "reference": "773f97c67f28de00d397be301821b06708fca0be" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", | ||
| "reference": "773f97c67f28de00d397be301821b06708fca0be", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.1-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Allows reflection of object attributes, including inherited and non-public ones", | ||
| "homepage": "https://github.com/sebastianbergmann/object-reflector/", | ||
| "time": "2017-03-29T09:07:27+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/recursion-context", | ||
| "version": "3.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/recursion-context.git", | ||
| "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", | ||
| "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| }, | ||
| { | ||
| "name": "Adam Harvey", | ||
| "email": "aharvey@php.net" | ||
| } | ||
| ], | ||
| "description": "Provides functionality to recursively process PHP variables", | ||
| "homepage": "http://www.github.com/sebastianbergmann/recursion-context", | ||
| "time": "2017-03-03T06:23:57+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/resource-operations", | ||
| "version": "1.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/resource-operations.git", | ||
| "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", | ||
| "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides a list of PHP built-in functions that operate on resources", | ||
| "homepage": "https://www.github.com/sebastianbergmann/resource-operations", | ||
| "time": "2015-07-28T20:34:47+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/version", | ||
| "version": "2.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/version.git", | ||
| "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", | ||
| "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.6" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Library that helps with managing the version number of Git-hosted PHP projects", | ||
| "homepage": "https://github.com/sebastianbergmann/version", | ||
| "time": "2016-10-03T07:35:21+00:00" | ||
| }, | ||
| { | ||
| "name": "theseer/tokenizer", | ||
| "version": "1.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/theseer/tokenizer.git", | ||
| "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", | ||
| "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-tokenizer": "*", | ||
| "ext-xmlwriter": "*", | ||
| "php": "^7.0" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", | ||
| "time": "2017-04-07T12:08:54+00:00" | ||
| }, | ||
| { | ||
| "name": "webmozart/assert", | ||
| "version": "1.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/webmozart/assert.git", | ||
| "reference": "0df1908962e7a3071564e857d86874dad1ef204a" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", | ||
| "reference": "0df1908962e7a3071564e857d86874dad1ef204a", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.3.3 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.6", | ||
| "sebastian/version": "^1.0.1" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.3-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Webmozart\\Assert\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@gmail.com" | ||
| } | ||
| ], | ||
| "description": "Assertions to validate method input/output with nice error messages.", | ||
| "keywords": [ | ||
| "assert", | ||
| "check", | ||
| "validate" | ||
| ], | ||
| "time": "2018-01-29T19:49:41+00:00" | ||
| } | ||
| ], | ||
| "aliases": [], | ||
| "minimum-stability": "stable", | ||
| "stability-flags": [], | ||
| "prefer-stable": false, | ||
| "prefer-lowest": false, | ||
| "platform": { | ||
| "php": "7.2.*" | ||
| }, | ||
| "platform-dev": [] | ||
| } |
| <?php | ||
| include(__DIR__ . '/../../vendor/autoload.php'); | ||
| use FcPhp\Di\Facades\DiFacade; | ||
| class TestClass | ||
| { | ||
| private $value; | ||
| public function setValue($value) { | ||
| $this->value = $value; | ||
| return $this; | ||
| } | ||
| public function getValue() | ||
| { | ||
| return $this->value; | ||
| } | ||
| } | ||
| // Init Di | ||
| $di = DiFacade::getInstance(); | ||
| // Configure classes | ||
| $di->set('TestClass', 'TestClass', [], ['setValue' => 'content']); | ||
| $di->set('TestClass2', 'TestClass', [], ['setValue' => $di->get('TestClass')]); | ||
| // Print: content | ||
| echo $di->make('TestClass2')->getValue()->getValue(); | ||
| echo "\n"; | ||
| $di->make('TestClass')->setValue('content-change'); | ||
| // Print: content-change | ||
| echo $di->make('TestClass')->getValue(); | ||
| echo "\n"; | ||
| // Print: test-change | ||
| echo $di->make('TestClass2')->getValue()->setValue('test-change')->getValue(); | ||
| echo "\n"; |
| The MIT License (MIT) | ||
| Copyright (c) João Moraes | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit bootstrap="vendor/autoload.php"> | ||
| <testsuites> | ||
| <testsuite name="testSuite"> | ||
| <directory>./tests/</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
| <filter> | ||
| <whitelist> | ||
| <directory suffix=".php">./src/</directory> | ||
| </whitelist> | ||
| <blacklist> | ||
| <directory suffix=".php">./vendor/</directory> | ||
| <exclude> | ||
| <directory suffix=".php">./vendor/</directory> | ||
| </exclude> | ||
| </blacklist> | ||
| </filter> | ||
| <logging> | ||
| <log type="coverage-html" target="tests/coverage" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70" /> | ||
| </logging> | ||
| </phpunit> |
| # FcPhp Dependency Injection | ||
| Package to manage dependencies of project. | ||
| [](https://travis-ci.org/00F100/fcphp-di) [](https://codecov.io/gh/00F100/fcphp-di) [](https://packagist.org/packages/00F100/fcphp-di) | ||
| ## How to install | ||
| Composer: | ||
| ```sh | ||
| $ composer require 00f100/fcphp-di | ||
| ``` | ||
| or add in composer.json | ||
| ```json | ||
| { | ||
| "require": { | ||
| "00f100/fcphp-di": "*" | ||
| } | ||
| } | ||
| ``` | ||
| ## How to use | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| $di = DiFacade::getInstance(); | ||
| /** | ||
| * Method to set new class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @return void | ||
| */ | ||
| $di->set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true); | ||
| /** | ||
| * Method to overwrite instance before make | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| $di->overwrite(string $id, string $namespace, array $args = [], array $setters = []) ; | ||
| /** | ||
| * Method to get instance of Container | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| $di->get(string $id, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| $di->setter(string $id, array $setters); | ||
| /** | ||
| * Method instance of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @return mixed | ||
| */ | ||
| $di->make(string $id, array $args = [], array $setters = []); | ||
| ``` | ||
| ## Examples | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| $di = DiFacade::getInstance(); | ||
| /* | ||
| namespace Namespace\To { | ||
| class Example { | ||
| public $foo; | ||
| private $anotherFoo; | ||
| public function __construct(string $foo) { | ||
| $this->foo = $foo; | ||
| } | ||
| public function setAnotherFoo($foo) { | ||
| $this->anotherFoo = $foo; | ||
| } | ||
| public functio getAnotherFoo() { | ||
| return $this->anotherFoo; | ||
| } | ||
| } | ||
| class ExampleBar { | ||
| public $example; | ||
| __construct(Example $example) { | ||
| $this->example = $example; | ||
| } | ||
| } | ||
| } | ||
| */ | ||
| $di->set('Example', 'Namespace\To\Example', ['foo' => 'bar'], ['setAnotherFoo', 'AnotherBar']); | ||
| $di->set('ExampleBar', 'Namespace\To\ExampleBar', ['example' => $di->get('Example')]); | ||
| // Print "bar" | ||
| echo $di->make('ExampleBar')->example->foo | ||
| // Print "AnotherBar" | ||
| echo $di->make('ExampleBar')->example->getAnotherFoo(); | ||
| ``` | ||
| ## Events | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| $di = DiFacade::getInstance(); | ||
| $di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, IInstance $instance) { | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, IInstance $instance, IContainer $container) { | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, IInstance $instance, IContainer $container, $class) { | ||
| } | ||
| ]); | ||
| ``` |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use ReflectionClass; | ||
| use ReflectionMethod; | ||
| class Container implements IContainer | ||
| { | ||
| private $instance; | ||
| private $args; | ||
| private $setters; | ||
| private $classInstance = false; | ||
| private $lock = false; | ||
| /** | ||
| * Method to construct instance of Container | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance of Container | ||
| * @param array $args Args to construct | ||
| * @param array $setters Setters methods | ||
| * @return void | ||
| */ | ||
| public function __construct(IInstance $instance, array $args = [], array $setters = []) | ||
| { | ||
| $this->instance = $instance; | ||
| $this->args = $args; | ||
| $this->setters = $setters; | ||
| } | ||
| /** | ||
| * Method to return instance of class inside Container | ||
| * | ||
| * @return mixed | ||
| */ | ||
| public function getClass() | ||
| { | ||
| if(!$this->classInstance) { | ||
| $args = array_merge($this->instance->getArgs(), $this->args); | ||
| foreach($args as $index => $value) { | ||
| if($value instanceof IContainer) { | ||
| $args[$index] = $value->getClass(); | ||
| } | ||
| } | ||
| $argsClass = []; | ||
| if(method_exists($this->instance->getNamespace(), '__construct')) { | ||
| $method = new ReflectionMethod($this->instance->getNamespace(), '__construct'); | ||
| $parameters = $method->getParameters(); | ||
| $params = []; | ||
| if(count($parameters) > 0) { | ||
| foreach($parameters as $param) { | ||
| $params[] = $param->getName(); | ||
| } | ||
| } | ||
| if(count($params) > 0) { | ||
| foreach($params as $param) { | ||
| if(isset($args[$param])) { | ||
| $argsClass[] = $args[$param]; | ||
| }else{ | ||
| $argsClass[] = null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $class = new ReflectionClass($this->instance->getNamespace()); | ||
| $instance = $class->newInstanceArgs($argsClass); | ||
| $setters = array_merge($this->instance->getSetters(), $this->setters); | ||
| if(count($setters) > 0) { | ||
| foreach($setters as $method => $value) { | ||
| if(method_exists($instance, $method)) { | ||
| if($value instanceof IContainer) { | ||
| call_user_func_array([$instance, $method], [$value->getClass()]); | ||
| }else{ | ||
| if(!is_array($value)) { | ||
| $value = [$value]; | ||
| } | ||
| call_user_func_array([$instance, $method], $value); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $this->register($instance); | ||
| $this->lock = true; | ||
| } | ||
| return $this->classInstance; | ||
| } | ||
| /** | ||
| * Method to register instance Container | ||
| * | ||
| * @param mixed Instance to inject | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function register($instance) :IContainer | ||
| { | ||
| $this->classInstance = $instance; | ||
| return $this; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| use FcPhp\Di\Traits\DiEvents; | ||
| use FcPhp\Di\Traits\DiCore; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class Di implements IDi | ||
| { | ||
| use DiEvents; | ||
| use DiCore; | ||
| /** | ||
| * @var FcPHP\Di\Interfaces\IDi Instance | ||
| */ | ||
| private static $instance; | ||
| /** | ||
| * @var array $instances List of instances | ||
| */ | ||
| private $instances = []; | ||
| /** | ||
| * @var array List of containers register | ||
| */ | ||
| private $register_containers = []; | ||
| /** | ||
| * @var bool Enable/Disable register container | ||
| */ | ||
| private $register = false; | ||
| /** | ||
| * @var FcPhp\Di\Interfaces\IContainerFactory Container Factory | ||
| */ | ||
| private $containerFactory; | ||
| /** | ||
| * @var FcPhp\Di\Interfaces\IInfanceFactory Instance Factory | ||
| */ | ||
| private $instanceFactory; | ||
| /** | ||
| * @var string Version Di | ||
| */ | ||
| private $version = '0.2.1'; | ||
| /** | ||
| * Return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IDiFactory $diFactory Instance of Di Factory | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (??!) Factory | ||
| * @return FcPHP\Di\Interfaces\IDi | ||
| */ | ||
| public static function getInstance(IDiFactory $diFactory, IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi | ||
| { | ||
| if(!self::$instance instanceof IDi) { | ||
| self::$instance = $diFactory->getInstance($containerFactory, $instanceFactory, $register); | ||
| } | ||
| return self::$instance; | ||
| } | ||
| /** | ||
| * Method to contruct instance of Di | ||
| * | ||
| * @param bool $register Define if register containers to log | ||
| */ | ||
| public function __construct(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, $register = false) | ||
| { | ||
| $this->register = $register; | ||
| $this->instanceFactory = $instanceFactory; | ||
| $this->containerFactory = $containerFactory; | ||
| } | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| return $this->_set($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| /** | ||
| * Method to configure new instance non singleton | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setNonSingleton(string $id, string $namespace, array $args = [], array $setters = []) :IDi | ||
| { | ||
| return $this->set($id, $namespace, $args, $setters, false); | ||
| } | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setter(string $id, array $setters) :IDi | ||
| { | ||
| return $this->_setter($id, $setters); | ||
| } | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function get(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| return $this->_get($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| return $this->_getNonSingleton($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to overwrite instance before make | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function overwrite(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| return $this->_overwrite($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| public function has(string $id) :bool | ||
| { | ||
| return $this->_has($id); | ||
| } | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| * @param array $setters Setters to class | ||
| * @return mixed | ||
| */ | ||
| public function make(string $id, array $args = [], array $setters = []) | ||
| { | ||
| return $this->_make($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| public function event($eventName, object $callback = null) :void | ||
| { | ||
| $this->_event($eventName, $callback); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPHP\Di\Exceptions | ||
| { | ||
| use Exception; | ||
| class ClassBusy extends Exception | ||
| { | ||
| } | ||
| } |
| <?php | ||
| namespace FcPHP\Di\Exceptions | ||
| { | ||
| use Exception; | ||
| class InstanceNotFound extends Exception | ||
| { | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Facades | ||
| { | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class DiFacade | ||
| { | ||
| /** | ||
| * @var FcPhp\Di\Facades\DiFacade | ||
| */ | ||
| private static $instance; | ||
| /** | ||
| * Method to create and return instance of Di Facade | ||
| * | ||
| * @param bool $register Register Containers | ||
| * @return FcPhp\Di\Facades\DiFacade | ||
| */ | ||
| public static function getInstance(bool $register = false) :IDi | ||
| { | ||
| if(!self::$instance instanceof IDi) { | ||
| self::$instance = new Di(new ContainerFactory(), new InstanceFactory(), $register); | ||
| } | ||
| return self::$instance; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Container; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class ContainerFactory implements IContainerFactory | ||
| { | ||
| /** | ||
| * Method to return instance of Container | ||
| * | ||
| * @param mixed $instance to use inside Container | ||
| * @param array $args Args to construct | ||
| * @param array @setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getInstance($instance, array $args, array $setters) :IContainer | ||
| { | ||
| return new Container($instance, $args, $setters); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| use FcPhp\Di\Di; | ||
| class DiFactory implements IDiFactory | ||
| { | ||
| /** | ||
| * Method to return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (!?!?!) Factory | ||
| * @param bool $register If register class inside log | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function getInstance(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi | ||
| { | ||
| return new Di($containerFactory, $instanceFactory, $register); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Instance; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| class InstanceFactory implements IInstanceFactory | ||
| { | ||
| /** | ||
| * Method to return new isntance of Instance (??!?@##?!) | ||
| * | ||
| * @param string $namespace Namespace of new class | ||
| * @param array $args Args to construct new class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If is singleton | ||
| */ | ||
| public function getInstance(string $namespace, array $args = [], array $setters = [], bool $singleton = true) | ||
| { | ||
| return new Instance($namespace, $args, $setters, $singleton); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| class Instance implements IInstance | ||
| { | ||
| /** | ||
| * @var string $namespace | ||
| */ | ||
| private $namespace; | ||
| /** | ||
| * @var array $args | ||
| */ | ||
| private $args = []; | ||
| /** | ||
| * @var bool $singleton | ||
| */ | ||
| private $singleton = true; | ||
| /** | ||
| * @var array $setters | ||
| */ | ||
| private $setters = []; | ||
| /** | ||
| * Method to construct new instance | ||
| * | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct new class | ||
| * @param bool $singlegon Define if this class is singleton (or not) | ||
| * @return void | ||
| */ | ||
| public function __construct(string $namespace, array $args, array $setters, bool $singleton) | ||
| { | ||
| $this->namespace = $namespace; | ||
| $this->args = $args; | ||
| $this->singleton = $singleton; | ||
| $this->setters = $setters; | ||
| } | ||
| /** | ||
| * Method to return namespace of class | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getNamespace() :string | ||
| { | ||
| return $this->namespace; | ||
| } | ||
| /** | ||
| * Method to return args to construct class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getArgs() :array | ||
| { | ||
| return $this->args; | ||
| } | ||
| /** | ||
| * Method to return if this class is singleton | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function getIsSingleton() :bool | ||
| { | ||
| return $this->singleton; | ||
| } | ||
| /** | ||
| * Method to return list of setters to class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getSetters() :array | ||
| { | ||
| return $this->setters; | ||
| } | ||
| /** | ||
| * Method to configure setters | ||
| * | ||
| * @return FcPhp\Di\Interfaces\IInstance | ||
| */ | ||
| public function setSetters(array $setters) :IInstance | ||
| { | ||
| $this->setters = $setters; | ||
| return $this; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| interface IContainer | ||
| { | ||
| /** | ||
| * Method to construct instance of Container | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance of Container | ||
| * @param array $args Args to construct | ||
| * @param array $setters Setters methods | ||
| * @return void | ||
| */ | ||
| public function __construct(IInstance $instance, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to return instance of class inside Container | ||
| * | ||
| * @return mixed | ||
| */ | ||
| public function getClass(); | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| interface IContainerFactory | ||
| { | ||
| /** | ||
| * Method to return instance of Container | ||
| * | ||
| * @param mixed $instance to use inside Container | ||
| * @param array $args Args to construct | ||
| * @param array @setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getInstance($instance, array $args, array $setters) :IContainer; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| interface IDi | ||
| { | ||
| /** | ||
| * Return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IDiFactory $diFactory Instance of Di Factory | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (??!) Factory | ||
| * @return FcPHP\Di\Interfaces\IDi | ||
| */ | ||
| public static function getInstance(IDiFactory $diFactory, IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi; | ||
| /** | ||
| * Method to contruct instance of Di | ||
| * | ||
| * @param bool $register Define if register containers to log | ||
| */ | ||
| public function __construct(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, $register = false); | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi; | ||
| /** | ||
| * Method to configure new instance non singleton | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setNonSingleton(string $id, string $namespace, array $args = [], array $setters = []) :IDi; | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setter(string $id, array $setters) :IDi; | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function get(string $id, array $args = [], array $setters = []) :IContainer; | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer; | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| public function has(string $id) :bool; | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| * @param array $setters Setters to class | ||
| * @return mixed | ||
| */ | ||
| public function make(string $id, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| public function event($eventName, object $callback = null) :void; | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| public function beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void; | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| public function afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance); | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeGet(string $id, array $args, array $setters) :void; | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| public function afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void; | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeMake(string $id, array $args, array $setters) :void; | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| public function afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| interface IDiFactory | ||
| { | ||
| /** | ||
| * Method to return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (!?!?!) Factory | ||
| * @param bool $register If register class inside log | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function getInstance(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| interface IInstance | ||
| { | ||
| /** | ||
| * Method to construct new instance | ||
| * | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct new class | ||
| * @param bool $singlegon Define if this class is singleton (or not) | ||
| * @return void | ||
| */ | ||
| public function __construct(string $namespace, array $args, array $setters, bool $singleton); | ||
| /** | ||
| * Method to return namespace of class | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getNamespace() :string; | ||
| /** | ||
| * Method to return args to construct class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getArgs() :array; | ||
| /** | ||
| * Method to return if this class is singleton | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function getIsSingleton() :bool; | ||
| /** | ||
| * Method to return list of setters to class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getSetters() :array; | ||
| /** | ||
| * Method to configure setters | ||
| * | ||
| * @return FcPhp\Di\Interfaces\IInstance | ||
| */ | ||
| public function setSetters(array $setters) :IInstance; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| interface IInstanceFactory | ||
| { | ||
| /** | ||
| * Method to return new isntance of Instance (??!?@##?!) | ||
| * | ||
| * @param string $namespace Namespace of new class | ||
| * @param array $args Args to construct new class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If is singleton | ||
| */ | ||
| public function getInstance(string $namespace, array $args = [], array $setters = [], bool $singleton = true); | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Traits | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Exceptions\InstanceNotFound; | ||
| use FcPhp\Di\Exceptions\ClassBusy; | ||
| trait DiCore | ||
| { | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| */ | ||
| private function _make(string $id, array $args = [], array $setters = []) | ||
| { | ||
| $this->beforeMake($id, $args, $setters); | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $instance = $this->instances[$id]; | ||
| if(!$instance->getIsSingleton()) { | ||
| $container = $this->_getNonSingleton($id, $args, $setters); | ||
| }else{ | ||
| if(!isset($this->containers[$id])) { | ||
| $this->containers[$id] = $this->_get($id, $args, $setters); | ||
| } | ||
| $container = $this->containers[$id]; | ||
| } | ||
| $class = $container->getClass(); | ||
| $this->afterMake($id, $args, $setters, $instance, $container, $class); | ||
| return $class; | ||
| } | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function _get(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| $this->beforeGet($id, $args, $setters); | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $instance = $this->instances[$id]; | ||
| if(!$instance->getIsSingleton()) { | ||
| $container = $this->containerFactory->getInstance($instance, $args, $setters); | ||
| $this->registerContainer($container); | ||
| $this->afterGet($id, $args, $setters, $instance, $container); | ||
| return $container; | ||
| } | ||
| if(!isset($this->containers[$id])) { | ||
| $this->containers[$id] = $this->containerFactory->getInstance($instance, $args, $setters); | ||
| $this->registerContainer($this->containers[$id]); | ||
| }else{ | ||
| if(count($args) > 0 || count($setters) > 0) { | ||
| throw new ClassBusy("This class has already been instantiated, can not be its modified constructor", 500); | ||
| } | ||
| } | ||
| $this->afterGet($id, $args, $setters, $instance, $this->containers[$id]); | ||
| return $this->containers[$id]; | ||
| } | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function _getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $container = $this->containerFactory->getInstance($this->instances[$id], $args, $setters); | ||
| $this->registerContainer($container); | ||
| return $container; | ||
| } | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| private function _set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| $this->beforeSet($id, $namespace, $args, $setters, $singleton); | ||
| if(!isset($this->instances[$id])) { | ||
| $this->instances[$id] = $this->instanceFactory->getInstance($namespace, $args, $setters, $singleton); | ||
| } | ||
| $this->afterSet($id, $namespace, $args, $setters, $singleton, $this->instances[$id]); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to overwrite instance before make | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| private function _overwrite(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| $this->beforeOverwrite($id, $namespace, $args, $setters, $singleton); | ||
| $this->instances[$id] = $this->instanceFactory->getInstance($namespace, $args, $setters, $singleton); | ||
| $this->afterOverwrite($id, $namespace, $args, $setters, $singleton, $this->instances[$id]); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to configure setters to instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Define setters to instance | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| private function _setter(string $id, array $setters) :IDi | ||
| { | ||
| $instance = $this->instances[$id]; | ||
| $instanceSetters = $instance->getSetters(); | ||
| $instanceSetters = array_merge($instanceSetters, $setters); | ||
| $instance->setSetters($setters); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| private function _has(string $id) :bool | ||
| { | ||
| return isset($this->instances[$id]); | ||
| } | ||
| /** | ||
| * Method to register container for log | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainer $container | ||
| * @return void | ||
| */ | ||
| private function registerContainer(IContainer $container) :void | ||
| { | ||
| if($this->register) { | ||
| $this->register_containers[] = $container; | ||
| } | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Traits | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| trait DiEvents | ||
| { | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeSet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterSet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeGet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterGet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeMake; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterMake; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeOverwrite; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterOverwrite; | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| public function beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void | ||
| { | ||
| $this->_beforeSet($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| public function afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) | ||
| { | ||
| $this->_afterSet($id, $namespace, $args, $setters, $singleton, $instance); | ||
| } | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeGet(string $id, array $args, array $setters) :void | ||
| { | ||
| $this->_beforeGet($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| public function afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void | ||
| { | ||
| $this->_afterGet($id, $args, $setters, $instance, $container); | ||
| } | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeMake(string $id, array $args, array $setters) :void | ||
| { | ||
| $this->_beforeMake($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| public function afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void | ||
| { | ||
| $this->_afterMake($id, $args, $setters, $instance, $container, $class); | ||
| } | ||
| /** | ||
| * Method to event before execute overwrite() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| public function beforeOverwrite(string $id, string $namespace, array $args, array $setters, bool $singleton) :void | ||
| { | ||
| $event = $this->beforeOverwrite; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute overwrite() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| public function afterOverwrite(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) :void | ||
| { | ||
| $event = $this->afterOverwrite; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton, $instance); | ||
| } | ||
| } | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| private function _event($eventName, object $callback = null) :void | ||
| { | ||
| if(is_array($eventName)) { | ||
| foreach($eventName as $eName => $clousure) { | ||
| $this->{$eName} = $clousure; | ||
| } | ||
| }else{ | ||
| $this->{$eventName} = $callback; | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| private function _beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void | ||
| { | ||
| $event = $this->beforeSet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| private function _afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) | ||
| { | ||
| $event = $this->afterSet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton, $instance); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| private function _beforeGet(string $id, array $args, array $setters) :void | ||
| { | ||
| $event = $this->beforeGet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| private function _afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void | ||
| { | ||
| $event = $this->afterGet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters, $instance, $container); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| private function _beforeMake(string $id, array $args, array $setters) :void | ||
| { | ||
| $event = $this->beforeMake; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| private function _afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void | ||
| { | ||
| $event = $this->afterMake; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters, $instance, $container, $class); | ||
| } | ||
| } | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Factories\DiFactory; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use FcPhp\Di\Interfaces\Icontainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Facades\DiFacade; | ||
| require_once(__DIR__ . '/../Unit/Mock.php'); | ||
| class DiIntegrationTest extends Mock | ||
| { | ||
| public function setUp() | ||
| { | ||
| $this->di = DiFacade::getInstance(true); | ||
| } | ||
| public function testCreate() | ||
| { | ||
| $this->assertTrue(Di::getInstance(new DiFactory(), new ContainerFactory(), new InstanceFactory(), false) instanceof IDi); | ||
| } | ||
| public function testIntance() | ||
| { | ||
| $this->assertTrue($this->di instanceof IDi); | ||
| } | ||
| public function testSetGet() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->get('TestClass') instanceof IContainer); | ||
| } | ||
| public function testMake() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->make('TestClass') instanceof \MockCallback); | ||
| } | ||
| public function testGetNonSingleton() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->getNonSingleton('TestClass')->getClass() instanceof \MockCallback); | ||
| } | ||
| public function testEvent() | ||
| { | ||
| $this->di->event('beforeSet', function() { | ||
| $this->assertTrue(true); | ||
| }); | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| } | ||
| public function testSetNonSinglet() | ||
| { | ||
| $this->assertTrue($this->di->setNonSingleton('TestClass', '\MockCallback') instanceof IDi); | ||
| } | ||
| public function testInjectDependency() | ||
| { | ||
| $this->di->set('TestClass1', '\MockCallbackParams', ['value' => 'content'], ['setTest' => 'test'], false); | ||
| $this->di->set('TestClass2', '\MockCallbackParams', ['value' => $this->di->get('TestClass1')], ['setTest' => $this->di->get('TestClass1')]); | ||
| $this->assertTrue($this->di->make('TestClass2') instanceof \MockCallbackParams); | ||
| $this->assertTrue($this->di->make('TestClass2')->args instanceof \MockCallbackParams); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetInstanceNotFound() | ||
| { | ||
| $this->di->get('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetNonSingletonInstanceNotFound() | ||
| { | ||
| $this->di->getNonSingleton('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testMakeInstanceNotFound() | ||
| { | ||
| $this->di->make('test'); | ||
| } | ||
| public function testGetMakeNonSingleton() | ||
| { | ||
| $this->di->setNonSingleton('ClassLocal', '\MockCallback'); | ||
| $this->assertTrue($this->di->make('ClassLocal') instanceof \MockCallback); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\ClassBusy | ||
| */ | ||
| public function testGetChangeValuesAfterInstance() | ||
| { | ||
| $this->di->set('ClassLocalChange', '\MockCallbackParams', ['value' => 'content']); | ||
| $instance = $this->di->make('ClassLocalChange'); | ||
| $this->di->get('ClassLocalChange', [], ['setTest' => 'value']); | ||
| } | ||
| public function testSettersMethod() | ||
| { | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->setter('MockCallback', ['setTest' => 'value']) instanceof IDI); | ||
| } | ||
| public function testHas() | ||
| { | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->has('MockCallback')); | ||
| } | ||
| public function testOverwriteArgs() | ||
| { | ||
| $this->di->set('MockCallbackParams', '\MockCallbackParams', ['value' => 12345]); | ||
| $this->di->overwrite('MockCallbackParams', '\MockCallbackParams', ['value' => 'overwrite']); | ||
| $this->assertEquals('overwrite', $this->di->make('MockCallbackParams')->getArgs()); | ||
| } | ||
| public function testContainerNullParam() | ||
| { | ||
| $this->di->set('MockCallbackParams2', '\MockCallbackParams', ['value' => null]); | ||
| $this->assertNull($this->di->make('MockCallbackParams2')->getArgs()); | ||
| } | ||
| public function testEvents() | ||
| { | ||
| $this->di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| $this->assertTrue($class instanceof \MockCallback); | ||
| }, | ||
| 'beforeOverwrite' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterOverwrite' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| } | ||
| ]); | ||
| $this->di->event('afterGet', function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }); | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->di->overwrite('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->get('MockCallback') instanceof IContainer); | ||
| $this->assertTrue($this->di->make('MockCallback') instanceof \MockCallback); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Container; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| require_once('Mock.php'); | ||
| class ContainerTest extends Mock | ||
| { | ||
| private $instance; | ||
| private $container; | ||
| public function setUp() | ||
| { | ||
| $this->instance = $this->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $this->instance | ||
| ->expects($this->any()) | ||
| ->method('getArgs') | ||
| ->will($this->returnValue([])); | ||
| $this->instance | ||
| ->expects($this->any()) | ||
| ->method('getSetters') | ||
| ->will($this->returnValue([])); | ||
| $this->instance | ||
| ->expects($this->any()) | ||
| ->method('getNamespace') | ||
| ->will($this->returnValue('\MockCallbackParams')); | ||
| $container = new Container($this->instance, ['value' => 'param'], ['setTest' => 'value']); | ||
| $this->container = new Container($this->instance, ['value' => $container], ['setTest' => $container]); | ||
| } | ||
| public function testInstance() | ||
| { | ||
| $this->assertTrue($this->container instanceof IContainer); | ||
| } | ||
| public function testGetClass() | ||
| { | ||
| $this->assertTrue($this->container->getClass() instanceof \MockCallbackParams); | ||
| } | ||
| public function testArgsNull() | ||
| { | ||
| $container = new Container($this->instance); | ||
| $class = $container->getClass(); | ||
| $this->assertNull($class->GetArgs()); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use PHPUnit\Framework\TestCase; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| require_once('Mock.php'); | ||
| class DiTest extends Mock | ||
| { | ||
| public $di; | ||
| public function setUp() | ||
| { | ||
| $this->di = new Di($this->getContainerMock(), $this->getInstanceMock(), true); | ||
| } | ||
| public function testEvents() | ||
| { | ||
| $this->di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| $this->assertTrue($class instanceof MockCallback); | ||
| }, | ||
| 'beforeOverwrite' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterOverwrite' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| } | ||
| ]); | ||
| $this->di->event('afterGet', function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }); | ||
| $this->di->set('MockCallback', 'MockCallback'); | ||
| $this->di->overwrite('MockCallback', 'MockCallback'); | ||
| $this->assertTrue($this->di->get('MockCallback') instanceof IContainer); | ||
| $this->assertTrue($this->di->make('MockCallback') instanceof MockCallback); | ||
| } | ||
| public function testInstanceDi() | ||
| { | ||
| $this->assertTrue($this->di instanceof IDi); | ||
| } | ||
| public function testSetInstance() | ||
| { | ||
| $this->assertTrue($this->di->set('ClassTest', 'MockCallback') instanceof IDi); | ||
| } | ||
| public function testSetNonSingletonInstance() | ||
| { | ||
| $this->assertTrue($this->di->setNonSingleton('ClassTest', 'MockCallback') instanceof IDi); | ||
| } | ||
| public function testGetInstance() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->get('ClassTeste') instanceof IContainer); | ||
| } | ||
| public function testGetNonSingletonInstance() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->getNonSingleton('ClassTeste') instanceof IContainer); | ||
| } | ||
| public function testMake() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->make('ClassTeste') instanceof MockCallback); | ||
| } | ||
| public function testGetInstanceOfDi() | ||
| { | ||
| $this->assertTrue(Di::getInstance($this->createMock('FcPhp\Di\Interfaces\IDiFactory'), $this->createMock('FcPhp\Di\Interfaces\IContainerFactory'), $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory')) instanceof IDi); | ||
| } | ||
| public function testMakeGetNonSingleton() | ||
| { | ||
| $di = new Di($this->getContainerMock(), $this->getInstanceNonSingletonMock()); | ||
| $di->set('MockCallback', 'MockCallback', [], [], false); | ||
| $this->assertTrue($di->make('MockCallback') instanceof MockCallback); | ||
| $this->assertTrue($di->get('MockCallback') instanceof IContainer); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetNonSingleInstanceError() | ||
| { | ||
| $this->di->getNonSingleton('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetInstanceError() | ||
| { | ||
| $this->di->get('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testMakeInstanceError() | ||
| { | ||
| $this->di->make('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\ClassBusy | ||
| */ | ||
| public function testMakeInstanceErrorClassBosy() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $class = $this->di->make('ClassTeste'); | ||
| $this->assertTrue($class instanceof MockCallback); | ||
| $class->param = 'value1'; | ||
| $this->di->get('ClassTeste', [], ['setFoo' => 'bar'])->getClass(); | ||
| } | ||
| public function testSetSetters() | ||
| { | ||
| $this->di->set('ClassMock', 'MockCallbackParams'); | ||
| $this->assertTrue($this->di->setter('ClassMock', ['setTest' => 'value']) instanceof IDi); | ||
| } | ||
| public function testHas() | ||
| { | ||
| $this->di->set('ClassMock', 'MockCallbackParams'); | ||
| $this->assertTrue($this->di->has('ClassMock')); | ||
| } | ||
| public function testOverwrite() | ||
| { | ||
| $this->assertInstanceOf(IDi::class, $this->di->overwrite('ClassMock', 'MockCallbackParams')); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Instance; | ||
| // use FcPhp\Di\Factories\ContainerFactory; | ||
| // use FcPhp\Di\Factories\InstanceFactory; | ||
| // use PHPUnit\Framework\TestCase; | ||
| // use FcPhp\Di\Interfaces\IDi; | ||
| // use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| require_once('Mock.php'); | ||
| class InstanceTest extends Mock | ||
| { | ||
| public $namespace; | ||
| public $args = []; | ||
| public $setters; | ||
| public $instance; | ||
| public function setUp() | ||
| { | ||
| $this->namespace = '\MockCallback'; | ||
| $this->args = ['foo' => 'bar']; | ||
| $this->setters = ['setFoo' => 'val']; | ||
| $this->instance = new Instance($this->namespace, $this->args, $this->setters, true); | ||
| } | ||
| public function testInstance() | ||
| { | ||
| $this->assertTrue($this->instance instanceof IInstance); | ||
| } | ||
| public function testGetNamespace() | ||
| { | ||
| $this->assertEquals($this->instance->getNamespace(), $this->namespace); | ||
| } | ||
| public function testGetArgs() | ||
| { | ||
| $this->assertEquals($this->instance->getArgs(), $this->args); | ||
| } | ||
| public function testGetSetters() | ||
| { | ||
| $this->assertEquals($this->instance->getSetters(), $this->setters); | ||
| } | ||
| public function testGetIsSingleton() | ||
| { | ||
| $this->assertEquals($this->instance->getIsSingleton(), true); | ||
| } | ||
| public function testSetSetters() | ||
| { | ||
| $setters = ['method' => 'value']; | ||
| $this->instance->setSetters($setters); | ||
| $this->assertEquals($this->instance->getSetters(), $setters); | ||
| } | ||
| } |
| <?php | ||
| use PHPUnit\Framework\TestCase; | ||
| Class Mock extends TestCase | ||
| { | ||
| public function getContainerMock() | ||
| { | ||
| $phpunit = $this; | ||
| $containerFactory = $this->createMock('FcPhp\Di\Interfaces\IContainerFactory'); | ||
| $containerFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit){ | ||
| $container = $phpunit->createMock('FcPhp\Di\Interfaces\IContainer'); | ||
| $container | ||
| ->expects($this->any()) | ||
| ->method('getClass') | ||
| ->will($this->returnCallback(function() { | ||
| return new MockCallback(); | ||
| })); | ||
| return $container; | ||
| })); | ||
| return $containerFactory; | ||
| } | ||
| public function getInstanceMock() | ||
| { | ||
| $phpunit = $this; | ||
| $instanceFactory = $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory'); | ||
| $instanceFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit) { | ||
| $instance = $phpunit->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getIsSingleton') | ||
| ->will($this->returnValue(true)); | ||
| return $instance; | ||
| })); | ||
| return $instanceFactory; | ||
| } | ||
| public function getInstanceNonSingletonMock() | ||
| { | ||
| $phpunit = $this; | ||
| $instanceFactory = $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory'); | ||
| $instanceFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit) { | ||
| $instance = $phpunit->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getIsSingleton') | ||
| ->will($this->returnValue(false)); | ||
| return $instance; | ||
| })); | ||
| return $instanceFactory; | ||
| } | ||
| } | ||
| class MockCallback | ||
| { | ||
| public $args; | ||
| public function __construct() | ||
| { | ||
| $this->args = func_get_args(); | ||
| } | ||
| } | ||
| class MockCallbackParams | ||
| { | ||
| public $args; | ||
| public $test; | ||
| public function __construct($value) | ||
| { | ||
| $this->args = $value; | ||
| } | ||
| public function setTest($value) | ||
| { | ||
| $this->test = $value; | ||
| } | ||
| public function getArgs() | ||
| { | ||
| return $this->args; | ||
| } | ||
| } |
| root = true | ||
| [*] | ||
| end_of_line = lf | ||
| [*.php] | ||
| insert_final_newline = true | ||
| [*.{php,xml,json,md}] | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 4 | ||
| [*.yml] | ||
| indent_style = space | ||
| indent_size = 2 |
| vendor | ||
| tests/coverage |
| language: php | ||
| php: | ||
| - 7.2 | ||
| before_script: | ||
| - travis_retry composer self-update | ||
| - travis_retry composer install --no-interaction --prefer-source --dev | ||
| script: | ||
| - vendor/bin/phpunit --coverage-clover=coverage.xml | ||
| after_success: | ||
| - bash <(curl -s https://codecov.io/bash) |
| { | ||
| "name": "00f100/fcphp-di", | ||
| "type": "package", | ||
| "version": "0.3.1", | ||
| "description": "Dependency Injection for FcPHP", | ||
| "keywords": ["dependency", "injection", "di", "php", "fcphp"], | ||
| "homepage": "https://github.com/00f100/fcphp-di", | ||
| "authors": [ | ||
| { | ||
| "name": "João Moraes", | ||
| "email": "joaomoraesbr@gmail.com", | ||
| "homepage": "https://github.com/00f100" | ||
| } | ||
| ], | ||
| "require": { | ||
| "php": ">=7.2" | ||
| }, | ||
| "require-dev": { | ||
| "00f100/phpdbug": "*", | ||
| "phpunit/phpunit": "6.*" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "FcPhp\\Di\\": "src/", | ||
| "FcPhp\\Di\\Test\\": "tests/" | ||
| } | ||
| } | ||
| } |
| { | ||
| "_readme": [ | ||
| "This file locks the dependencies of your project to a known state", | ||
| "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | ||
| "This file is @generated automatically" | ||
| ], | ||
| "content-hash": "fd9e1ef21cd165902746b43681fc1066", | ||
| "packages": [], | ||
| "packages-dev": [ | ||
| { | ||
| "name": "00f100/phpdbug", | ||
| "version": "0.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/00F100/phpdbug.git", | ||
| "reference": "ffe174fb589e1d7d7f7043d6150b4759adce2b6d" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/00F100/phpdbug/zipball/ffe174fb589e1d7d7f7043d6150b4759adce2b6d", | ||
| "reference": "ffe174fb589e1d7d7f7043d6150b4759adce2b6d", | ||
| "shasum": "" | ||
| }, | ||
| "type": "package", | ||
| "autoload": { | ||
| "files": [ | ||
| "src/functions.php" | ||
| ], | ||
| "psr-4": { | ||
| "PHPdbug\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "authors": [ | ||
| { | ||
| "name": "João Moraes", | ||
| "email": "joaomoraesbr@gmail.com", | ||
| "homepage": "https://github.com/00f100" | ||
| } | ||
| ], | ||
| "description": "Package to debug everything in PHP", | ||
| "homepage": "https://github.com/00f100/phpdbug", | ||
| "keywords": [ | ||
| "denbug", | ||
| "php" | ||
| ], | ||
| "time": "2017-07-27T14:09:24+00:00" | ||
| }, | ||
| { | ||
| "name": "doctrine/instantiator", | ||
| "version": "1.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/doctrine/instantiator.git", | ||
| "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", | ||
| "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.1" | ||
| }, | ||
| "require-dev": { | ||
| "athletic/athletic": "~0.1.8", | ||
| "ext-pdo": "*", | ||
| "ext-phar": "*", | ||
| "phpunit/phpunit": "^6.2.3", | ||
| "squizlabs/php_codesniffer": "^3.0.2" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.2.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Marco Pivetta", | ||
| "email": "ocramius@gmail.com", | ||
| "homepage": "http://ocramius.github.com/" | ||
| } | ||
| ], | ||
| "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", | ||
| "homepage": "https://github.com/doctrine/instantiator", | ||
| "keywords": [ | ||
| "constructor", | ||
| "instantiate" | ||
| ], | ||
| "time": "2017-07-22T11:58:36+00:00" | ||
| }, | ||
| { | ||
| "name": "myclabs/deep-copy", | ||
| "version": "1.8.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/myclabs/DeepCopy.git", | ||
| "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/478465659fd987669df0bd8a9bf22a8710e5f1b6", | ||
| "reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.1" | ||
| }, | ||
| "replace": { | ||
| "myclabs/deep-copy": "self.version" | ||
| }, | ||
| "require-dev": { | ||
| "doctrine/collections": "^1.0", | ||
| "doctrine/common": "^2.6", | ||
| "phpunit/phpunit": "^7.1" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "psr-4": { | ||
| "DeepCopy\\": "src/DeepCopy/" | ||
| }, | ||
| "files": [ | ||
| "src/DeepCopy/deep_copy.php" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "description": "Create deep copies (clones) of your objects", | ||
| "keywords": [ | ||
| "clone", | ||
| "copy", | ||
| "duplicate", | ||
| "object", | ||
| "object graph" | ||
| ], | ||
| "time": "2018-05-29T17:25:09+00:00" | ||
| }, | ||
| { | ||
| "name": "phar-io/manifest", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phar-io/manifest.git", | ||
| "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", | ||
| "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-phar": "*", | ||
| "phar-io/version": "^1.0.1", | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Heuer", | ||
| "email": "sebastian@phpeople.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", | ||
| "time": "2017-03-05T18:14:27+00:00" | ||
| }, | ||
| { | ||
| "name": "phar-io/version", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phar-io/version.git", | ||
| "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", | ||
| "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Heuer", | ||
| "email": "sebastian@phpeople.de", | ||
| "role": "Developer" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "Library for handling version information and constraints", | ||
| "time": "2017-03-05T17:38:23+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/reflection-common", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/ReflectionCommon.git", | ||
| "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", | ||
| "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.5" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.6" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jaap van Otterdijk", | ||
| "email": "opensource@ijaap.nl" | ||
| } | ||
| ], | ||
| "description": "Common reflection classes used by phpdocumentor to reflect the code structure", | ||
| "homepage": "http://www.phpdoc.org", | ||
| "keywords": [ | ||
| "FQSEN", | ||
| "phpDocumentor", | ||
| "phpdoc", | ||
| "reflection", | ||
| "static analysis" | ||
| ], | ||
| "time": "2017-09-11T18:02:19+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/reflection-docblock", | ||
| "version": "4.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", | ||
| "reference": "94fd0001232e47129dd3504189fa1c7225010d08" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", | ||
| "reference": "94fd0001232e47129dd3504189fa1c7225010d08", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "phpdocumentor/reflection-common": "^1.0.0", | ||
| "phpdocumentor/type-resolver": "^0.4.0", | ||
| "webmozart/assert": "^1.0" | ||
| }, | ||
| "require-dev": { | ||
| "doctrine/instantiator": "~1.0.5", | ||
| "mockery/mockery": "^1.0", | ||
| "phpunit/phpunit": "^6.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "4.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src/" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Mike van Riel", | ||
| "email": "me@mikevanriel.com" | ||
| } | ||
| ], | ||
| "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", | ||
| "time": "2017-11-30T07:14:17+00:00" | ||
| }, | ||
| { | ||
| "name": "phpdocumentor/type-resolver", | ||
| "version": "0.4.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpDocumentor/TypeResolver.git", | ||
| "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", | ||
| "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.5 || ^7.0", | ||
| "phpdocumentor/reflection-common": "^1.0" | ||
| }, | ||
| "require-dev": { | ||
| "mockery/mockery": "^0.9.4", | ||
| "phpunit/phpunit": "^5.2||^4.8.24" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "phpDocumentor\\Reflection\\": [ | ||
| "src/" | ||
| ] | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Mike van Riel", | ||
| "email": "me@mikevanriel.com" | ||
| } | ||
| ], | ||
| "time": "2017-07-14T14:27:02+00:00" | ||
| }, | ||
| { | ||
| "name": "phpspec/prophecy", | ||
| "version": "1.7.6", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/phpspec/prophecy.git", | ||
| "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", | ||
| "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "doctrine/instantiator": "^1.0.2", | ||
| "php": "^5.3|^7.0", | ||
| "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", | ||
| "sebastian/comparator": "^1.1|^2.0|^3.0", | ||
| "sebastian/recursion-context": "^1.0|^2.0|^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpspec/phpspec": "^2.5|^3.2", | ||
| "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.7.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-0": { | ||
| "Prophecy\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Konstantin Kudryashov", | ||
| "email": "ever.zet@gmail.com", | ||
| "homepage": "http://everzet.com" | ||
| }, | ||
| { | ||
| "name": "Marcello Duarte", | ||
| "email": "marcello.duarte@gmail.com" | ||
| } | ||
| ], | ||
| "description": "Highly opinionated mocking framework for PHP 5.3+", | ||
| "homepage": "https://github.com/phpspec/prophecy", | ||
| "keywords": [ | ||
| "Double", | ||
| "Dummy", | ||
| "fake", | ||
| "mock", | ||
| "spy", | ||
| "stub" | ||
| ], | ||
| "time": "2018-04-18T13:57:24+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-code-coverage", | ||
| "version": "5.3.2", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-code-coverage.git", | ||
| "reference": "c89677919c5dd6d3b3852f230a663118762218ac" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", | ||
| "reference": "c89677919c5dd6d3b3852f230a663118762218ac", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-xmlwriter": "*", | ||
| "php": "^7.0", | ||
| "phpunit/php-file-iterator": "^1.4.2", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "phpunit/php-token-stream": "^2.0.1", | ||
| "sebastian/code-unit-reverse-lookup": "^1.0.1", | ||
| "sebastian/environment": "^3.0", | ||
| "sebastian/version": "^2.0.1", | ||
| "theseer/tokenizer": "^1.1" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "suggest": { | ||
| "ext-xdebug": "^2.5.5" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "5.3.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-code-coverage", | ||
| "keywords": [ | ||
| "coverage", | ||
| "testing", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-04-06T15:36:58+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-file-iterator", | ||
| "version": "1.4.5", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-file-iterator.git", | ||
| "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", | ||
| "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.3.3" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.4.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sb@sebastian-bergmann.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "FilterIterator implementation that filters files based on a list of suffixes.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", | ||
| "keywords": [ | ||
| "filesystem", | ||
| "iterator" | ||
| ], | ||
| "time": "2017-11-27T13:52:08+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-text-template", | ||
| "version": "1.2.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-text-template.git", | ||
| "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", | ||
| "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.3.3" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Simple template engine.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-text-template/", | ||
| "keywords": [ | ||
| "template" | ||
| ], | ||
| "time": "2015-06-21T13:50:34+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-timer", | ||
| "version": "1.0.9", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-timer.git", | ||
| "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", | ||
| "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.3.3 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sb@sebastian-bergmann.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Utility class for timing", | ||
| "homepage": "https://github.com/sebastianbergmann/php-timer/", | ||
| "keywords": [ | ||
| "timer" | ||
| ], | ||
| "time": "2017-02-26T11:10:40+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/php-token-stream", | ||
| "version": "2.0.2", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/php-token-stream.git", | ||
| "reference": "791198a2c6254db10131eecfe8c06670700904db" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", | ||
| "reference": "791198a2c6254db10131eecfe8c06670700904db", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-tokenizer": "*", | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.2.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Wrapper around PHP's tokenizer extension.", | ||
| "homepage": "https://github.com/sebastianbergmann/php-token-stream/", | ||
| "keywords": [ | ||
| "tokenizer" | ||
| ], | ||
| "time": "2017-11-27T05:48:46+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/phpunit", | ||
| "version": "6.5.8", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/phpunit.git", | ||
| "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b", | ||
| "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-json": "*", | ||
| "ext-libxml": "*", | ||
| "ext-mbstring": "*", | ||
| "ext-xml": "*", | ||
| "myclabs/deep-copy": "^1.6.1", | ||
| "phar-io/manifest": "^1.0.1", | ||
| "phar-io/version": "^1.0", | ||
| "php": "^7.0", | ||
| "phpspec/prophecy": "^1.7", | ||
| "phpunit/php-code-coverage": "^5.3", | ||
| "phpunit/php-file-iterator": "^1.4.3", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "phpunit/php-timer": "^1.0.9", | ||
| "phpunit/phpunit-mock-objects": "^5.0.5", | ||
| "sebastian/comparator": "^2.1", | ||
| "sebastian/diff": "^2.0", | ||
| "sebastian/environment": "^3.1", | ||
| "sebastian/exporter": "^3.1", | ||
| "sebastian/global-state": "^2.0", | ||
| "sebastian/object-enumerator": "^3.0.3", | ||
| "sebastian/resource-operations": "^1.0", | ||
| "sebastian/version": "^2.0.1" | ||
| }, | ||
| "conflict": { | ||
| "phpdocumentor/reflection-docblock": "3.0.2", | ||
| "phpunit/dbunit": "<3.0" | ||
| }, | ||
| "require-dev": { | ||
| "ext-pdo": "*" | ||
| }, | ||
| "suggest": { | ||
| "ext-xdebug": "*", | ||
| "phpunit/php-invoker": "^1.1" | ||
| }, | ||
| "bin": [ | ||
| "phpunit" | ||
| ], | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "6.5.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "The PHP Unit Testing framework.", | ||
| "homepage": "https://phpunit.de/", | ||
| "keywords": [ | ||
| "phpunit", | ||
| "testing", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-04-10T11:38:34+00:00" | ||
| }, | ||
| { | ||
| "name": "phpunit/phpunit-mock-objects", | ||
| "version": "5.0.7", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", | ||
| "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", | ||
| "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "doctrine/instantiator": "^1.0.5", | ||
| "php": "^7.0", | ||
| "phpunit/php-text-template": "^1.2.1", | ||
| "sebastian/exporter": "^3.1" | ||
| }, | ||
| "conflict": { | ||
| "phpunit/phpunit": "<6.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.5" | ||
| }, | ||
| "suggest": { | ||
| "ext-soap": "*" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "5.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Mock Object library for PHPUnit", | ||
| "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", | ||
| "keywords": [ | ||
| "mock", | ||
| "xunit" | ||
| ], | ||
| "time": "2018-05-29T13:50:43+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/code-unit-reverse-lookup", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", | ||
| "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", | ||
| "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.6 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^5.7 || ^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Looks up which function or method a line of code belongs to", | ||
| "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", | ||
| "time": "2017-03-04T06:30:41+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/comparator", | ||
| "version": "2.1.3", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/comparator.git", | ||
| "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", | ||
| "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/diff": "^2.0 || ^3.0", | ||
| "sebastian/exporter": "^3.1" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.4" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Volker Dusch", | ||
| "email": "github@wallbash.com" | ||
| }, | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@2bepublished.at" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides the functionality to compare PHP values for equality", | ||
| "homepage": "https://github.com/sebastianbergmann/comparator", | ||
| "keywords": [ | ||
| "comparator", | ||
| "compare", | ||
| "equality" | ||
| ], | ||
| "time": "2018-02-01T13:46:46+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/diff", | ||
| "version": "2.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/diff.git", | ||
| "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", | ||
| "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.2" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Kore Nordmann", | ||
| "email": "mail@kore-nordmann.de" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Diff implementation", | ||
| "homepage": "https://github.com/sebastianbergmann/diff", | ||
| "keywords": [ | ||
| "diff" | ||
| ], | ||
| "time": "2017-08-03T08:09:46+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/environment", | ||
| "version": "3.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/environment.git", | ||
| "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", | ||
| "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.1" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides functionality to handle HHVM/PHP environments", | ||
| "homepage": "http://www.github.com/sebastianbergmann/environment", | ||
| "keywords": [ | ||
| "Xdebug", | ||
| "environment", | ||
| "hhvm" | ||
| ], | ||
| "time": "2017-07-01T08:51:00+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/exporter", | ||
| "version": "3.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/exporter.git", | ||
| "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", | ||
| "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/recursion-context": "^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "ext-mbstring": "*", | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.1.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Volker Dusch", | ||
| "email": "github@wallbash.com" | ||
| }, | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@2bepublished.at" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| }, | ||
| { | ||
| "name": "Adam Harvey", | ||
| "email": "aharvey@php.net" | ||
| } | ||
| ], | ||
| "description": "Provides the functionality to export PHP variables for visualization", | ||
| "homepage": "http://www.github.com/sebastianbergmann/exporter", | ||
| "keywords": [ | ||
| "export", | ||
| "exporter" | ||
| ], | ||
| "time": "2017-04-03T13:19:02+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/global-state", | ||
| "version": "2.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/global-state.git", | ||
| "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", | ||
| "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "suggest": { | ||
| "ext-uopz": "*" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Snapshotting of global state", | ||
| "homepage": "http://www.github.com/sebastianbergmann/global-state", | ||
| "keywords": [ | ||
| "global state" | ||
| ], | ||
| "time": "2017-04-27T15:39:26+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/object-enumerator", | ||
| "version": "3.0.3", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/object-enumerator.git", | ||
| "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", | ||
| "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0", | ||
| "sebastian/object-reflector": "^1.1.1", | ||
| "sebastian/recursion-context": "^3.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Traverses array structures and object graphs to enumerate all referenced objects", | ||
| "homepage": "https://github.com/sebastianbergmann/object-enumerator/", | ||
| "time": "2017-08-03T12:35:26+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/object-reflector", | ||
| "version": "1.1.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/object-reflector.git", | ||
| "reference": "773f97c67f28de00d397be301821b06708fca0be" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", | ||
| "reference": "773f97c67f28de00d397be301821b06708fca0be", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.1-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Allows reflection of object attributes, including inherited and non-public ones", | ||
| "homepage": "https://github.com/sebastianbergmann/object-reflector/", | ||
| "time": "2017-03-29T09:07:27+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/recursion-context", | ||
| "version": "3.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/recursion-context.git", | ||
| "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", | ||
| "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "3.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Jeff Welch", | ||
| "email": "whatthejeff@gmail.com" | ||
| }, | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| }, | ||
| { | ||
| "name": "Adam Harvey", | ||
| "email": "aharvey@php.net" | ||
| } | ||
| ], | ||
| "description": "Provides functionality to recursively process PHP variables", | ||
| "homepage": "http://www.github.com/sebastianbergmann/recursion-context", | ||
| "time": "2017-03-03T06:23:57+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/resource-operations", | ||
| "version": "1.0.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/resource-operations.git", | ||
| "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", | ||
| "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.6.0" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de" | ||
| } | ||
| ], | ||
| "description": "Provides a list of PHP built-in functions that operate on resources", | ||
| "homepage": "https://www.github.com/sebastianbergmann/resource-operations", | ||
| "time": "2015-07-28T20:34:47+00:00" | ||
| }, | ||
| { | ||
| "name": "sebastian/version", | ||
| "version": "2.0.1", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/sebastianbergmann/version.git", | ||
| "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", | ||
| "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": ">=5.6" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "2.0.x-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Sebastian Bergmann", | ||
| "email": "sebastian@phpunit.de", | ||
| "role": "lead" | ||
| } | ||
| ], | ||
| "description": "Library that helps with managing the version number of Git-hosted PHP projects", | ||
| "homepage": "https://github.com/sebastianbergmann/version", | ||
| "time": "2016-10-03T07:35:21+00:00" | ||
| }, | ||
| { | ||
| "name": "theseer/tokenizer", | ||
| "version": "1.1.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/theseer/tokenizer.git", | ||
| "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", | ||
| "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "ext-dom": "*", | ||
| "ext-tokenizer": "*", | ||
| "ext-xmlwriter": "*", | ||
| "php": "^7.0" | ||
| }, | ||
| "type": "library", | ||
| "autoload": { | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "BSD-3-Clause" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Arne Blankerts", | ||
| "email": "arne@blankerts.de", | ||
| "role": "Developer" | ||
| } | ||
| ], | ||
| "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", | ||
| "time": "2017-04-07T12:08:54+00:00" | ||
| }, | ||
| { | ||
| "name": "webmozart/assert", | ||
| "version": "1.3.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/webmozart/assert.git", | ||
| "reference": "0df1908962e7a3071564e857d86874dad1ef204a" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", | ||
| "reference": "0df1908962e7a3071564e857d86874dad1ef204a", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "php": "^5.3.3 || ^7.0" | ||
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "^4.6", | ||
| "sebastian/version": "^1.0.1" | ||
| }, | ||
| "type": "library", | ||
| "extra": { | ||
| "branch-alias": { | ||
| "dev-master": "1.3-dev" | ||
| } | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Webmozart\\Assert\\": "src/" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "authors": [ | ||
| { | ||
| "name": "Bernhard Schussek", | ||
| "email": "bschussek@gmail.com" | ||
| } | ||
| ], | ||
| "description": "Assertions to validate method input/output with nice error messages.", | ||
| "keywords": [ | ||
| "assert", | ||
| "check", | ||
| "validate" | ||
| ], | ||
| "time": "2018-01-29T19:49:41+00:00" | ||
| } | ||
| ], | ||
| "aliases": [], | ||
| "minimum-stability": "stable", | ||
| "stability-flags": [], | ||
| "prefer-stable": false, | ||
| "prefer-lowest": false, | ||
| "platform": { | ||
| "php": "7.2.*" | ||
| }, | ||
| "platform-dev": [] | ||
| } |
| <?php | ||
| include(__DIR__ . '/../../vendor/autoload.php'); | ||
| use FcPhp\Di\Facades\DiFacade; | ||
| class TestClass | ||
| { | ||
| private $value; | ||
| public function setValue($value) { | ||
| $this->value = $value; | ||
| return $this; | ||
| } | ||
| public function getValue() | ||
| { | ||
| return $this->value; | ||
| } | ||
| } | ||
| // Init Di | ||
| $di = DiFacade::getInstance(); | ||
| // Configure classes | ||
| $di->set('TestClass', 'TestClass', [], ['setValue' => 'content']); | ||
| $di->set('TestClass2', 'TestClass', [], ['setValue' => $di->get('TestClass')]); | ||
| // Print: content | ||
| echo $di->make('TestClass2')->getValue()->getValue(); | ||
| echo "\n"; | ||
| $di->make('TestClass')->setValue('content-change'); | ||
| // Print: content-change | ||
| echo $di->make('TestClass')->getValue(); | ||
| echo "\n"; | ||
| // Print: test-change | ||
| echo $di->make('TestClass2')->getValue()->setValue('test-change')->getValue(); | ||
| echo "\n"; |
| The MIT License (MIT) | ||
| Copyright (c) João Moraes | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit bootstrap="vendor/autoload.php"> | ||
| <testsuites> | ||
| <testsuite name="testSuite"> | ||
| <directory>./tests/</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
| <filter> | ||
| <whitelist> | ||
| <directory suffix=".php">./src/</directory> | ||
| </whitelist> | ||
| <blacklist> | ||
| <directory suffix=".php">./vendor/</directory> | ||
| <exclude> | ||
| <directory suffix=".php">./vendor/</directory> | ||
| </exclude> | ||
| </blacklist> | ||
| </filter> | ||
| <logging> | ||
| <log type="coverage-html" target="tests/coverage" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70" /> | ||
| </logging> | ||
| </phpunit> |
| # FcPhp Dependency Injection | ||
| Package to manage dependencies of project. | ||
| [](https://travis-ci.org/00F100/fcphp-di) [](https://codecov.io/gh/00F100/fcphp-di) [](https://packagist.org/packages/00F100/fcphp-di) | ||
| ## How to install | ||
| Composer: | ||
| ```sh | ||
| $ composer require 00f100/fcphp-di | ||
| ``` | ||
| or add in composer.json | ||
| ```json | ||
| { | ||
| "require": { | ||
| "00f100/fcphp-di": "*" | ||
| } | ||
| } | ||
| ``` | ||
| ## How to use | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| $di = DiFacade::getInstance(); | ||
| /** | ||
| * Method to set new class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @return void | ||
| */ | ||
| $di->set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true); | ||
| /** | ||
| * Method to get instance of Container | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| $di->get(string $id, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| $di->setter(string $id, array $setters); | ||
| /** | ||
| * Method instance of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @return mixed | ||
| */ | ||
| $di->make(string $id, array $args = [], array $setters = []); | ||
| ``` | ||
| ## Examples | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| $di = DiFacade::getInstance(); | ||
| /* | ||
| namespace Namespace\To { | ||
| class Example { | ||
| public $foo; | ||
| private $anotherFoo; | ||
| public function __construct(string $foo) { | ||
| $this->foo = $foo; | ||
| } | ||
| public function setAnotherFoo($foo) { | ||
| $this->anotherFoo = $foo; | ||
| } | ||
| public functio getAnotherFoo() { | ||
| return $this->anotherFoo; | ||
| } | ||
| } | ||
| class ExampleBar { | ||
| public $example; | ||
| __construct(Example $example) { | ||
| $this->example = $example; | ||
| } | ||
| } | ||
| } | ||
| */ | ||
| $di->set('Example', 'Namespace\To\Example', ['foo' => 'bar'], ['setAnotherFoo', 'AnotherBar']); | ||
| $di->set('ExampleBar', 'Namespace\To\ExampleBar', ['example' => $di->get('Example')]); | ||
| // Print "bar" | ||
| echo $di->make('ExampleBar')->example->foo | ||
| // Print "AnotherBar" | ||
| echo $di->make('ExampleBar')->example->getAnotherFoo(); | ||
| ``` | ||
| ## Events | ||
| ```php | ||
| <?php | ||
| use FcPHP\Di\Facades\DiFacade; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| $di = DiFacade::getInstance(); | ||
| $di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, IInstance $instance) { | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, IInstance $instance, IContainer $container) { | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, IInstance $instance, IContainer $container, $class) { | ||
| } | ||
| ]); | ||
| ``` |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use ReflectionClass; | ||
| use ReflectionMethod; | ||
| class Container implements IContainer | ||
| { | ||
| private $instance; | ||
| private $args; | ||
| private $setters; | ||
| private $classInstance = false; | ||
| private $lock = false; | ||
| /** | ||
| * Method to construct instance of Container | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance of Container | ||
| * @param array $args Args to construct | ||
| * @param array $setters Setters methods | ||
| * @return void | ||
| */ | ||
| public function __construct(IInstance $instance, array $args = [], array $setters = []) | ||
| { | ||
| $this->instance = $instance; | ||
| $this->args = $args; | ||
| $this->setters = $setters; | ||
| } | ||
| /** | ||
| * Method to return instance of class inside Container | ||
| * | ||
| * @return mixed | ||
| */ | ||
| public function getClass() | ||
| { | ||
| if(!$this->classInstance) { | ||
| $args = array_merge($this->instance->getArgs(), $this->args); | ||
| foreach($args as $index => $value) { | ||
| if($value instanceof IContainer) { | ||
| $args[$index] = $value->getClass(); | ||
| } | ||
| } | ||
| $argsClass = []; | ||
| if(method_exists($this->instance->getNamespace(), '__construct')) { | ||
| $method = new ReflectionMethod($this->instance->getNamespace(), '__construct'); | ||
| $parameters = $method->getParameters(); | ||
| $params = []; | ||
| if(count($parameters) > 0) { | ||
| foreach($parameters as $param) { | ||
| $params[] = $param->getName(); | ||
| } | ||
| } | ||
| if(count($params) > 0) { | ||
| foreach($params as $param) { | ||
| if(isset($args[$param])) { | ||
| $argsClass[] = $args[$param]; | ||
| }else{ | ||
| $argsClass[] = null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $class = new ReflectionClass($this->instance->getNamespace()); | ||
| $instance = $class->newInstanceArgs($argsClass); | ||
| $setters = array_merge($this->instance->getSetters(), $this->setters); | ||
| if(count($setters) > 0) { | ||
| foreach($setters as $method => $value) { | ||
| if(method_exists($instance, $method)) { | ||
| if($value instanceof IContainer) { | ||
| call_user_func_array([$instance, $method], [$value->getClass()]); | ||
| }else{ | ||
| if(!is_array($value)) { | ||
| $value = [$value]; | ||
| } | ||
| call_user_func_array([$instance, $method], $value); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $this->register($instance); | ||
| $this->lock = true; | ||
| } | ||
| return $this->classInstance; | ||
| } | ||
| /** | ||
| * Method to register instance Container | ||
| * | ||
| * @param mixed Instance to inject | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function register($instance) :IContainer | ||
| { | ||
| $this->classInstance = $instance; | ||
| return $this; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| use FcPhp\Di\Traits\DiEvents; | ||
| use FcPhp\Di\Traits\DiCore; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class Di implements IDi | ||
| { | ||
| use DiEvents; | ||
| use DiCore; | ||
| /** | ||
| * @var FcPHP\Di\Interfaces\IDi Instance | ||
| */ | ||
| private static $instance; | ||
| /** | ||
| * @var array $instances List of instances | ||
| */ | ||
| private $instances = []; | ||
| /** | ||
| * @var array List of containers register | ||
| */ | ||
| private $register_containers = []; | ||
| /** | ||
| * @var bool Enable/Disable register container | ||
| */ | ||
| private $register = false; | ||
| /** | ||
| * @var FcPhp\Di\Interfaces\IContainerFactory Container Factory | ||
| */ | ||
| private $containerFactory; | ||
| /** | ||
| * @var FcPhp\Di\Interfaces\IInfanceFactory Instance Factory | ||
| */ | ||
| private $instanceFactory; | ||
| /** | ||
| * @var string Version Di | ||
| */ | ||
| private $version = '0.2.1'; | ||
| /** | ||
| * Return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IDiFactory $diFactory Instance of Di Factory | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (??!) Factory | ||
| * @return FcPHP\Di\Interfaces\IDi | ||
| */ | ||
| public static function getInstance(IDiFactory $diFactory, IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi | ||
| { | ||
| if(!self::$instance instanceof IDi) { | ||
| self::$instance = $diFactory->getInstance($containerFactory, $instanceFactory, $register); | ||
| } | ||
| return self::$instance; | ||
| } | ||
| /** | ||
| * Method to contruct instance of Di | ||
| * | ||
| * @param bool $register Define if register containers to log | ||
| */ | ||
| public function __construct(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, $register = false) | ||
| { | ||
| $this->register = $register; | ||
| $this->instanceFactory = $instanceFactory; | ||
| $this->containerFactory = $containerFactory; | ||
| } | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| $this->_set($id, $namespace, $args, $setters, $singleton); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to configure new instance non singleton | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setNonSingleton(string $id, string $namespace, array $args = [], array $setters = []) :IDi | ||
| { | ||
| return $this->set($id, $namespace, $args, $setters, false); | ||
| } | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setter(string $id, array $setters) :IDi | ||
| { | ||
| return $this->_setter($id, $setters); | ||
| } | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function get(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| return $this->_get($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| return $this->_getNonSingleton($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| public function has(string $id) :bool | ||
| { | ||
| return $this->_has($id); | ||
| } | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| * @param array $setters Setters to class | ||
| * @return mixed | ||
| */ | ||
| public function make(string $id, array $args = [], array $setters = []) | ||
| { | ||
| return $this->_make($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| public function event($eventName, object $callback = null) :void | ||
| { | ||
| $this->_event($eventName, $callback); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPHP\Di\Exceptions | ||
| { | ||
| use Exception; | ||
| class ClassBusy extends Exception | ||
| { | ||
| } | ||
| } |
| <?php | ||
| namespace FcPHP\Di\Exceptions | ||
| { | ||
| use Exception; | ||
| class InstanceNotFound extends Exception | ||
| { | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Facades | ||
| { | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class DiFacade | ||
| { | ||
| /** | ||
| * @var FcPhp\Di\Facades\DiFacade | ||
| */ | ||
| private static $instance; | ||
| /** | ||
| * Method to create and return instance of Di Facade | ||
| * | ||
| * @param bool $register Register Containers | ||
| * @return FcPhp\Di\Facades\DiFacade | ||
| */ | ||
| public static function getInstance(bool $register = false) :IDi | ||
| { | ||
| if(!self::$instance instanceof IDi) { | ||
| self::$instance = new Di(new ContainerFactory(), new InstanceFactory(), $register); | ||
| } | ||
| return self::$instance; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Container; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| class ContainerFactory implements IContainerFactory | ||
| { | ||
| /** | ||
| * Method to return instance of Container | ||
| * | ||
| * @param mixed $instance to use inside Container | ||
| * @param array $args Args to construct | ||
| * @param array @setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getInstance($instance, array $args, array $setters) :IContainer | ||
| { | ||
| return new Container($instance, $args, $setters); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| use FcPhp\Di\Di; | ||
| class DiFactory implements IDiFactory | ||
| { | ||
| /** | ||
| * Method to return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (!?!?!) Factory | ||
| * @param bool $register If register class inside log | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function getInstance(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi | ||
| { | ||
| return new Di($containerFactory, $instanceFactory, $register); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Factories | ||
| { | ||
| use FcPhp\Di\Instance; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| class InstanceFactory implements IInstanceFactory | ||
| { | ||
| /** | ||
| * Method to return new isntance of Instance (??!?@##?!) | ||
| * | ||
| * @param string $namespace Namespace of new class | ||
| * @param array $args Args to construct new class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If is singleton | ||
| */ | ||
| public function getInstance(string $namespace, array $args = [], array $setters = [], bool $singleton = true) | ||
| { | ||
| return new Instance($namespace, $args, $setters, $singleton); | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| class Instance implements IInstance | ||
| { | ||
| /** | ||
| * @var string $namespace | ||
| */ | ||
| private $namespace; | ||
| /** | ||
| * @var array $args | ||
| */ | ||
| private $args = []; | ||
| /** | ||
| * @var bool $singleton | ||
| */ | ||
| private $singleton = true; | ||
| /** | ||
| * @var array $setters | ||
| */ | ||
| private $setters = []; | ||
| /** | ||
| * Method to construct new instance | ||
| * | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct new class | ||
| * @param bool $singlegon Define if this class is singleton (or not) | ||
| * @return void | ||
| */ | ||
| public function __construct(string $namespace, array $args, array $setters, bool $singleton) | ||
| { | ||
| $this->namespace = $namespace; | ||
| $this->args = $args; | ||
| $this->singleton = $singleton; | ||
| $this->setters = $setters; | ||
| } | ||
| /** | ||
| * Method to return namespace of class | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getNamespace() :string | ||
| { | ||
| return $this->namespace; | ||
| } | ||
| /** | ||
| * Method to return args to construct class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getArgs() :array | ||
| { | ||
| return $this->args; | ||
| } | ||
| /** | ||
| * Method to return if this class is singleton | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function getIsSingleton() :bool | ||
| { | ||
| return $this->singleton; | ||
| } | ||
| /** | ||
| * Method to return list of setters to class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getSetters() :array | ||
| { | ||
| return $this->setters; | ||
| } | ||
| /** | ||
| * Method to configure setters | ||
| * | ||
| * @return FcPhp\Di\Interfaces\IInstance | ||
| */ | ||
| public function setSetters(array $setters) :IInstance | ||
| { | ||
| $this->setters = $setters; | ||
| return $this; | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| interface IContainer | ||
| { | ||
| /** | ||
| * Method to construct instance of Container | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance of Container | ||
| * @param array $args Args to construct | ||
| * @param array $setters Setters methods | ||
| * @return void | ||
| */ | ||
| public function __construct(IInstance $instance, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to return instance of class inside Container | ||
| * | ||
| * @return mixed | ||
| */ | ||
| public function getClass(); | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| interface IContainerFactory | ||
| { | ||
| /** | ||
| * Method to return instance of Container | ||
| * | ||
| * @param mixed $instance to use inside Container | ||
| * @param array $args Args to construct | ||
| * @param array @setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getInstance($instance, array $args, array $setters) :IContainer; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IDiFactory; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IContainerFactory; | ||
| use FcPhp\Di\Interfaces\IInstanceFactory; | ||
| interface IDi | ||
| { | ||
| /** | ||
| * Return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IDiFactory $diFactory Instance of Di Factory | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (??!) Factory | ||
| * @return FcPHP\Di\Interfaces\IDi | ||
| */ | ||
| public static function getInstance(IDiFactory $diFactory, IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi; | ||
| /** | ||
| * Method to contruct instance of Di | ||
| * | ||
| * @param bool $register Define if register containers to log | ||
| */ | ||
| public function __construct(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, $register = false); | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi; | ||
| /** | ||
| * Method to configure new instance non singleton | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setNonSingleton(string $id, string $namespace, array $args = [], array $setters = []) :IDi; | ||
| /** | ||
| * Method to configure setters to class | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function setter(string $id, array $setters) :IDi; | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function get(string $id, array $args = [], array $setters = []) :IContainer; | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| public function getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer; | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| public function has(string $id) :bool; | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| * @param array $setters Setters to class | ||
| * @return mixed | ||
| */ | ||
| public function make(string $id, array $args = [], array $setters = []); | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| public function event($eventName, object $callback = null) :void; | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| public function beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void; | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| public function afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance); | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeGet(string $id, array $args, array $setters) :void; | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| public function afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void; | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeMake(string $id, array $args, array $setters) :void; | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| public function afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| interface IDiFactory | ||
| { | ||
| /** | ||
| * Method to return new instance of Di | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainerFactory $containerFactory Instance of Container Factory | ||
| * @param FcPhp\Di\Interfaces\IInstanceFactory $instanceFactory Instance of Instance (!?!?!) Factory | ||
| * @param bool $register If register class inside log | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| public function getInstance(IContainerFactory $containerFactory, IInstanceFactory $instanceFactory, bool $register = false) :IDi; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| interface IInstance | ||
| { | ||
| /** | ||
| * Method to construct new instance | ||
| * | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct new class | ||
| * @param bool $singlegon Define if this class is singleton (or not) | ||
| * @return void | ||
| */ | ||
| public function __construct(string $namespace, array $args, array $setters, bool $singleton); | ||
| /** | ||
| * Method to return namespace of class | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getNamespace() :string; | ||
| /** | ||
| * Method to return args to construct class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getArgs() :array; | ||
| /** | ||
| * Method to return if this class is singleton | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function getIsSingleton() :bool; | ||
| /** | ||
| * Method to return list of setters to class | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getSetters() :array; | ||
| /** | ||
| * Method to configure setters | ||
| * | ||
| * @return FcPhp\Di\Interfaces\IInstance | ||
| */ | ||
| public function setSetters(array $setters) :IInstance; | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Interfaces | ||
| { | ||
| interface IInstanceFactory | ||
| { | ||
| /** | ||
| * Method to return new isntance of Instance (??!?@##?!) | ||
| * | ||
| * @param string $namespace Namespace of new class | ||
| * @param array $args Args to construct new class | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If is singleton | ||
| */ | ||
| public function getInstance(string $namespace, array $args = [], array $setters = [], bool $singleton = true); | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Traits | ||
| { | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Exceptions\InstanceNotFound; | ||
| use FcPhp\Di\Exceptions\ClassBusy; | ||
| trait DiCore | ||
| { | ||
| /** | ||
| * Method to make new instance of class | ||
| * | ||
| * @param string $id Identify of class | ||
| * @param array $args Args to contruct class | ||
| */ | ||
| private function _make(string $id, array $args = [], array $setters = []) | ||
| { | ||
| $this->beforeMake($id, $args, $setters); | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $instance = $this->instances[$id]; | ||
| if(!$instance->getIsSingleton()) { | ||
| $container = $this->_getNonSingleton($id, $args, $setters); | ||
| }else{ | ||
| $checksum = $this->_getChecksum($id, $args); | ||
| if(!isset($this->containers[$checksum])) { | ||
| $this->containers[$checksum] = $this->_get($id, $args, $setters); | ||
| } | ||
| $container = $this->containers[$checksum]; | ||
| } | ||
| $class = $container->getClass(); | ||
| $this->afterMake($id, $args, $setters, $instance, $container, $class); | ||
| return $class; | ||
| } | ||
| /** | ||
| * Method to return Container to manipulate instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $args Args to construct class | ||
| * @param array $setters Setters to after construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function _get(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| $this->beforeGet($id, $args, $setters); | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $instance = $this->instances[$id]; | ||
| if(!$instance->getIsSingleton()) { | ||
| $container = $this->containerFactory->getInstance($instance, $args, $setters); | ||
| $this->registerContainer($container); | ||
| $this->afterGet($id, $args, $setters, $instance, $container); | ||
| return $container; | ||
| } | ||
| $checksum = $this->_getChecksum($id, $args); | ||
| if(!isset($this->containers[$checksum])) { | ||
| $this->containers[$checksum] = $this->containerFactory->getInstance($instance, $args, $setters); | ||
| $this->registerContainer($this->containers[$checksum]); | ||
| }else{ | ||
| if(count($args) > 0 || count($setters) > 0) { | ||
| throw new ClassBusy("This class has already been instantiated, can not be its modified constructor", 500); | ||
| } | ||
| } | ||
| $this->afterGet($id, $args, $setters, $instance, $this->containers[$checksum]); | ||
| return $this->containers[$checksum]; | ||
| } | ||
| /** | ||
| * Method to return new instance non singleton of class | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct class | ||
| * @return FcPhp\Di\Interfaces\IContainer | ||
| */ | ||
| private function _getNonSingleton(string $id, array $args = [], array $setters = []) :IContainer | ||
| { | ||
| if(!isset($this->instances[$id])) { | ||
| throw new InstanceNotFound(); | ||
| } | ||
| $container = $this->containerFactory->getInstance($this->instances[$id], $args, $setters); | ||
| $this->registerContainer($container); | ||
| return $container; | ||
| } | ||
| /** | ||
| * Method to configure new instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct class | ||
| * @param bool $singleton Define this class has singleton (or not | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| private function _set(string $id, string $namespace, array $args = [], array $setters = [], bool $singleton = true) :IDi | ||
| { | ||
| $this->beforeSet($id, $namespace, $args, $setters, $singleton); | ||
| if(!isset($this->instances[$id])) { | ||
| $this->instances[$id] = $this->instanceFactory->getInstance($namespace, $args, $setters, $singleton); | ||
| } | ||
| $this->afterSet($id, $namespace, $args, $setters, $singleton, $this->instances[$id]); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to configure setters to instance | ||
| * | ||
| * @param string $id Identify instance | ||
| * @param array $setters Define setters to instance | ||
| * @return FcPhp\Di\Interfaces\IDi | ||
| */ | ||
| private function _setter(string $id, array $setters) :IDi | ||
| { | ||
| $instance = $this->instances[$id]; | ||
| $instanceSetters = $instance->getSetters(); | ||
| $instanceSetters = array_merge($instanceSetters, $setters); | ||
| $instance->setSetters($setters); | ||
| return $this; | ||
| } | ||
| /** | ||
| * Method to verify if instance exists | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @return bool | ||
| */ | ||
| private function _has(string $id) :bool | ||
| { | ||
| return isset($this->instances[$id]); | ||
| } | ||
| /** | ||
| * Method to generate new checksum | ||
| * | ||
| * @return string | ||
| */ | ||
| private function _getChecksum() | ||
| { | ||
| return md5(serialize(func_get_args())); | ||
| } | ||
| /** | ||
| * Method to register container for log | ||
| * | ||
| * @param FcPhp\Di\Interfaces\IContainer $container | ||
| * @return void | ||
| */ | ||
| private function registerContainer(IContainer $container) :void | ||
| { | ||
| if($this->register) { | ||
| $this->register_containers[] = $container; | ||
| } | ||
| } | ||
| } | ||
| } |
| <?php | ||
| namespace FcPhp\Di\Traits | ||
| { | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| trait DiEvents | ||
| { | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeSet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterSet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeGet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterGet; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $beforeMake; | ||
| /** | ||
| * @var object | ||
| */ | ||
| private $afterMake; | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| public function beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void | ||
| { | ||
| $this->_beforeSet($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| public function afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) | ||
| { | ||
| $this->_afterSet($id, $namespace, $args, $setters, $singleton, $instance); | ||
| } | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeGet(string $id, array $args, array $setters) :void | ||
| { | ||
| $this->_beforeGet($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| public function afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void | ||
| { | ||
| $this->_afterGet($id, $args, $setters, $instance, $container); | ||
| } | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| public function beforeMake(string $id, array $args, array $setters) :void | ||
| { | ||
| $this->_beforeMake($id, $args, $setters); | ||
| } | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| public function afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void | ||
| { | ||
| $this->_afterMake($id, $args, $setters, $instance, $container, $class); | ||
| } | ||
| /** | ||
| * Method to execute clousure on event | ||
| * | ||
| * @param string $eventName Event Name, ex: beforeSet | ||
| * @param object $callback Function to execute | ||
| * @return void | ||
| */ | ||
| private function _event($eventName, object $callback = null) :void | ||
| { | ||
| if(is_array($eventName)) { | ||
| foreach($eventName as $eName => $clousure) { | ||
| $this->{$eName} = $clousure; | ||
| } | ||
| }else{ | ||
| $this->{$eventName} = $callback; | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @return void | ||
| */ | ||
| private function _beforeSet(string $id, string $namespace, array $args, array $setters, bool $singleton) :void | ||
| { | ||
| $event = $this->beforeSet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute set() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param string $namespace Namespace of class | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param bool $singleton If this class is singleton | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @return void | ||
| */ | ||
| private function _afterSet(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) | ||
| { | ||
| $event = $this->afterSet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $namespace, $args, $setters, $singleton, $instance); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| private function _beforeGet(string $id, array $args, array $setters) :void | ||
| { | ||
| $event = $this->beforeGet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute get() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @return void | ||
| */ | ||
| private function _afterGet(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) :void | ||
| { | ||
| $event = $this->afterGet; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters, $instance, $container); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event before execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @return void | ||
| */ | ||
| private function _beforeMake(string $id, array $args, array $setters) :void | ||
| { | ||
| $event = $this->beforeMake; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters); | ||
| } | ||
| } | ||
| /** | ||
| * Method to event after execute make() | ||
| * | ||
| * @param string $id Identify of instance | ||
| * @param array $args Args to construct instance | ||
| * @param array $setters Setters to class | ||
| * @param FcPhp\Di\Interfaces\IInstance $instance Instance config of class | ||
| * @param FcPhp\Di\Interfaces\IContainer $container Instance of Container | ||
| * @param mixed $class Instance of class | ||
| * @return void | ||
| */ | ||
| private function _afterMake(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) :void | ||
| { | ||
| $event = $this->afterMake; | ||
| if(gettype($event) == 'object') { | ||
| $event($id, $args, $setters, $instance, $container, $class); | ||
| } | ||
| } | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Factories\DiFactory; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use FcPhp\Di\Interfaces\Icontainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| use FcPhp\Di\Facades\DiFacade; | ||
| require_once(__DIR__ . '/../Unit/Mock.php'); | ||
| class DiIntegrationTest extends Mock | ||
| { | ||
| public function setUp() | ||
| { | ||
| $this->di = DiFacade::getInstance(true); | ||
| } | ||
| public function testCreate() | ||
| { | ||
| $this->assertTrue(Di::getInstance(new DiFactory(), new ContainerFactory(), new InstanceFactory(), false) instanceof IDi); | ||
| } | ||
| public function testIntance() | ||
| { | ||
| $this->assertTrue($this->di instanceof IDi); | ||
| } | ||
| public function testSetGet() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->get('TestClass') instanceof IContainer); | ||
| } | ||
| public function testMake() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->make('TestClass') instanceof \MockCallback); | ||
| } | ||
| public function testGetNonSingleton() | ||
| { | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| $this->assertTrue($this->di->getNonSingleton('TestClass')->getClass() instanceof \MockCallback); | ||
| } | ||
| public function testEvent() | ||
| { | ||
| $this->di->event('beforeSet', function() { | ||
| $this->assertTrue(true); | ||
| }); | ||
| $this->di->set('TestClass', '\MockCallback'); | ||
| } | ||
| public function testSetNonSinglet() | ||
| { | ||
| $this->assertTrue($this->di->setNonSingleton('TestClass', '\MockCallback') instanceof IDi); | ||
| } | ||
| public function testInjectDependency() | ||
| { | ||
| $this->di->set('TestClass1', '\MockCallbackParams', ['value' => 'content'], ['setTest' => 'test'], false); | ||
| $this->di->set('TestClass2', '\MockCallbackParams', ['value' => $this->di->get('TestClass1')], ['setTest' => $this->di->get('TestClass1')]); | ||
| $this->assertTrue($this->di->make('TestClass2') instanceof \MockCallbackParams); | ||
| $this->assertTrue($this->di->make('TestClass2')->args instanceof \MockCallbackParams); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetInstanceNotFound() | ||
| { | ||
| $this->di->get('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetNonSingletonInstanceNotFound() | ||
| { | ||
| $this->di->getNonSingleton('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testMakeInstanceNotFound() | ||
| { | ||
| $this->di->make('test'); | ||
| } | ||
| public function testGetMakeNonSingleton() | ||
| { | ||
| $this->di->setNonSingleton('ClassLocal', '\MockCallback'); | ||
| $this->assertTrue($this->di->make('ClassLocal') instanceof \MockCallback); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\ClassBusy | ||
| */ | ||
| public function testGetChangeValuesAfterInstance() | ||
| { | ||
| $this->di->set('ClassLocalChange', '\MockCallbackParams', ['value' => 'content']); | ||
| $instance = $this->di->make('ClassLocalChange'); | ||
| $this->di->get('ClassLocalChange', [], ['setTest' => 'value']); | ||
| } | ||
| public function testEvents() | ||
| { | ||
| $this->di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, '\MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| $this->assertTrue($class instanceof \MockCallback); | ||
| }, | ||
| ]); | ||
| $this->di->event('afterGet', function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }); | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->get('MockCallback') instanceof IContainer); | ||
| $this->assertTrue($this->di->make('MockCallback') instanceof \MockCallback); | ||
| } | ||
| public function testSettersMethod() | ||
| { | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->setter('MockCallback', ['setTest' => 'value']) instanceof IDI); | ||
| } | ||
| public function testHas() | ||
| { | ||
| $this->di->set('MockCallback', '\MockCallback'); | ||
| $this->assertTrue($this->di->has('MockCallback')); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Container; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| require_once('Mock.php'); | ||
| class ContainerTest extends Mock | ||
| { | ||
| public $container; | ||
| // public $instance; | ||
| // public $args; | ||
| // public $setters; | ||
| public function setUp() | ||
| { | ||
| $instance = $this->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getArgs') | ||
| ->will($this->returnValue([])); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getSetters') | ||
| ->will($this->returnValue([])); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getNamespace') | ||
| ->will($this->returnValue('\MockCallbackParams')); | ||
| $container = new Container($instance, ['value' => 'param'], ['setTest' => 'value']); | ||
| $this->container = new Container($instance, ['value' => $container], ['setTest' => $container]); | ||
| } | ||
| public function testInstance() | ||
| { | ||
| $this->assertTrue($this->container instanceof IContainer); | ||
| } | ||
| public function testGetClass() | ||
| { | ||
| $this->assertTrue($this->container->getClass() instanceof \MockCallbackParams); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Di; | ||
| use FcPhp\Di\Factories\ContainerFactory; | ||
| use FcPhp\Di\Factories\InstanceFactory; | ||
| use PHPUnit\Framework\TestCase; | ||
| use FcPhp\Di\Interfaces\IDi; | ||
| use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| require_once('Mock.php'); | ||
| class DiTest extends Mock | ||
| { | ||
| public $di; | ||
| public function setUp() | ||
| { | ||
| $this->di = new Di($this->getContainerMock(), $this->getInstanceMock(), true); | ||
| } | ||
| public function testEvents() | ||
| { | ||
| $this->di->event([ | ||
| 'beforeSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| }, | ||
| 'afterSet' => function(string $id, string $namespace, array $args, array $setters, bool $singleton, ?IInstance $instance) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($namespace, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertEquals($singleton, true); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| }, | ||
| 'beforeGet' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterGet' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }, | ||
| 'beforeMake' => function(string $id, array $args, array $setters) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| }, | ||
| 'afterMake' => function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container, $class) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| $this->assertTrue($class instanceof MockCallback); | ||
| }, | ||
| ]); | ||
| $this->di->event('afterGet', function(string $id, array $args, array $setters, ?IInstance $instance, ?IContainer $container) { | ||
| $this->assertEquals($id, 'MockCallback'); | ||
| $this->assertEquals($args, []); | ||
| $this->assertEquals($setters, []); | ||
| $this->assertTrue($instance instanceof IInstance); | ||
| $this->assertTrue($container instanceof IContainer); | ||
| }); | ||
| $this->di->set('MockCallback', 'MockCallback'); | ||
| $this->assertTrue($this->di->get('MockCallback') instanceof IContainer); | ||
| $this->assertTrue($this->di->make('MockCallback') instanceof MockCallback); | ||
| } | ||
| public function testInstanceDi() | ||
| { | ||
| $this->assertTrue($this->di instanceof IDi); | ||
| } | ||
| public function testSetInstance() | ||
| { | ||
| $this->assertTrue($this->di->set('ClassTest', 'MockCallback') instanceof IDi); | ||
| } | ||
| public function testSetNonSingletonInstance() | ||
| { | ||
| $this->assertTrue($this->di->setNonSingleton('ClassTest', 'MockCallback') instanceof IDi); | ||
| } | ||
| public function testGetInstance() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->get('ClassTeste') instanceof IContainer); | ||
| } | ||
| public function testGetNonSingletonInstance() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->getNonSingleton('ClassTeste') instanceof IContainer); | ||
| } | ||
| public function testMake() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $this->assertTrue($this->di->make('ClassTeste') instanceof MockCallback); | ||
| } | ||
| public function testGetInstanceOfDi() | ||
| { | ||
| $this->assertTrue(Di::getInstance($this->createMock('FcPhp\Di\Interfaces\IDiFactory'), $this->createMock('FcPhp\Di\Interfaces\IContainerFactory'), $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory')) instanceof IDi); | ||
| } | ||
| public function testMakeGetNonSingleton() | ||
| { | ||
| $di = new Di($this->getContainerMock(), $this->getInstanceNonSingletonMock()); | ||
| $di->set('MockCallback', 'MockCallback', [], [], false); | ||
| $this->assertTrue($di->make('MockCallback') instanceof MockCallback); | ||
| $this->assertTrue($di->get('MockCallback') instanceof IContainer); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetNonSingleInstanceError() | ||
| { | ||
| $this->di->getNonSingleton('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testGetInstanceError() | ||
| { | ||
| $this->di->get('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\InstanceNotFound | ||
| */ | ||
| public function testMakeInstanceError() | ||
| { | ||
| $this->di->make('test'); | ||
| } | ||
| /** | ||
| * @expectedException FcPhp\Di\Exceptions\ClassBusy | ||
| */ | ||
| public function testMakeInstanceErrorClassBosy() | ||
| { | ||
| $this->di->set('ClassTeste', 'MockCallback'); | ||
| $class = $this->di->make('ClassTeste'); | ||
| $this->assertTrue($class instanceof MockCallback); | ||
| $class->param = 'value1'; | ||
| $this->di->get('ClassTeste', [], ['setFoo' => 'bar'])->getClass(); | ||
| } | ||
| public function testSetSetters() | ||
| { | ||
| $this->di->set('ClassMock', 'MockCallbackParams'); | ||
| $this->assertTrue($this->di->setter('ClassMock', ['setTest' => 'value']) instanceof IDi); | ||
| } | ||
| public function testHas() | ||
| { | ||
| $this->di->set('ClassMock', 'MockCallbackParams'); | ||
| $this->assertTrue($this->di->has('ClassMock')); | ||
| } | ||
| } |
| <?php | ||
| use FcPhp\Di\Instance; | ||
| // use FcPhp\Di\Factories\ContainerFactory; | ||
| // use FcPhp\Di\Factories\InstanceFactory; | ||
| // use PHPUnit\Framework\TestCase; | ||
| // use FcPhp\Di\Interfaces\IDi; | ||
| // use FcPhp\Di\Interfaces\IContainer; | ||
| use FcPhp\Di\Interfaces\IInstance; | ||
| require_once('Mock.php'); | ||
| class InstanceTest extends Mock | ||
| { | ||
| public $namespace; | ||
| public $args = []; | ||
| public $setters; | ||
| public $instance; | ||
| public function setUp() | ||
| { | ||
| $this->namespace = '\MockCallback'; | ||
| $this->args = ['foo' => 'bar']; | ||
| $this->setters = ['setFoo' => 'val']; | ||
| $this->instance = new Instance($this->namespace, $this->args, $this->setters, true); | ||
| } | ||
| public function testInstance() | ||
| { | ||
| $this->assertTrue($this->instance instanceof IInstance); | ||
| } | ||
| public function testGetNamespace() | ||
| { | ||
| $this->assertEquals($this->instance->getNamespace(), $this->namespace); | ||
| } | ||
| public function testGetArgs() | ||
| { | ||
| $this->assertEquals($this->instance->getArgs(), $this->args); | ||
| } | ||
| public function testGetSetters() | ||
| { | ||
| $this->assertEquals($this->instance->getSetters(), $this->setters); | ||
| } | ||
| public function testGetIsSingleton() | ||
| { | ||
| $this->assertEquals($this->instance->getIsSingleton(), true); | ||
| } | ||
| public function testSetSetters() | ||
| { | ||
| $setters = ['method' => 'value']; | ||
| $this->instance->setSetters($setters); | ||
| $this->assertEquals($this->instance->getSetters(), $setters); | ||
| } | ||
| } |
| <?php | ||
| use PHPUnit\Framework\TestCase; | ||
| Class Mock extends TestCase | ||
| { | ||
| public function getContainerMock() | ||
| { | ||
| $phpunit = $this; | ||
| $containerFactory = $this->createMock('FcPhp\Di\Interfaces\IContainerFactory'); | ||
| $containerFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit){ | ||
| $container = $phpunit->createMock('FcPhp\Di\Interfaces\IContainer'); | ||
| $container | ||
| ->expects($this->any()) | ||
| ->method('getClass') | ||
| ->will($this->returnCallback(function() { | ||
| return new MockCallback(); | ||
| })); | ||
| return $container; | ||
| })); | ||
| return $containerFactory; | ||
| } | ||
| public function getInstanceMock() | ||
| { | ||
| $phpunit = $this; | ||
| $instanceFactory = $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory'); | ||
| $instanceFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit) { | ||
| $instance = $phpunit->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getIsSingleton') | ||
| ->will($this->returnValue(true)); | ||
| return $instance; | ||
| })); | ||
| return $instanceFactory; | ||
| } | ||
| public function getInstanceNonSingletonMock() | ||
| { | ||
| $phpunit = $this; | ||
| $instanceFactory = $this->createMock('FcPhp\Di\Interfaces\IInstanceFactory'); | ||
| $instanceFactory | ||
| ->expects($this->any()) | ||
| ->method('getInstance') | ||
| ->will($this->returnCallback(function() use ($phpunit) { | ||
| $instance = $phpunit->createMock('FcPhp\Di\Interfaces\IInstance'); | ||
| $instance | ||
| ->expects($this->any()) | ||
| ->method('getIsSingleton') | ||
| ->will($this->returnValue(false)); | ||
| return $instance; | ||
| })); | ||
| return $instanceFactory; | ||
| } | ||
| } | ||
| class MockCallback | ||
| { | ||
| public $args; | ||
| public function __construct() | ||
| { | ||
| $this->args = func_get_args(); | ||
| } | ||
| } | ||
| class MockCallbackParams | ||
| { | ||
| public $args; | ||
| public $test; | ||
| public function __construct($value) | ||
| { | ||
| $this->args = $value; | ||
| } | ||
| public function setTest($value) | ||
| { | ||
| $this->test = $value; | ||
| } | ||
| } |