diff --git a/composer.json b/composer.json index 6be40b36eabc0c866f35f1bffb964f7d8e4cf6a2..6c96b2dfeebae5de9dc27d45c28460ccfb28bba9 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,7 @@ "jasig/phpcas": "*", "johnwohlers/sip2": "dev-master", "mobileesp/mdetect": "dev-master", + "ocramius/proxy-manager": "*", "oyejorge/less.php": "*", "pear-pear.php.net/file_marc": "*", "pear-pear.php.net/pear": "*", diff --git a/composer.lock b/composer.lock index 6d71cbeaa63aaf54343d88a9355853873492c67d..036646d92564495e23288ecbfc3a6589b8d9e90c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fee460941507f1e403fd5c4b6d6b862f", + "hash": "bdf603dc03336b065db2cb676f092114", "packages": [ { "name": "aferrandini/phpqrcode", @@ -135,6 +135,70 @@ ] } }, + { + "name": "ocramius/proxy-manager", + "version": "0.5.1", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/ProxyManager.git", + "reference": "eaaf10f9a24ffd79a3e388809f6d61f229e261bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/eaaf10f9a24ffd79a3e388809f6d61f229e261bd", + "reference": "eaaf10f9a24ffd79a3e388809f6d61f229e261bd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-code": ">2.2.5,<3.0" + }, + "require-dev": { + "ext-phar": "*", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "1.5.*" + }, + "suggest": { + "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", + "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", + "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", + "zendframework/zend-stdlib": "To use the hydrator proxy", + "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "ProxyManager\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/", + "role": "Developer" + } + ], + "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", + "homepage": "https://github.com/Ocramius/ProxyManager", + "keywords": [ + "aop", + "lazy loading", + "proxy", + "proxy pattern", + "service proxies" + ], + "time": "2014-03-12 14:00:19" + }, { "name": "oyejorge/less.php", "version": "v1.7.0.2", diff --git a/module/VuFind/src/VuFind/Auth/Factory.php b/module/VuFind/src/VuFind/Auth/Factory.php index 19bac6ba708e459acf829f01ffd22c46f16a2b0f..fc73a13c230943f13e02072e444c7ae434ce06fd 100644 --- a/module/VuFind/src/VuFind/Auth/Factory.php +++ b/module/VuFind/src/VuFind/Auth/Factory.php @@ -61,9 +61,22 @@ class Factory */ public static function getILSAuthenticator(ServiceManager $sm) { - $auth = $sm->get('VuFind\AuthManager'); - $catalog = $sm->get('VuFind\ILSConnection'); - return new ILSAuthenticator($auth, $catalog); + // Construct the ILS authenticator as a lazy loading value holder so that + // the object is not instantiated until it is called. This helps break a + // potential circular dependency with the MultiBackend driver as well as + // saving on initialization costs in cases where the authenticator is not + // actually utilized. + $callback = function (& $wrapped, $proxy) use ($sm) { + // Generate wrapped object: + $auth = $sm->get('VuFind\AuthManager'); + $catalog = $sm->get('VuFind\ILSConnection'); + $wrapped = new ILSAuthenticator($auth, $catalog); + + // Indicate that initialization is complete to avoid reinitialization: + $proxy->setProxyInitializer(null); + }; + $factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory(); + return $factory->createProxy('VuFind\Auth\ILSAuthenticator', $callback); } /** diff --git a/vendor/autoload.php b/vendor/autoload.php index 6686884c28321fcbc095936fd24e26daf02b0a9c..fda071db9125ebde330dbb7ebea3eea127b68b78 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443::getLoader(); +return ComposerAutoloaderInit787a7480744b64d80a4758b706585039::getLoader(); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 8e1dd16c82b79c2284c97fffd54ac9f9949c7290..33addd7ad2b55cf679a1de1a89d52f96c67f383f 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -13,6 +13,7 @@ return array( 'ZendRest' => array($vendorDir . '/zendframework/zendrest/library'), 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), 'SerialsSolutions' => array($vendorDir . '/serialssolutions/summon'), + 'ProxyManager\\' => array($vendorDir . '/ocramius/proxy-manager/src'), 'PHPQRCode' => array($vendorDir . '/aferrandini/phpqrcode/lib'), 'Less' => array($vendorDir . '/oyejorge/less.php/lib'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 2c19f699aaceb1f29c530d53ebe8f1f6e58fbc89..731556ae4993f7c502a1495946d54a038ee1f906 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443 +class ComposerAutoloaderInit787a7480744b64d80a4758b706585039 { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit787a7480744b64d80a4758b706585039', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit787a7480744b64d80a4758b706585039', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; array_push($includePaths, get_include_path()); @@ -48,7 +48,7 @@ class ComposerAutoloaderInit328ec30d59afd86e26ec0bf54ac09443 } } -function composerRequire328ec30d59afd86e26ec0bf54ac09443($file) +function composerRequire787a7480744b64d80a4758b706585039($file) { require $file; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 4d6fef9e0f7e80e40b20f125a1f70f61ac7e5924..a8547aea4425908e9f9c179cd5d18141eced6bce 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -838,5 +838,71 @@ "source": "https://github.com/zendframework/ZendService_ReCaptcha/tree/release-2.0.1", "issues": "https://github.com/zendframework/ZendService_ReCaptcha/issues" } + }, + { + "name": "ocramius/proxy-manager", + "version": "0.5.1", + "version_normalized": "0.5.1.0", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/ProxyManager.git", + "reference": "eaaf10f9a24ffd79a3e388809f6d61f229e261bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/eaaf10f9a24ffd79a3e388809f6d61f229e261bd", + "reference": "eaaf10f9a24ffd79a3e388809f6d61f229e261bd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-code": ">2.2.5,<3.0" + }, + "require-dev": { + "ext-phar": "*", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "1.5.*" + }, + "suggest": { + "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", + "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", + "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", + "zendframework/zend-stdlib": "To use the hydrator proxy", + "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" + }, + "time": "2014-03-12 14:00:19", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "ProxyManager\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/", + "role": "Developer" + } + ], + "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", + "homepage": "https://github.com/Ocramius/ProxyManager", + "keywords": [ + "aop", + "lazy loading", + "proxy", + "proxy pattern", + "service proxies" + ] } ] diff --git a/vendor/ocramius/proxy-manager/.gitignore b/vendor/ocramius/proxy-manager/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..c12b0ce954b79a0932abb13d2b29af6a4e291b77 --- /dev/null +++ b/vendor/ocramius/proxy-manager/.gitignore @@ -0,0 +1,6 @@ +vendor +composer.lock +composer.phar +phpunit.xml +phpmd.xml +phpdox.xml diff --git a/vendor/ocramius/proxy-manager/.scrutinizer.yml b/vendor/ocramius/proxy-manager/.scrutinizer.yml new file mode 100644 index 0000000000000000000000000000000000000000..df6d207ec6428e3e20941e7443dc089d72ddc6fa --- /dev/null +++ b/vendor/ocramius/proxy-manager/.scrutinizer.yml @@ -0,0 +1,44 @@ +before_commands: + - "composer install --no-dev --prefer-source" + +tools: + php_code_coverage: + enabled: true + test_command: phpunit -c phpunit.xml.dist --exclude-group Functional,Performance + php_code_sniffer: + enabled: true + config: + standard: PSR2 + filter: + paths: ["src/*", "tests/*"] + php_cpd: + enabled: true + excluded_dirs: ["build/*", "docs", "examples", "tests", "vendor"] + php_cs_fixer: + enabled: true + config: + level: all + filter: + paths: ["src/*", "tests/*"] + php_loc: + enabled: true + excluded_dirs: ["build", "docs", "examples", "tests", "vendor"] + php_mess_detector: + enabled: true + config: + ruleset: phpmd.xml.dist + design_rules: { eval_expression: false } + filter: + paths: ["src/*"] + php_pdepend: + enabled: true + excluded_dirs: ["build", "docs", "examples", "tests", "vendor"] + php_analyzer: + enabled: true + filter: + paths: ["src/*", "tests/*", "examples/*"] + php_hhvm: + enabled: true + filter: + paths: ["src/*", "tests/*", "examples/*"] + sensiolabs_security_checker: true diff --git a/vendor/ocramius/proxy-manager/.travis.yml b/vendor/ocramius/proxy-manager/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..bfb3ba3eee98c487c03112691aab910c3b9fbf32 --- /dev/null +++ b/vendor/ocramius/proxy-manager/.travis.yml @@ -0,0 +1,23 @@ +language: php + +php: + - 5.3.3 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - composer self-update + - composer update --prefer-source; composer install --dev --prefer-source; + +script: + - ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml --exclude-group Performance + - ./vendor/bin/phpunit ./tests/language-feature-scripts/ + - php -n ./vendor/bin/phpunit --group=Performance + - ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/ + +matrix: + allow_failures: + - php: hhvm diff --git a/vendor/ocramius/proxy-manager/CONTRIBUTING.md b/vendor/ocramius/proxy-manager/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..d07d8dc3a870e68a40502f2e717188e7c3b81375 --- /dev/null +++ b/vendor/ocramius/proxy-manager/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contributing + + * Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) + * The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php) + * Any contribution must provide tests for additional introduced conditions + * Any un-confirmed issue needs a failing test case before being accepted + * Pull requests must be sent from a new hotfix/feature branch, not from `master`. + +## Installation + +To install the project and run the tests, you need to clone it first: + +```sh +$ git clone git://github.com/Ocramius/ProxyManager.git +``` + +You will then need to run a composer installation: + +```sh +$ cd ProxyManager +$ curl -s https://getcomposer.org/installer | php +$ php composer.phar update +``` + +## Testing + +The PHPUnit version to be used is the one installed as a dev- dependency via composer: + +```sh +$ ./vendor/bin/phpunit +``` + +Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement +won't be merged. + diff --git a/vendor/ocramius/proxy-manager/LICENSE b/vendor/ocramius/proxy-manager/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..49adae035a2c355b285322fe8a3b4c2474621503 --- /dev/null +++ b/vendor/ocramius/proxy-manager/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Marco Pivetta + +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. \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/README.md b/vendor/ocramius/proxy-manager/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4244f597cd821a1472f38da95eb78a888419b2d3 --- /dev/null +++ b/vendor/ocramius/proxy-manager/README.md @@ -0,0 +1,193 @@ +# Proxy Manager + +This library aims at providing abstraction for generating various kinds of [proxy classes](http://marco-pivetta.com/proxy-pattern-in-php/). + + + +[](https://travis-ci.org/Ocramius/ProxyManager) +[](https://scrutinizer-ci.com/g/Ocramius/ProxyManager/) +[](https://scrutinizer-ci.com/g/Ocramius/ProxyManager/) +[](https://insight.sensiolabs.com/projects/69fe5f97-b1c8-4ddd-93ce-900b8b788cf2) +[](https://www.versioneye.com/package/php--ocramius--proxy-manager) + +[](https://packagist.org/packages/ocramius/proxy-manager) +[](https://packagist.org/packages/ocramius/proxy-manager) +[](https://packagist.org/packages/ocramius/proxy-manager) + +## Installation + +The suggested installation method is via [composer](https://getcomposer.org/): + +```sh +php composer.phar require ocramius/proxy-manager:0.5.* +``` + +## Lazy Loading Value Holders (Virtual Proxy) + +ProxyManager can generate [lazy loading value holders](http://www.martinfowler.com/eaaCatalog/lazyLoad.html), +which are virtual proxies capable of saving performance and memory for objects that require a lot of dependencies or +CPU cycles to be loaded: particularly useful when you may not always need the object, but are constructing it anyways. + +```php +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory(); + +$proxy = $factory->createProxy( + 'MyApp\HeavyComplexObject', + function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) { + $wrappedObject = new HeavyComplexObject(); // instantiation logic here + $initializer = null; // turning off further lazy initialization + + return true; + } +); + +$proxy->doFoo(); +``` + +See the [complete documentation about lazy loading value holders](/docs/lazy-loading-value-holder.md) +in the `docs/` directory. + +## Access Interceptor Value Holder + +An access interceptor value holder is a smart reference that allows you to execute logic before +and after a particular method is executed or a particular property is accessed, and it allows to +manipulate parameters and return values depending on your needs. + +```php +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory(); + +$proxy = $factory->createProxy( + new \My\Db\Connection(), + array('query' => function () { echo "Query being executed!\n"; }), + array('query' => function () { echo "Query completed!\n"; }) +); + +$proxy->query(); // produces "Query being executed!\nQuery completed!\n" +``` + +See the [complete documentation about access interceptor value holders](/docs/access-interceptor-value-holder.md) +in the `docs/` directory. + +## Access Interceptor Scope Localizer + +An access interceptor scope localizer works exactly like an access interceptor value holder, +but it is safe to use to proxy fluent interfaces. + +See the [complete documentation about access interceptor scope localizer](/docs/access-interceptor-scope-localizer.md) +in the `docs/` directory. + +## Null Objects + +A Null Object proxy implements the [null object pattern](http://en.wikipedia.org/wiki/Null_Object_pattern). + +This kind of proxy allows you to have fallback logic in case loading of the wrapped value failed. + +```php +$factory = new \ProxyManager\Factory\NullObjectFactory(); + +$proxy = $factory->createProxy('My\EntityObject'); + +$proxy->getName(); // empty return +``` + +A Null Object Proxy can be created from an object, a class name or an interface name: + +```php +$factory = new \ProxyManager\Factory\NullObjectFactory(); + +$proxy = $factory->createProxy('My\EntityObjectInterface'); // created from interface name +$proxy->getName(); // empty return + +$proxy = $factory->createProxy($entity); // created from object +$proxy->getName(); // empty return +``` + +See the [complete documentation about null object proxy](/docs/null-object.md) +in the `docs/` directory. + +## Ghost Objects + + +Similar to value holder, a ghost object is usually created to handle lazy loading. + +The difference between a value holder and a ghost object is that the ghost object does not contain a real instance of +the required object, but handles lazy loading by initializing its own inherited properties. + +ProxyManager can generate [lazy loading ghost objects](http://www.martinfowler.com/eaaCatalog/lazyLoad.html), +which are proxies used to save performance and memory for large datasets and graphs representing relational data. +Ghost objects are particularly useful when building data-mappers. + +Additionally, the overhead introduced by ghost objects is very low when compared to the memory and performance overhead +caused by virtual proxies. + +```php +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory(); + +$proxy = $factory->createProxy( + 'MyApp\HeavyComplexObject', + function ($proxy, $method, $parameters, & $initializer) { + $initializer = null; // turning off further lazy initialization + + // modify the proxy instance + $proxy->setFoo('foo'); + $proxy->setBar('bar'); + + return true; + } +); + +$proxy->doFoo(); +``` + +See the [complete documentation about lazy loading ghost objects](/docs/lazy-loading-ghost-object.md) +in the `docs/` directory. + +## Lazy References + +A lazy reference proxy is actually a proxy backed by some kind of reference holder (usually a registry) that can fetch +existing instances of a particular object. + +A lazy reference is usually necessary when multiple instances of the same object can be avoided, or when the instances +are not hard links (like with [Weakref](http://php.net/manual/en/book.weakref.php)), and could be garbage-collected to +save memory in long time running processes. + +This feature [yet to be planned](https://github.com/Ocramius/ProxyManager/issues/8). + +## Remote Object + +A remote object proxy is an object that is located on a different system, but is used as if it was available locally. +There's various possible remote proxy implementations, which could be based on xmlrpc/jsonrpc/soap/dnode/etc. + +This example uses the XML-RPC client of Zend Framework 2: + +```php +interface FooServiceInterface +{ + public function foo(); +} + +$factory = new \ProxyManager\Factory\RemoteObjectFactory( + new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc( + new \Zend\XmlRpc\Client('https://example.com/rpc-endpoint') + ) +); + +// proxy is your remote implementation +$proxy = $factory->createProxy('FooServiceInterface'); + +var_dump($proxy->foo()); +``` + +See the [complete documentation about remote objects](https://github.com/Ocramius/ProxyManager/tree/master/docs/remote-object.md) +in the `docs/` directory. + +## Contributing + +Please read the [CONTRIBUTING.md](https://github.com/Ocramius/ProxyManager/blob/master/CONTRIBUTING.md) contents if you +wish to help out! + +## Credits + +The idea was originated by a [talk about Proxies in PHP OOP](http://marco-pivetta.com/proxy-pattern-in-php/) that I gave +at the [@phpugffm](https://twitter.com/phpugffm) in January 2013. + diff --git a/vendor/ocramius/proxy-manager/UPGRADE.md b/vendor/ocramius/proxy-manager/UPGRADE.md new file mode 100644 index 0000000000000000000000000000000000000000..d0de61d3951852a4a5cfecf707f068e8b9ba9306 --- /dev/null +++ b/vendor/ocramius/proxy-manager/UPGRADE.md @@ -0,0 +1,69 @@ +This is a list of backwards compatibility (BC) breaks introduced in ProxyManager: + +# 0.5.0 + + * The Generated Hydrator has been removed - it is now available as a separate project + at [Ocramius/GeneratedHydrator](https://github.com/Ocramius/GeneratedHydrator) [#65](https://github.com/Ocramius/ProxyManager/pull/65) + * When having a `public function __get($name)` defined (by-val) and public properties, it won't be possible to get public + properties by-ref while initializing the object. Either drop `__get()` or implement + a by-ref `& __get()` [#126](https://github.com/Ocramius/ProxyManager/pull/126) + * Proxies are now being always auto-generated if they could not be autoloaded by a factory. The methods + [`ProxyManager\Configuration#setAutoGenerateProxies()`](https://github.com/Ocramius/ProxyManager/blob/0.5.0-BETA2/src/ProxyManager/Configuration.php#L67) + and [`ProxyManager\Configuration#doesAutoGenerateProxies()`](https://github.com/Ocramius/ProxyManager/blob/0.5.0-BETA2/src/ProxyManager/Configuration.php#L75) + are now no-op and deprecated, and will be removed in the next minor + version [#87](https://github.com/Ocramius/ProxyManager/pull/87) [#90](https://github.com/Ocramius/ProxyManager/pull/90) + * Proxy public properties defaults are now set before initialization [#116](https://github.com/Ocramius/ProxyManager/pull/116) [#122](https://github.com/Ocramius/ProxyManager/pull/122) + +# 0.4.0 + + * An optional parameter `$options` was introduced + in [`ProxyManager\Inflector\ClassNameInflectorInterface#getProxyClassName($className, array $options = array())`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Inflector/ClassNameInflectorInterface.php) + parametrize the generated class name as of [#10](https://github.com/Ocramius/ProxyManager/pull/10) + and [#59](https://github.com/Ocramius/ProxyManager/pull/59) + * Generated hydrators no longer have constructor arguments. Any required reflection instantiation is now dealt with + in the hydrator internally as of [#63](https://github.com/Ocramius/ProxyManager/pull/63) + +# 0.3.4 + + * Interface names are also supported for proxy generation as of [#40](https://github.com/Ocramius/ProxyManager/pull/40) + +# 0.3.3 + + * [Generated hydrators](https://github.com/Ocramius/ProxyManager/tree/master/docs/generated-hydrator.md) were introduced + +# 0.3.2 + + * An additional (optional) [by-ref parameter was added](https://github.com/Ocramius/ProxyManager/pull/31) + to the lazy loading proxies' initializer to allow unsetting the initializer with less overhead. + +# 0.3.0 + + * Dependency to [jms/cg](https://github.com/schmittjoh/cg-library) removed + * Moved code generation logic to [`Zend\Code`](https://github.com/zendframework/zf2) + * Added method [`ProxyManager\Inflector\ClassNameInflectorInterface#isProxyClassName($className)`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Inflector/ClassNameInflectorInterface.php) + * The constructor of [`ProxyManager\Autoloader\Autoloader`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Autoloader/Autoloader.php) + changed from `__construct(\ProxyManager\FileLocator\FileLocatorInterface $fileLocator)` to + `__construct(\ProxyManager\FileLocator\FileLocatorInterface $fileLocator, \ProxyManager\Inflector\ClassNameInflectorInterface $classNameInflector)` + * Classes implementing `CG\Core\GeneratorStrategyInterface` now implement + [`ProxyManager\GeneratorStrategy\GeneratorStrategyInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/GeneratorStrategy/GeneratorStrategyInterface.php) + instead + * All code generation logic has been replaced - If you wrote any logic based on `ProxyManager\ProxyGenerator`, you will + have to rewrite it + +# 0.2.0 + + * The signature of initializers to be used with proxies implementing + [`ProxyManager\Proxy\LazyLoadingInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/LazyLoadingInterface.php) + changed from: + + ```php + $initializer = function ($proxy, & $wrappedObject, $method, $parameters) {}; + ``` + + to + + ```php + $initializer = function (& $wrappedObject, $proxy, $method, $parameters) {}; + ``` + + Only the order of parameters passed to the closures has been changed. diff --git a/vendor/ocramius/proxy-manager/build/.gitignore b/vendor/ocramius/proxy-manager/build/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6d8e8bfe3bee0f04034151c3031be7d8bc6caa3c --- /dev/null +++ b/vendor/ocramius/proxy-manager/build/.gitignore @@ -0,0 +1,4 @@ +* +!logs +!.gitignore +!coverage-checker.php \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/composer.json b/vendor/ocramius/proxy-manager/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..fa7e22638d4a624614afd7f9b9b93bddb8bbcc06 --- /dev/null +++ b/vendor/ocramius/proxy-manager/composer.json @@ -0,0 +1,48 @@ +{ + "name": "ocramius/proxy-manager", + "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", + "type": "library", + "license": "MIT", + "homepage": "https://github.com/Ocramius/ProxyManager", + "minimum-stability": "dev", + "keywords": [ + "proxy", + "proxy pattern", + "service proxies", + "lazy loading", + "aop" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "require": { + "php": ">=5.3.3", + "zendframework/zend-code": ">2.2.5,<3.0" + }, + "require-dev": { + "ext-phar": "*", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "1.5.*" + }, + "suggest": { + "zendframework/zend-stdlib": "To use the hydrator proxy", + "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", + "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)", + "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", + "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)" + }, + "autoload": { + "psr-0": { + "ProxyManager\\": "src" + } + }, + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + } +} diff --git a/vendor/ocramius/proxy-manager/docs/access-interceptor-scope-localizer.md b/vendor/ocramius/proxy-manager/docs/access-interceptor-scope-localizer.md new file mode 100644 index 0000000000000000000000000000000000000000..a03ac09ee8f4d3bedce71bd56729cf65c7638904 --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/access-interceptor-scope-localizer.md @@ -0,0 +1,105 @@ +# Access Interceptor Scope Localizer Proxy + +An access interceptor scope localizer is a smart reference proxy that allows you to dynamically +define logic to be executed before or after any of the proxied object's methods' logic. + +It works exactly like the [access interceptor value holder](access-interceptor-value-holder.md), +with some minor differences in behavior. + +The working concept of an access interceptor scope localizer is to localize scope of a proxied object: + +```php +class Example +{ + protected $foo; + protected $bar; + protected $baz; + + public function doFoo() + { + // ... + } +} + +class ExampleProxy extends Example +{ + public function __construct(Example $example) + { + $this->foo = & $example->foo; + $this->bar = & $example->bar; + $this->baz = & $example->baz; + } + + public function doFoo() + { + return parent::doFoo(); + } +} +``` + +This allows to create a mirror copy of the real instance, where any change in the proxy or in the real +instance is reflected in both objects. + +The main advantage of this approach is that the proxy is now safe against fluent interfaces, which +would break an [access interceptor value holder](access-interceptor-value-holder.md) instead. + +## Differences with [access interceptor value holder](access-interceptor-value-holder.md): + + * It does **NOT** implement the `ProxyManager\Proxy\ValueHolderInterface`, since the proxy itself + does not keep a reference to the original object being proxied + * In all interceptor methods (see [access interceptor value holder](access-interceptor-value-holder.md)), + the `$instance` passed in is the proxy itself. There is no way to gather a reference to the + original object right now, and that's mainly to protect from misuse. + +## Known limitations + + * It is **NOT** possible to intercept access to public properties + * It is **NOT** possible to proxy interfaces, since this proxy relies on `parent::method()` calls. + Interfaces obviously don't provide a parent method implementation. + * calling `unset` on a property of an access interceptor scope localizer (or the real instance) + will cause the two objects to be un-synchronized, with possible unexpected behaviour. + * serializing or un-serializing an access interceptor scope localizer (or the real instance) + will not cause the real instance (or the proxy) to be serialized or un-serialized + * if a proxied object contains private properties, then an exception will be thrown if you use + PHP `< 5.4.0`. + +## Example + +Here's an example of how you can create and use an access interceptor scope localizer : + +```php +<?php + +use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory as Factory; + +require_once __DIR__ . '/vendor/autoload.php'; + +class Foo +{ + public function doFoo() + { + echo "Foo!\n"; + } +} + +$factory = new Factory(); + +$proxy = $factory->createProxy( + new Foo(), + array('doFoo' => function () { echo "PreFoo!\n"; }), + array('doFoo' => function () { echo "PostFoo!\n"; }) +); + +$proxy->doFoo(); +``` + +This send something like following to your output: + +``` +PreFoo! +Foo! +PostFoo! +``` + +This is pretty much the same logic that you can find +in [access interceptor value holder](access-interceptor-value-holder.md). diff --git a/vendor/ocramius/proxy-manager/docs/access-interceptor-value-holder.md b/vendor/ocramius/proxy-manager/docs/access-interceptor-value-holder.md new file mode 100644 index 0000000000000000000000000000000000000000..e47e941bb4d97c140a139d0cb44615cd1e346186 --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/access-interceptor-value-holder.md @@ -0,0 +1,108 @@ +# Access Interceptor Value Holder Proxy + +An access interceptor value holder is a smart reference proxy that allows you to dynamically +define logic to be executed before or after any of the wrapped object's methods +logic. + +It wraps around a real instance of the object to be proxied, and can be useful for things like: + + * caching execution of slow and heavy methods + * log method calls + * debugging + * event triggering + * handling of orthogonal logic, and [AOP](http://en.wikipedia.org/wiki/Aspect-oriented_programming) in general + +## Example + +Here's an example of how you can create and use an access interceptor value holder: + +```php +<?php + +use ProxyManager\Factory\AccessInterceptorValueHolderFactory as Factory; + +require_once __DIR__ . '/vendor/autoload.php'; + +class Foo +{ + public function doFoo() + { + echo "Foo!\n"; + } +} + +$factory = new Factory(); + +$proxy = $factory->createProxy( + new Foo(), + array('doFoo' => function () { echo "PreFoo!\n"; }), + array('doFoo' => function () { echo "PostFoo!\n"; }) +); + +$proxy->doFoo(); +``` + +This send something like following to your output: + +``` +PreFoo! +Foo! +PostFoo! +``` + +## Implementing pre- and post- access interceptors + +A proxy produced by the +[`ProxyManager\Factory\AccessInterceptorValueHolderFactory`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Factory/AccessInterceptorValueHolderFactory.php) +implements both the +[`ProxyManager\Proxy\ValueHolderInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/ValueHolderInterface.php) +and the +[`ProxyManager\Proxy\AccessInterceptorInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/ValueHolderInterface.php). + +Therefore, you can set an access interceptor callback by calling: + +```php +$proxy->setMethodPrefixInterceptor('methodName', function () { echo 'pre'; }); +$proxy->setMethodSuffixInterceptor('methodName', function () { echo 'post'; }); +``` + +You can also listen to public properties access by attaching interceptors to `__get`, `__set`, `__isset` and `__unset`. + +A prefix interceptor (executed before method logic) should have following signature: + +```php +/** + * @var object $proxy the proxy that intercepted the method call + * @var object $instance the wrapped instance within the proxy + * @var string $method name of the called method + * @var array $params sorted array of parameters passed to the intercepted + * method, indexed by parameter name + * @var bool $returnEarly flag to tell the interceptor proxy to return early, returning + * the interceptor's return value instead of executing the method logic + * + * @return mixed + */ +$prefixInterceptor = function ($proxy, $instance, $method, $params, & $returnEarly) {}; +``` + +A suffix interceptor (executed after method logic) should have following signature: + +```php +/** + * @var object $proxy the proxy that intercepted the method call + * @var object $instance the wrapped instance within the proxy + * @var string $method name of the called method + * @var array $params sorted array of parameters passed to the intercepted + * method, indexed by parameter name + * @var mixed $returnValue the return value of the intercepted method + * @var bool $returnEarly flag to tell the proxy to return early, returning the interceptor's + * return value instead of the value produced by the method + * + * @return mixed + */ +$suffixInterceptor = function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) {}; +``` + +## Tuning performance for production + +See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md). \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/docs/generator-strategies.md b/vendor/ocramius/proxy-manager/docs/generator-strategies.md new file mode 100644 index 0000000000000000000000000000000000000000..e4022d58e932e2281588f6dd9668ce861aca343e --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/generator-strategies.md @@ -0,0 +1,16 @@ +# Generator strategies + +ProxyManager allows you to generate classes based on generator strategies and a +given `Zend\Code\Generator\ClassGenerator` as of +the [interface of a generator strategy](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/GeneratorStrategy/GeneratorStrategyInterface.php). + +Currently, 3 generator strategies are shipped with ProxyManager: + + * [`ProxyManager\GeneratorStrategy\BaseGeneratorStrategy`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/GeneratorStrategy/BaseGeneratorStrategy.php), + which simply retrieves the string representation of the class from `ClassGenerator` + * [`ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php), + which calls `eval()` upon the generated class code before returning it. This is useful in cases + where you want to generate multiple classes at runtime + * [`ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php), + which accepts a [`ProxyManager\FileLocator\FileLocatorInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/FileLocator/FileLocatorInterface.php) + instance as constructor parameter, and based on it, writes the generated class to a file before returning its code. \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/docs/lazy-loading-ghost-object.md b/vendor/ocramius/proxy-manager/docs/lazy-loading-ghost-object.md new file mode 100644 index 0000000000000000000000000000000000000000..4c93439a06e471092c9f3639dede2a98a3b3e813 --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/lazy-loading-ghost-object.md @@ -0,0 +1,206 @@ +# Lazy Loading Ghost Object Proxies + +A lazy loading ghost object proxy is a ghost proxy that looks exactly like the real instance of the proxied subject, +but which has all properties nulled before initialization. + +## Lazy loading with the Ghost Object + +In pseudo-code, in userland, [lazy loading](http://www.martinfowler.com/eaaCatalog/lazyLoad.html) in a ghost object +looks like following: + +```php +class MyObjectProxy +{ + private $initialized = false; + private $name; + private $surname; + + public function doFoo() + { + $this->init(); + + // Perform doFoo routine using loaded variables + } + + private function init() + { + if (! $this->initialized) { + $data = some_logic_that_loads_data(); + + $this->name = $data['name']; + $this->surname = $data['surname']; + + $this->initialized = true; + } + } +} +``` + +Ghost objects work similarly to virtual proxies, but since they don't wrap around a "real" instance of the proxied +subject, they are better suited for representing dataset rows. + +## When do I use a ghost object? + +You usually need a ghost object in cases where following applies + + * you are building a small data-mapper and want to lazily load data across associations in your object graph + * you want to initialize objects representing rows in a large dataset + * you want to compare instances of lazily initialized objects without the risk of comparing a proxy with a real subject + * you are aware of the internal state of the object and are confident in working with its internals via reflection + or direct property access + +## Usage examples + +[ProxyManager](https://github.com/Ocramius/ProxyManager) provides a factory that creates lazy loading ghost objects. +To use it, follow these steps: + +First of all, define your object's logic without taking care of lazy loading: + +```php +namespace MyApp; + +class Customer +{ + private $name; + private $surname; + + // just write your business logic or generally logic + // don't worry about how complex this object will be! + // don't code lazy-loading oriented optimizations in here! + public function getName() { return $this->name; } + public function setName($name) { $this->name = (string) $name; } + public function getSurname() { return $this->surname; } + public function setSurname($surname) { $this->surname = (string) $surname; } +} +``` + +Then use the proxy manager to create a ghost object of it. +You will be responsible of setting its state during lazy loading: + +```php +namespace MyApp; + +use ProxyManager\Factory\LazyLoadingGhostFactory; +use ProxyManager\Proxy\LazyLoadingInterface; + +require_once __DIR__ . '/vendor/autoload.php'; + +$factory = new LazyLoadingGhostFactory(); +$initializer = function (LazyLoadingInterface $proxy, $method, array $parameters, & $initializer) { + $initializer = null; // disable initialization + + // load data and modify the object here + $proxy->setName('Agent'); + $proxy->setSurname('Smith'); + + return true; // confirm that initialization occurred correctly +}; + +$instance = $factory->createProxy('MyApp\Customer', $initializer); +``` + +You can now simply use your object as before: + +```php +// this will just work as before +echo $proxy->getName() . ' ' . $proxy->getSurname(); // Agent Smith +``` + +## Lazy Initialization + +As you can see, we use a closure to handle lazy initialization of the proxy instance at runtime. +The initializer closure signature for ghost objects should be as following: + +```php +/** + * @var object $proxy the instance the ghost object proxy that is being initialized + * @var string $method the name of the method that triggered lazy initialization + * @var array $parameters an ordered list of parameters passed to the method that + * triggered initialization, indexed by parameter name + * @var Closure $initializer a reference to the property that is the initializer for the + * proxy. Set it to null to disable further initialization + * + * @return bool true on success + */ +$initializer = function ($proxy, $method, $parameters, & $initializer) {}; +``` + +The initializer closure should usually be coded like following: + +```php +$initializer = function ($proxy, $method, $parameters, & $initializer) { + $initializer = null; // disable initializer for this proxy instance + + // modify the object with loaded data + $proxy->setFoo(/* ... */); + $proxy->setBar(/* ... */); + + return true; // report success +}; +``` + +The +[`ProxyManager\Factory\LazyLoadingGhostFactory`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Factory/LazyLoadingGhostFactory.php) +produces proxies that implement both the +[`ProxyManager\Proxy\GhostObjectInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/GhostObjectInterface.php) +and the +[`ProxyManager\Proxy\LazyLoadingInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/LazyLoadingInterface.php). + +At any point in time, you can set a new initializer for the proxy: + +```php +$proxy->setProxyInitializer($initializer); +``` + +In your initializer, you **MUST** turn off any further initialization: + +```php +$proxy->setProxyInitializer(null); +``` + +or + +```php +$initializer = null; // if you use the initializer passed by reference to the closure +``` + +## Triggering Initialization + +A lazy loading ghost object is initialized whenever you access any property or method of it. +Any of the following interactions would trigger lazy initialization: + +```php +// calling a method +$proxy->someMethod(); + +// reading a property +echo $proxy->someProperty; + +// writing a property +$proxy->someProperty = 'foo'; + +// checking for existence of a property +isset($proxy->someProperty); + +// removing a property +unset($proxy->someProperty); + +// cloning the entire proxy +clone $proxy; + +// serializing the proxy +$unserialized = serialize(unserialize($proxy)); +``` + +Remember to call `$proxy->setProxyInitializer(null);` to disable initialization of your proxy, or it will happen more +than once. + +## Proxying interfaces + +You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the +methods defined by the interface itself, even if the `wrappedObject` implements more methods. This will anyway save +some memory since the proxy won't contain any properties. + +## Tuning performance for production + +See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md). diff --git a/vendor/ocramius/proxy-manager/docs/lazy-loading-value-holder.md b/vendor/ocramius/proxy-manager/docs/lazy-loading-value-holder.md new file mode 100644 index 0000000000000000000000000000000000000000..c6b503e988fef51e28cdeca7d03b04ac37a6eb2b --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/lazy-loading-value-holder.md @@ -0,0 +1,202 @@ +# Lazy Loading Value Holder Proxy + +A lazy loading value holder proxy is a virtual proxy that wraps and lazily initializes a "real" instance of the proxied +class. + +## What is lazy loading? + +In pseudo-code, in userland, [lazy loading](http://www.martinfowler.com/eaaCatalog/lazyLoad.html) looks like following: + +```php +class MyObjectProxy +{ + private $wrapped; + + public function doFoo() + { + $this->init(); + + return $this->wrapped->doFoo(); + } + + private function init() + { + if (null === $this->wrapped) { + $this->wrapped = new MyObject(); + } + } +} +``` + +This code is problematic, and adds a lot of complexity that makes your unit tests' code even worse. + +Also, this kind of usage often ends up in coupling your code with a particular +[Dependency Injection Container](http://martinfowler.com/articles/injection.html) +or a framework that fetches dependencies for you. +That way, further complexity is introduced, and some problems related +with service location raise, as I've explained +[in this article](http://ocramius.github.com/blog/zf2-and-symfony-service-proxies-with-doctrine-proxies/). + +Lazy loading value holders abstract this logic for you, hiding your complex, slow, performance-impacting objects behind +tiny wrappers that have their same API, and that get initialized at first usage. + +## When do I use a lazy value holder? + +You usually need a lazy value holder in cases where following applies + + * your object takes a lot of time and memory to be initialized (with all dependencies) + * your object is not always used, and the instantiation overhead can be avoided + +## Usage examples + +[ProxyManager](https://github.com/Ocramius/ProxyManager) provides a factory that eases instantiation of lazy loading +value holders. To use it, follow these steps: + +First of all, define your object's logic without taking care of lazy loading: + +```php +namespace MyApp; + +class HeavyComplexObject +{ + public function __construct() + { + // just write your business logic + // don't worry about how heavy initialization of this will be! + } + + public function doFoo() { + echo "OK!" + } +} +``` + +Then use the proxy manager to create a lazy version of the object (as a proxy): + +```php +namespace MyApp; + +use ProxyManager\Factory\LazyLoadingValueHolderFactory; +use ProxyManager\Proxy\LazyLoadingInterface; + +require_once __DIR__ . '/vendor/autoload.php'; + +$factory = new LazyLoadingValueHolderFactory(); +$initializer = function (& $wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, & $initializer) { + $initializer = null; // disable initialization + $wrappedObject = new HeavyComplexObject(); // fill your object with values here + + return true; // confirm that initialization occurred correctly +}; + +$instance = $factory->createProxy('MyApp\HeavyComplexObject', $initializer); +``` + +You can now simply use your object as before: + +```php +// this will just work as before +$proxy->doFoo(); // OK! +``` + +## Lazy Initialization + +As you can see, we use a closure to handle lazy initialization of the proxy instance at runtime. +The initializer closure signature should be as following: + +```php +/** + * @var object $wrappedObject the instance (passed by reference) of the wrapped object, + * set it to your real object + * @var object $proxy the instance proxy that is being initialized + * @var string $method the name of the method that triggered lazy initialization + * @var string $parameters an ordered list of parameters passed to the method that + * triggered initialization, indexed by parameter name + * @var Closure $initializer a reference to the property that is the initializer for the + * proxy. Set it to null to disable further initialization + * + * @return bool true on success + */ +$initializer = function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {}; +``` + +The initializer closure should usually be coded like following: + +```php +$initializer = function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) { + $newlyCreatedObject = new Foo(); // instantiation logic + $newlyCreatedObject->setBar('baz') // instantiation logic + $newlyCreatedObject->setBat('bam') // instantiation logic + + $wrappedObject = $newlyCreatedObject; // set wrapped object in the proxy + $initializer = null; // disable initializer + + return true; // report success +}; +``` + +The +[`ProxyManager\Factory\LazyLoadingValueHolderFactory`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Factory/LazyLoadingValueHolderFactory.php) +produces proxies that implement both the +[`ProxyManager\Proxy\ValueHolderInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/ValueHolderInterface.php) +and the +[`ProxyManager\Proxy\LazyLoadingInterface`](https://github.com/Ocramius/ProxyManager/blob/master/src/ProxyManager/Proxy/LazyLoadingInterface.php). + +At any point in time, you can set a new initializer for the proxy: + +```php +$proxy->setProxyInitializer($initializer); +``` + +In your initializer, you currently **MUST** turn off any further initialization: + +```php +$proxy->setProxyInitializer(null); +``` + +or + +```php +$initializer = null; // if you use the initializer by reference +``` + +## Triggering Initialization + +A lazy loading proxy is initialized whenever you access any property or method of it. +Any of the following interactions would trigger lazy initialization: + +```php +// calling a method +$proxy->someMethod(); + +// reading a property +echo $proxy->someProperty; + +// writing a property +$proxy->someProperty = 'foo'; + +// checking for existence of a property +isset($proxy->someProperty); + +// removing a property +unset($proxy->someProperty); + +// cloning the entire proxy +clone $proxy; + +// serializing the proxy +$unserialized = serialize(unserialize($proxy)); +``` + +Remember to call `$proxy->setProxyInitializer(null);` to disable initialization of your proxy, or it will happen more +than once. + +## Proxying interfaces + +You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the +methods defined by the interface itself, even if the `wrappedObject` implements more methods. This will anyway save +some memory since the proxy won't contain useless inherited properties. + +## Tuning performance for production + +See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md). diff --git a/vendor/ocramius/proxy-manager/docs/null-object.md b/vendor/ocramius/proxy-manager/docs/null-object.md new file mode 100644 index 0000000000000000000000000000000000000000..aca1739ca57e9b7616cd1dee57d2bca84dc51374 --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/null-object.md @@ -0,0 +1,89 @@ +# Null Object Proxy + +A Null Object proxy is a [null object pattern](http://en.wikipedia.org/wiki/Null_Object_pattern) implementation. +The proxy factory creates a new object with defined neutral behavior based on an other object, class name or interface. + +## What is null object proxy ? + +In your application, when you can't return the object related to the request, the consumer of the model must check +for the return value and handle the failing condition gracefully, thus generating an explosion of conditionals throughout your code. +Fortunately, this seemingly-tangled situation can be sorted out simply by creating a polymorphic implementation of the +domain object, which would implement the same interface as the one of the object in question, only that its methods +wouldn’t do anything, therefore offloading client code from doing repetitive checks for ugly null values when the operation + is executed. + +## Usage examples + +```php +class UserMapper +{ + private $adapter; + + public function __construct(DatabaseAdapterInterface $adapter) { + $this->adapter = $adapter; + } + + public function fetchById($id) { + $this->adapter->select("users", array("id" => $id)); + if (!$row = $this->adapter->fetch()) { + return null; + } + return $this->createUser($row); + } + + private function createUser(array $row) { + $user = new Entity\User($row["name"], $row["email"]); + $user->setId($row["id"]); + return $user; + } +} +``` + +If you want to remove conditionals from client code, you need to have a version of the entity conforming to the corresponding +interface. With the Null Object Proxy, you can build this object : + +```php +$factory = new \ProxyManager\Factory\NullObjectFactory(); + +$nullUser = $factory->createProxy('Entity\User'); + +var_dump($nullUser->getName()); // empty return +``` + +You can now return a valid entity : + +```php +class UserMapper +{ + private $adapter; + + public function __construct(DatabaseAdapterInterface $adapter) { + $this->adapter = $adapter; + } + + public function fetchById($id) { + $this->adapter->select("users", array("id" => $id)); + return $this->createUser($this->adapter->fetch()); + } + + private function createUser($row) { + if (!$row) { + $factory = new \ProxyManager\Factory\NullObjectFactory(); + + return $factory->createProxy('Entity\User'); + } + $user = new Entity\User($row["name"], $row["email"]); + $user->setId($row["id"]); + return $user; + } +} +``` + +## Proxying interfaces + +You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the +methods defined by the interface itself, and like with the object, the methods are empty. + +## Tuning performance for production + +See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md). diff --git a/vendor/ocramius/proxy-manager/docs/remote-object.md b/vendor/ocramius/proxy-manager/docs/remote-object.md new file mode 100644 index 0000000000000000000000000000000000000000..1e040bdd38c41a4f9a06afc6eb4ec2d096424ce1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/remote-object.md @@ -0,0 +1,100 @@ +# Remote Object Proxy + +The remote object implementation is a mechanism that enables an local object to control an other object on an other server. +Each call method on the local object will do a network call to get information or execute operations on the remote object. + +## What is remote object proxy ? + +A remote object is based on an interface. The remote interface defines the API that a consumer can call. This interface +must be implemented both by the client and the RPC server. + +## Adapters + +ZendFramework's RPC components (XmlRpc, JsonRpc & Soap) can be used easily with the remote object. +You will need to require the one you need via composer, though: + +```sh +$ php composer.phar require zendframework/zend-xmlrpc:2.* +$ php composer.phar require zendframework/zend-json:2.* +$ php composer.phar require zendframework/zend-soap:2.* +``` + +ProxyManager comes with 3 adapters: + + * `ProxyManager\Factory\RemoteObject\Adapter\XmlRpc` + * `ProxyManager\Factory\RemoteObject\Adapter\JsonRpc` + * `ProxyManager\Factory\RemoteObject\Adapter\Soap` + +## Usage examples + +RPC server side code (`xmlrpc.php` in your local webroot): + +```php +interface FooServiceInterface +{ + public function foo(); +} + +class Foo implements FooServiceInterface +{ + /** + * Foo function + * @return string + */ + public function foo() + { + return 'bar remote'; + } +} + +$server = new Zend\XmlRpc\Server(); +$server->setClass('Foo', 'FooServiceInterface'); // my FooServiceInterface implementation +$server->handle(); +``` + +Client side code (proxy) : + +```php + +interface FooServiceInterface +{ + public function foo(); +} + +$factory = new \ProxyManager\Factory\RemoteObjectFactory( + new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc( + new \Zend\XmlRpc\Client('https://localhost/xmlrpc.php') + ) +); + +$proxy = $factory->createProxy('FooServiceInterface'); + +var_dump($proxy->foo()); // "bar remote" +``` + +## Implementing custom adapters + +Your adapters must implement `ProxyManager\Factory\RemoteObject\AdapterInterface` : + +```php +interface AdapterInterface +{ + /** + * Call remote object + * + * @param string $wrappedClass + * @param string $method + * @param array $params + * + * @return mixed + */ + public function call($wrappedClass, $method, array $params = array()); +} +``` + +It is very easy to create your own implementation (for RESTful web services, for example). Simply pass +your own adapter instance to your factory at construction time + +## Tuning performance for production + +See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md). diff --git a/vendor/ocramius/proxy-manager/docs/tuning-for-production.md b/vendor/ocramius/proxy-manager/docs/tuning-for-production.md new file mode 100644 index 0000000000000000000000000000000000000000..48ccf9f6e051c9ba8eaa23d0159193092c898eab --- /dev/null +++ b/vendor/ocramius/proxy-manager/docs/tuning-for-production.md @@ -0,0 +1,24 @@ +## Tuning the ProxyManager for production + +By default, all proxy factories generate the required proxy classes at runtime. + +Proxy generation causes I/O operations and uses a lot of reflection, so be sure to have +generated all of your proxies **before deploying your code on a live system**, or you +may experience poor performance. + +You can configure ProxyManager so that it will try autoloading the proxies first. +Generating them "bulk" is not yet implemented: + +```php +$config = new \ProxyManager\Configuration(); +$config->setProxiesTargetDir(__DIR__ . '/my/generated/classes/cache/dir'); + +// then register the autoloader +spl_autoload_register($config->getProxyAutoloader()); +``` + +Generating a classmap with all your proxy classes in it will also work perfectly. + +Please note that all the currently implemented `ProxyManager\Factory\*` classes accept +a `ProxyManager\Configuration` object as optional constructor parameter. This allows for +fine-tuning of ProxyManager according to your needs. diff --git a/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php b/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php new file mode 100644 index 0000000000000000000000000000000000000000..eb1da5b7480586dea9abdef0abc1cb8d74978781 --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php @@ -0,0 +1,38 @@ +<?php +/** + * This example demonstrates how an access interceptor scope localizer + * (which is a specific type of smart reference) is safe to use to + * proxy fluent interfaces. + */ + +require_once __DIR__ . '/../vendor/autoload.php'; + +use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory; + +class FluentCounter +{ + public $counter = 0; + + /** @return FluentCounter */ + public function fluentMethod() + { + $this->counter += 1; + + return $this; + } +} + +$factory = new AccessInterceptorScopeLocalizerFactory(); +$foo = new FluentCounter(); + +/* @var $proxy FluentCounter */ +$proxy = $factory->createProxy( + $foo, + array('fluentMethod' => function ($proxy) { echo "pre-fluentMethod #{$proxy->counter}!\n"; }), + array('fluentMethod' => function ($proxy) { echo "post-fluentMethod #{$proxy->counter}!\n"; }) +); + +$proxy->fluentMethod()->fluentMethod()->fluentMethod()->fluentMethod(); + +echo 'The proxy counter is now at ' . $proxy->counter . "\n"; +echo 'The real instance counter is now at ' . $foo->counter . "\n"; diff --git a/vendor/ocramius/proxy-manager/examples/ghost-object.php b/vendor/ocramius/proxy-manager/examples/ghost-object.php new file mode 100644 index 0000000000000000000000000000000000000000..b4ec216611a35fb126f49777e1891341b858a441 --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/ghost-object.php @@ -0,0 +1,46 @@ +<?php + +require_once __DIR__ . '/../vendor/autoload.php'; + +use ProxyManager\Factory\LazyLoadingGhostFactory; + +class Foo +{ + private $foo; + + public function __construct() + { + sleep(5); + } + + public function setFoo($foo) + { + $this->foo = (string) $foo; + } + + public function getFoo() + { + return $this->foo; + } +} + +$startTime = microtime(true); +$factory = new LazyLoadingGhostFactory(); + +for ($i = 0; $i < 1000; $i += 1) { + $proxy = $factory->createProxy( + 'Foo', + function ($proxy, $method, $parameters, & $initializer) { + $initializer = null; + $proxy->setFoo('Hello World!'); + + return true; + } + ); +} + +var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime)); + +echo $proxy->getFoo() . "\n"; + +var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime)); diff --git a/vendor/ocramius/proxy-manager/examples/remote-proxy.php b/vendor/ocramius/proxy-manager/examples/remote-proxy.php new file mode 100644 index 0000000000000000000000000000000000000000..97025fca0ffcfa60a1eca822191f56e705994d31 --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/remote-proxy.php @@ -0,0 +1,36 @@ +<?php + +require_once __DIR__ . '/../vendor/autoload.php'; + +use ProxyManager\Factory\RemoteObject\Adapter\XmlRpc; +use ProxyManager\Factory\RemoteObjectFactory; +use Zend\XmlRpc\Client; + +if (! class_exists('Zend\XmlRpc\Client')) { + echo "This example needs Zend\\XmlRpc\\Client to run. \n In order to install it, " + . "please run following:\n\n" + . "\$ php composer.phar require zendframework/zend-xmlrpc:2.*\n\n"; + + exit(2); +} + +class Foo +{ + public function bar() + { + return 'bar local!'; + } +} + +$factory = new RemoteObjectFactory( + new XmlRpc(new Client('http://localhost:9876/remote-proxy/remote-proxy-server.php')) +); +$proxy = $factory->createProxy('Foo'); + +try { + var_dump($proxy->bar()); // bar remote ! +} catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $error) { + echo "To run this example, please following before:\n\n\$ php -S localhost:9876 -t \"" . __DIR__ . "\"\n"; + + exit(2); +} diff --git a/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php b/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php new file mode 100644 index 0000000000000000000000000000000000000000..81a742f086b7dbc1c41e6c6d28d1d925e38f60a2 --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php @@ -0,0 +1,20 @@ +<?php + +use Zend\XmlRpc\Server; + +require_once __DIR__ . '/../../vendor/autoload.php'; + +class Foo +{ + public function bar() + { + return 'bar remote!'; + } +} + +$server = new Server(); + +$server->setClass(new Foo(), 'Foo'); +$server->setReturnResponse(false); + +$server->handle(); diff --git a/vendor/ocramius/proxy-manager/examples/smart-reference.php b/vendor/ocramius/proxy-manager/examples/smart-reference.php new file mode 100644 index 0000000000000000000000000000000000000000..8c00a3a1caa83379839b0ccabb86633392c6f56e --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/smart-reference.php @@ -0,0 +1,23 @@ +<?php + +require_once __DIR__ . '/../vendor/autoload.php'; + +use ProxyManager\Factory\AccessInterceptorValueHolderFactory; + +class Foo +{ + public function doFoo() + { + echo "Foo!\n"; + } +} + +$factory = new AccessInterceptorValueHolderFactory(); + +$proxy = $factory->createProxy( + new Foo(), + array('doFoo' => function () { echo "pre-foo!\n"; }), + array('doFoo' => function () { echo "post-foo!\n"; }) +); + +$proxy->doFoo(); diff --git a/vendor/ocramius/proxy-manager/examples/virtual-proxy.php b/vendor/ocramius/proxy-manager/examples/virtual-proxy.php new file mode 100644 index 0000000000000000000000000000000000000000..7ee6b2ee3e583c8a0a734f8be82486bfc21be1fc --- /dev/null +++ b/vendor/ocramius/proxy-manager/examples/virtual-proxy.php @@ -0,0 +1,39 @@ +<?php + +require_once __DIR__ . '/../vendor/autoload.php'; + +use ProxyManager\Factory\LazyLoadingValueHolderFactory; + +class Foo +{ + public function __construct() + { + sleep(5); + } + + public function doFoo() + { + echo "Foo!"; + } +} + +$startTime = microtime(true); +$factory = new LazyLoadingValueHolderFactory(); + +for ($i = 0; $i < 1000; $i += 1) { + $proxy = $factory->createProxy( + 'Foo', + function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) { + $initializer = null; + $wrappedObject = new Foo(); + + return true; + } + ); +} + +var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime)); + +$proxy->doFoo(); + +var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime)); diff --git a/vendor/ocramius/proxy-manager/phpdox.xml.dist b/vendor/ocramius/proxy-manager/phpdox.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..c610db976ac8410df19205df29395fc9c38783a5 --- /dev/null +++ b/vendor/ocramius/proxy-manager/phpdox.xml.dist @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<phpdox xmlns="http://phpdox.de/config" silent="false"> + <project + name="ProxyManager" + source="src" + workdir="build/phpdox" + > + <collector publiconly="false"> + <include mask="*.php" /> + </collector> + + <generator output="build"> + <build engine="html" enabled="true" output="api"/> + </generator> + </project> +</phpdox> \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/phpmd.xml.dist b/vendor/ocramius/proxy-manager/phpmd.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..4a9f7df5bfe83850f26a112450f1b68408ea7b0b --- /dev/null +++ b/vendor/ocramius/proxy-manager/phpmd.xml.dist @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<ruleset + name="ProxyManager rules" + xmlns="http://pmd.sf.net/ruleset/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" + xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" +> + <rule ref="rulesets/codesize.xml"/> + <rule ref="rulesets/unusedcode.xml"/> + <rule ref="rulesets/design.xml"> + <!-- eval is needed to generate runtime classes --> + <exclude name="EvalExpression"/> + </rule> + <rule ref="rulesets/naming.xml"/> +</ruleset> \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/phpunit.xml.dist b/vendor/ocramius/proxy-manager/phpunit.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..94f3665c6c5221e8142108bb6e3d3dedfd3b6a61 --- /dev/null +++ b/vendor/ocramius/proxy-manager/phpunit.xml.dist @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<phpunit + bootstrap="./tests/Bootstrap.php" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + verbose="true" + stopOnFailure="false" + processIsolation="false" + backupGlobals="false" + syntaxCheck="true" +> + <testsuite name="ProxyManager tests"> + <directory>./tests/ProxyManagerTest</directory> + </testsuite> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">./src</directory> + </whitelist> + </filter> +</phpunit> diff --git a/vendor/ocramius/proxy-manager/proxy-manager.png b/vendor/ocramius/proxy-manager/proxy-manager.png new file mode 100644 index 0000000000000000000000000000000000000000..0ab1c6e2c5da324a9a4729aa24e591901b819173 Binary files /dev/null and b/vendor/ocramius/proxy-manager/proxy-manager.png differ diff --git a/vendor/ocramius/proxy-manager/proxy-manager.svg b/vendor/ocramius/proxy-manager/proxy-manager.svg new file mode 100644 index 0000000000000000000000000000000000000000..f74aa910cec9271422cf29affaec25cb041aa782 --- /dev/null +++ b/vendor/ocramius/proxy-manager/proxy-manager.svg @@ -0,0 +1,346 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many individuals +and is licensed under the MIT license. +--> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="378.25879" + height="241.71141" + id="svg9092" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="logo_DEF.svg"> + <title + id="title5929">Logo - Ocramius Proxy Manager</title> + <defs + id="defs9094"> + <linearGradient + id="linearGradient3798"> + <stop + id="stop3800" + offset="0" + style="stop-color:#545454;stop-opacity:0;" /> + <stop + id="stop3802" + offset="1" + style="stop-color:#585858;stop-opacity:1;" /> + </linearGradient> + <linearGradient + id="linearGradient3788"> + <stop + style="stop-color:#585858;stop-opacity:1;" + offset="0" + id="stop3790" /> + <stop + style="stop-color:#585858;stop-opacity:0;" + offset="1" + id="stop3792" /> + </linearGradient> + <marker + inkscape:stockid="DotL" + orient="auto" + refY="0" + refX="0" + id="DotL" + style="overflow:visible"> + <path + id="path3987" + d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z" + style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt" + transform="matrix(0.8,0,0,0.8,5.92,0.8)" + inkscape:connector-curvature="0" /> + </marker> + <clipPath + clipPathUnits="userSpaceOnUse" + id="clipPath3920"> + <path + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m -21.125,46.0625 c -1.315071,0 -2.375,1.059929 -2.375,2.375 l 0,262.09375 c 0,1.31507 1.059929,2.375 2.375,2.375 l 292.15625,0 c 1.31507,0 2.375,-1.05993 2.375,-2.375 l 0,-262.09375 c 0,-1.315071 -1.05993,-2.375 -2.375,-2.375 l -292.15625,0 z m 111.28125,68.34375 68.625,0 33.9375,58.75 -33.9375,60.15625 -68.625,0 L 55.8125,173.875 90.15625,114.40625 z" + id="path3922" + inkscape:connector-curvature="0" /> + </clipPath> + <clipPath + clipPathUnits="userSpaceOnUse" + id="clipPath3924"> + <path + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m -21.125,46.0625 c -1.315071,0 -2.375,1.059929 -2.375,2.375 l 0,262.09375 c 0,1.31507 1.059929,2.375 2.375,2.375 l 292.15625,0 c 1.31507,0 2.375,-1.05993 2.375,-2.375 l 0,-262.09375 c 0,-1.315071 -1.05993,-2.375 -2.375,-2.375 l -292.15625,0 z m 111.28125,68.34375 68.625,0 33.9375,58.75 -33.9375,60.15625 -68.625,0 L 55.8125,173.875 90.15625,114.40625 z" + id="path3926" + inkscape:connector-curvature="0" /> + </clipPath> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.53214715" + inkscape:cx="-234.17911" + inkscape:cy="-96.916153" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:snap-bbox="true" + inkscape:bbox-nodes="true" + inkscape:bbox-paths="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="true" + inkscape:object-paths="true" + inkscape:object-nodes="true" + inkscape:snap-smooth-nodes="true" + inkscape:snap-midpoints="true" + inkscape:snap-intersection-paths="true" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1366" + inkscape:window-height="746" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true" + inkscape:guide-bbox="true" + inkscape:snap-page="false" + inkscape:snap-grids="false" + inkscape:snap-to-guides="false" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" /> + <metadata + id="metadata9097"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Logo - Ocramius Proxy Manager</dc:title> + <dc:date>November 2013</dc:date> + <dc:creator> + <cc:Agent> + <dc:title>Maestro Pivetta</dc:title> + </cc:Agent> + </dc:creator> + <dc:rights> + <cc:Agent> + <dc:title>MIT</dc:title> + </cc:Agent> + </dc:rights> + <dc:publisher> + <cc:Agent> + <dc:title>Marco Pivetta</dc:title> + </cc:Agent> + </dc:publisher> + <dc:coverage>Logo</dc:coverage> + <dc:subject> + <rdf:Bag /> + </dc:subject> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:groupmode="layer" + id="layer4" + inkscape:label="Layer" + transform="translate(-18.781538,-53.01103)" /> + <g + inkscape:groupmode="layer" + id="layer3" + inkscape:label="low" + style="display:inline" + transform="translate(-18.781538,-53.01103)"> + <path + style="fill:none;stroke:#787878;stroke-width:14.46100044;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 222.81682,230.67946 -98.45761,-56.81264 0,0 -98.347172,56.81265" + id="path3882" + inkscape:connector-curvature="0" + clip-path="url(#clipPath3924)" /> + <path + style="fill:none;stroke:#787878;stroke-width:14.46100044;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 124.35921,173.86682 0.0552,-113.62529" + id="path3785" + inkscape:connector-curvature="0" + clip-path="url(#clipPath3920)" /> + </g> + <g + inkscape:label="base" + inkscape:groupmode="layer" + id="layer1" + style="display:inline" + transform="translate(-18.781538,-53.01103)"> + <path + style="fill:#1a1a1a;fill-opacity:1;stroke:#1e1e1e;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" + d="m 193.11566,173.86682 59.40231,0" + id="path12544" + inkscape:connector-curvature="0" /> + <path + sodipodi:type="star" + style="fill:none;stroke:#787878;stroke-width:35;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path9100" + sodipodi:sides="6" + sodipodi:cx="225.71429" + sodipodi:cy="372.36218" + sodipodi:r1="275.01392" + sodipodi:r2="238.16904" + sodipodi:arg1="-0.52359878" + sodipodi:arg2="0" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 463.88333,234.85522 0,275.01392 L 225.7143,647.3761 -12.454743,509.86914 -12.454744,234.85523 225.71429,97.348267 z" + transform="matrix(0.41316197,0,0,0.41316197,31.157864,20.020928)" + clip-path="none" /> + <path + inkscape:connector-curvature="0" + id="path12548" + d="m 154.2419,173.86682 59.40231,0" + style="fill:#1a1a1a;fill-opacity:1;stroke:#1e1e1e;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" /> + <g + id="g5895"> + <path + id="path9626" + sodipodi:type="star" + style="fill:none;stroke:#de8c33;stroke-width:57.93455887;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:40" + sodipodi:sides="6" + sodipodi:cx="225.71429" + sodipodi:cy="372.36218" + sodipodi:r1="275.01392" + sodipodi:r2="238.16904" + sodipodi:arg1="-0.52359878" + sodipodi:arg2="0" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 463.88333,234.85522 0,275.01392 L 225.7143,647.3761 -12.454743,509.86914 -12.454744,234.85523 225.71429,97.348267 z" + transform="matrix(0.21616793,0.12480461,-0.12480461,0.21616793,122.14997,65.203872)" /> + <g + style="stroke:#de8c33;stroke-width:4.13199997;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="g3786"> + <path + inkscape:connector-curvature="0" + style="fill:none;stroke:#de8c33;stroke-width:4.13199997;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:78.84750349" + d="M 158.79266,233.31601 124.46965,173.86682" + id="path9636" /> + <path + style="fill:none;stroke:#de8c33;stroke-width:4.13199997;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:78.84750349" + d="m 124.35921,173.86682 34.43344,-59.44919" + id="path3884" + inkscape:connector-curvature="0" /> + <path + style="fill:none;stroke:#de8c33;stroke-width:4.13199997;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:78.84750349" + d="m 55.823635,173.86682 68.701185,0.0956" + id="path3886" + inkscape:connector-curvature="0" /> + </g> + </g> + <g + id="g5920" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"> + <path + d="m 163.10781,173.47926 c 0,2.16916 -1.75845,3.92761 -3.9276,3.92761 -2.16916,0 -3.92761,-1.75845 -3.92761,-3.92761 0,-2.16915 1.75845,-3.9276 3.92761,-3.9276 2.16915,0 3.9276,1.75845 3.9276,3.9276 z" + sodipodi:ry="3.9276054" + sodipodi:rx="3.9276054" + sodipodi:cy="173.47926" + sodipodi:cx="159.18021" + id="path5902" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /> + <path + transform="translate(21.523427,0.38755669)" + sodipodi:type="arc" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path5904" + sodipodi:cx="159.18021" + sodipodi:cy="173.47926" + sodipodi:rx="3.9276054" + sodipodi:ry="3.9276054" + d="m 163.10781,173.47926 c 0,2.16916 -1.75845,3.92761 -3.9276,3.92761 -2.16916,0 -3.92761,-1.75845 -3.92761,-3.92761 0,-2.16915 1.75845,-3.9276 3.92761,-3.9276 2.16915,0 3.9276,1.75845 3.9276,3.9276 z" /> + <path + d="m 163.10781,173.47926 c 0,2.16916 -1.75845,3.92761 -3.9276,3.92761 -2.16916,0 -3.92761,-1.75845 -3.92761,-3.92761 0,-2.16915 1.75845,-3.9276 3.92761,-3.9276 2.16915,0 3.9276,1.75845 3.9276,3.9276 z" + sodipodi:ry="3.9276054" + sodipodi:rx="3.9276054" + sodipodi:cy="173.47926" + sodipodi:cx="159.18021" + id="path5906" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" + transform="translate(43.326071,0.38755669)" /> + <path + transform="translate(64.819008,1.9726929e-6)" + sodipodi:type="arc" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path5908" + sodipodi:cx="159.18021" + sodipodi:cy="173.47926" + sodipodi:rx="3.9276054" + sodipodi:ry="3.9276054" + d="m 163.10781,173.47926 c 0,2.16916 -1.75845,3.92761 -3.9276,3.92761 -2.16916,0 -3.92761,-1.75845 -3.92761,-3.92761 0,-2.16915 1.75845,-3.9276 3.92761,-3.9276 2.16915,0 3.9276,1.75845 3.9276,3.9276 z" /> + <path + d="m 163.10781,173.47926 c 0,2.16916 -1.75845,3.92761 -3.9276,3.92761 -2.16916,0 -3.92761,-1.75845 -3.92761,-3.92761 0,-2.16915 1.75845,-3.9276 3.92761,-3.9276 2.16915,0 3.9276,1.75845 3.9276,3.9276 z" + sodipodi:ry="3.9276054" + sodipodi:rx="3.9276054" + sodipodi:cy="173.47926" + sodipodi:cx="159.18021" + id="path5910" + style="fill:#3c3c3c;fill-opacity:1;stroke:#3c3c3c;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" + transform="translate(86.425344,1.9726929e-6)" /> + </g> + </g> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="ext cube" + style="display:inline" + transform="translate(-18.781538,-53.01103)"> + <g + id="g5891" + style="stroke:#3c3c3c;stroke-opacity:1"> + <path + transform="matrix(0.21616793,0.12480461,-0.12480461,0.21616793,318.8443,65.203877)" + d="m 463.88333,234.85522 0,275.01392 L 225.7143,647.3761 -12.454743,509.86914 -12.454744,234.85523 225.71429,97.348267 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="0" + sodipodi:arg1="-0.52359878" + sodipodi:r2="238.16904" + sodipodi:r1="275.01392" + sodipodi:cy="372.36218" + sodipodi:cx="225.71429" + sodipodi:sides="6" + id="path9660" + style="fill:none;stroke:#3c3c3c;stroke-width:57.93323135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + <path + id="path9662" + style="fill:none;stroke:#3c3c3c;stroke-width:4.13161993;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 252.51797,173.86682 68.64601,0 34.323,-59.44919 m 10e-6,118.89838 -34.32301,-59.44919" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + </g> + </g> +</svg> diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/Autoloader.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/Autoloader.php new file mode 100644 index 0000000000000000000000000000000000000000..91a6fc2823f23822d6eea273858325182e19b145 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/Autoloader.php @@ -0,0 +1,69 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Autoloader; + +use ProxyManager\FileLocator\FileLocatorInterface; +use ProxyManager\Inflector\ClassNameInflectorInterface; + +/** + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Autoloader implements AutoloaderInterface +{ + /** + * @var \ProxyManager\FileLocator\FileLocatorInterface + */ + protected $fileLocator; + + /** + * @var \ProxyManager\Inflector\ClassNameInflectorInterface + */ + protected $classNameInflector; + + /** + * @param \ProxyManager\FileLocator\FileLocatorInterface $fileLocator + * @param \ProxyManager\Inflector\ClassNameInflectorInterface $classNameInflector + */ + public function __construct(FileLocatorInterface $fileLocator, ClassNameInflectorInterface $classNameInflector) + { + $this->fileLocator = $fileLocator; + $this->classNameInflector = $classNameInflector; + } + + /** + * {@inheritDoc} + */ + public function __invoke($className) + { + if (class_exists($className, false) || ! $this->classNameInflector->isProxyClassName($className)) { + return false; + } + + $file = $this->fileLocator->getProxyFileName($className); + + if (! file_exists($file)) { + return false; + } + + return (bool) require_once $file; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/AutoloaderInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/AutoloaderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..9670f98b826eb491e32d3773d3d146563d4801cc --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Autoloader/AutoloaderInterface.php @@ -0,0 +1,37 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Autoloader; + +/** + * Basic autoloader utilities required to work with proxy files + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface AutoloaderInterface +{ + /** + * Callback to allow the object to be handled as autoloader - tries to autoload the given class name + * + * @param string $className + * + * @return bool + */ + public function __invoke($className); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php new file mode 100644 index 0000000000000000000000000000000000000000..486ff5dd83a058352740ac0d30e45157c28093d1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php @@ -0,0 +1,179 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager; + +use ProxyManager\Autoloader\AutoloaderInterface; +use ProxyManager\Autoloader\Autoloader; +use ProxyManager\FileLocator\FileLocator; +use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy; +use ProxyManager\GeneratorStrategy\GeneratorStrategyInterface; +use ProxyManager\Inflector\ClassNameInflectorInterface; +use ProxyManager\Inflector\ClassNameInflector; + +/** + * Base configuration class for the proxy manager - serves as micro disposable DIC/facade + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Configuration +{ + const DEFAULT_PROXY_NAMESPACE = 'ProxyManagerGeneratedProxy'; + + /** + * @var string|null + */ + protected $proxiesTargetDir; + + /** + * @var string + */ + protected $proxiesNamespace = self::DEFAULT_PROXY_NAMESPACE; + + /** + * @var \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface|null + */ + protected $generatorStrategy; + + /** + * @var callable|null + */ + protected $proxyAutoloader; + + /** + * @var \ProxyManager\Inflector\ClassNameInflectorInterface|null + */ + protected $classNameInflector; + + /** + * @deprecated deprecated since version 0.5 + */ + public function setAutoGenerateProxies() + { + } + + /** + * @return bool + * + * @deprecated deprecated since version 0.5 + */ + public function doesAutoGenerateProxies() + { + return true; + } + + /** + * @param \ProxyManager\Autoloader\AutoloaderInterface $proxyAutoloader + */ + public function setProxyAutoloader(AutoloaderInterface $proxyAutoloader) + { + $this->proxyAutoloader = $proxyAutoloader; + } + + /** + * @return \ProxyManager\Autoloader\AutoloaderInterface + */ + public function getProxyAutoloader() + { + if (null === $this->proxyAutoloader) { + $this->proxyAutoloader = new Autoloader( + new FileLocator($this->getProxiesTargetDir()), + $this->getClassNameInflector() + ); + } + + return $this->proxyAutoloader; + } + + /** + * @param string $proxiesNamespace + */ + public function setProxiesNamespace($proxiesNamespace) + { + $this->proxiesNamespace = $proxiesNamespace; + } + + /** + * @return string + */ + public function getProxiesNamespace() + { + return $this->proxiesNamespace; + } + + /** + * @param string $proxiesTargetDir + */ + public function setProxiesTargetDir($proxiesTargetDir) + { + $this->proxiesTargetDir = (string) $proxiesTargetDir; + } + + /** + * @return null|string + */ + public function getProxiesTargetDir() + { + if (null === $this->proxiesTargetDir) { + $this->proxiesTargetDir = sys_get_temp_dir(); + } + + return $this->proxiesTargetDir; + } + + /** + * @param \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface $generatorStrategy + */ + public function setGeneratorStrategy(GeneratorStrategyInterface $generatorStrategy) + { + $this->generatorStrategy = $generatorStrategy; + } + + /** + * @return \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface + */ + public function getGeneratorStrategy() + { + if (null === $this->generatorStrategy) { + $this->generatorStrategy = new FileWriterGeneratorStrategy(new FileLocator($this->getProxiesTargetDir())); + } + + return $this->generatorStrategy; + } + + /** + * @param \ProxyManager\Inflector\ClassNameInflectorInterface $classNameInflector + */ + public function setClassNameInflector(ClassNameInflectorInterface $classNameInflector) + { + $this->classNameInflector = $classNameInflector; + } + + /** + * @return \ProxyManager\Inflector\ClassNameInflectorInterface + */ + public function getClassNameInflector() + { + if (null === $this->classNameInflector) { + $this->classNameInflector = new ClassNameInflector($this->getProxiesNamespace()); + } + + return $this->classNameInflector; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/DisabledMethodException.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/DisabledMethodException.php new file mode 100644 index 0000000000000000000000000000000000000000..42f4eda07e1ca80b3d363c69db35e81812a92aa6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/DisabledMethodException.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Exception; + +use BadMethodCallException; + +/** + * Exception for forcefully disabled methods + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class DisabledMethodException extends BadMethodCallException implements ExceptionInterface +{ + const NAME = __CLASS__; + + /** + * @param string $method + * + * @return self + */ + public static function disabledMethod($method) + { + return new self(sprintf('Method "%s" is forcefully disabled', (string) $method)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/ExceptionInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/ExceptionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..34c7d8687229e3b63fa437e55d6737ef11cae72d --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/ExceptionInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Exception; + +/** + * Base exception class for the proxy manager + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface ExceptionInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxiedClassException.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxiedClassException.php new file mode 100644 index 0000000000000000000000000000000000000000..fff18b75b7825958f5ae677b6e5aef5671ac8e71 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxiedClassException.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Exception; + +use InvalidArgumentException; +use ReflectionClass; + +/** + * Exception for invalid proxied classes + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InvalidProxiedClassException extends InvalidArgumentException implements ExceptionInterface +{ + /** + * @param ReflectionClass $reflection + * + * @return self + */ + public static function interfaceNotSupported(ReflectionClass $reflection) + { + return new self(sprintf('Provided interface "%s" cannot be proxied', $reflection->getName())); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxyDirectoryException.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxyDirectoryException.php new file mode 100644 index 0000000000000000000000000000000000000000..cb5d0ea0fff92cb766ce0c21c72775516ebf937e --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/InvalidProxyDirectoryException.php @@ -0,0 +1,40 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Exception; + +use InvalidArgumentException; + +/** + * Exception for invalid directories + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InvalidProxyDirectoryException extends InvalidArgumentException implements ExceptionInterface +{ + /** + * @param string $directory + * + * @return self + */ + public static function proxyDirectoryNotFound($directory) + { + return new self(sprintf('Provided directory "%s" does not exist', (string) $directory)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/UnsupportedProxiedClassException.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/UnsupportedProxiedClassException.php new file mode 100644 index 0000000000000000000000000000000000000000..68f8215f7ca669662966244c6fad0f1da2dce496 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Exception/UnsupportedProxiedClassException.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Exception; + +use LogicException; +use ReflectionProperty; + +/** + * Exception for invalid proxied classes + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class UnsupportedProxiedClassException extends LogicException implements ExceptionInterface +{ + /** + * @param ReflectionProperty $property + * + * @return self + */ + public static function unsupportedLocalizedReflectionProperty(ReflectionProperty $property) + { + return new self( + sprintf( + 'Provided reflection property "%s" of class "%s" is private and cannot be localized in PHP 5.3', + $property->getName(), + $property->getDeclaringClass()->getName() + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractBaseFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractBaseFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..b3de2aa47b167513cacecc15c6a1e30a0a551f18 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractBaseFactory.php @@ -0,0 +1,97 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\Configuration; +use ProxyManager\Generator\ClassGenerator; +use ReflectionClass; + +/** + * Base factory common logic + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +abstract class AbstractBaseFactory +{ + /** + * @var \ProxyManager\Configuration + */ + protected $configuration; + + /** + * @var \ProxyManager\Inflector\ClassNameInflectorInterface + */ + protected $inflector; + + /** + * Cached generated class names + * + * @var string[] + */ + protected $generatedClasses = array(); + + /** + * @var \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator + */ + protected $generator; + + /** + * @param \ProxyManager\Configuration $configuration + */ + public function __construct(Configuration $configuration = null) + { + $this->configuration = $configuration ?: new Configuration(); + // localizing some properties for performance + $this->inflector = $this->configuration->getClassNameInflector(); + } + + /** + * Generate a proxy from a class name + * @param string $className + * @return string proxy class name + */ + protected function generateProxy($className) + { + if (! isset($this->generatedClasses[$className])) { + $this->generatedClasses[$className] = $this->inflector->getProxyClassName( + $className, + array('factory' => get_class($this)) + ); + } + + $proxyClassName = $this->generatedClasses[$className]; + + if (! class_exists($proxyClassName)) { + $className = $this->inflector->getUserClassName($className); + $phpClass = new ClassGenerator($proxyClassName); + + $this->getGenerator()->generate(new ReflectionClass($className), $phpClass); + $this->configuration->getGeneratorStrategy()->generate($phpClass); + $this->configuration->getProxyAutoloader()->__invoke($proxyClassName); + } + + return $proxyClassName; + } + + /** + * @return \ProxyManager\ProxyGenerator\ProxyGeneratorInterface + */ + abstract protected function getGenerator(); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..690bfa15cb4c359047bcc3e0b68c8d71437b0528 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php @@ -0,0 +1,46 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use Closure; + +/** + * Base factory common logic + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +abstract class AbstractLazyFactory extends AbstractBaseFactory +{ + /** + * Creates a new lazy proxy instance of the given class with + * the given initializer + * + * @param string $className name of the class to be proxied + * @param \Closure $initializer initializer to be passed to the proxy + * + * @return \ProxyManager\Proxy\LazyLoadingInterface + */ + public function createProxy($className, Closure $initializer) + { + $proxyClassName = $this->generateProxy($className); + + return new $proxyClassName($initializer); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorScopeLocalizerFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorScopeLocalizerFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..629b67691b49bf3ad12c30b0f2773d4e24f97c3b --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorScopeLocalizerFactory.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator; + +/** + * Factory responsible of producing proxy objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorScopeLocalizerFactory extends AbstractBaseFactory +{ + /** + * @param object $instance the object to be localized within the access interceptor + * @param \Closure[] $prefixInterceptors an array (indexed by method name) of interceptor closures to be called + * before method logic is executed + * @param \Closure[] $suffixInterceptors an array (indexed by method name) of interceptor closures to be called + * after method logic is executed + * + * @return \ProxyManager\Proxy\AccessInterceptorInterface + */ + public function createProxy($instance, array $prefixInterceptors = array(), array $suffixInterceptors = array()) + { + $proxyClassName = $this->generateProxy(get_class($instance)); + + return new $proxyClassName($instance, $prefixInterceptors, $suffixInterceptors); + } + + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new AccessInterceptorScopeLocalizerGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorValueHolderFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorValueHolderFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..c18d95d9f4fd3bf63631804a00da314c47f8b3b7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AccessInterceptorValueHolderFactory.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator; + +/** + * Factory responsible of producing proxy objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorValueHolderFactory extends AbstractBaseFactory +{ + /** + * @param object $instance the object to be wrapped within the value holder + * @param \Closure[] $prefixInterceptors an array (indexed by method name) of interceptor closures to be called + * before method logic is executed + * @param \Closure[] $suffixInterceptors an array (indexed by method name) of interceptor closures to be called + * after method logic is executed + * + * @return \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface + */ + public function createProxy($instance, array $prefixInterceptors = array(), array $suffixInterceptors = array()) + { + $className = get_class($instance); + $proxyClassName = $this->generateProxy($className); + + return new $proxyClassName($instance, $prefixInterceptors, $suffixInterceptors); + } + + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new AccessInterceptorValueHolderGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingGhostFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingGhostFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..995f1688a209702536bfc6ef02b8bc27b63f1d40 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingGhostFactory.php @@ -0,0 +1,40 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator; + +/** + * Factory responsible of producing ghost instances + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @method \ProxyManager\Proxy\GhostObjectInterface createProxy($className, \Closure $initializer) + */ +class LazyLoadingGhostFactory extends AbstractLazyFactory +{ + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new LazyLoadingGhostGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingValueHolderFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingValueHolderFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..02a273e9e8c84dd17d0424261547ba29127a91ed --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/LazyLoadingValueHolderFactory.php @@ -0,0 +1,40 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator; + +/** + * Factory responsible of producing virtual proxy instances + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @method \ProxyManager\Proxy\VirtualProxyInterface createProxy($className, \Closure $initializer) + */ +class LazyLoadingValueHolderFactory extends AbstractLazyFactory +{ + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new LazyLoadingValueHolderGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/NullObjectFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/NullObjectFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..121f6ba7fbe56fee1d707a16e86b946b909c7263 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/NullObjectFactory.php @@ -0,0 +1,51 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\ProxyGenerator\NullObjectGenerator; + +/** + * Factory responsible of producing proxy objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectFactory extends AbstractBaseFactory +{ + /** + * @param object $instanceOrClassName the object to be wrapped or interface to transform to null object + * + * @return \ProxyManager\Proxy\NullobjectInterface + */ + public function createProxy($instanceOrClassName) + { + $className = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName; + $proxyClassName = $this->generateProxy($className); + + return new $proxyClassName(); + } + + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new NullObjectGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/BaseAdapter.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/BaseAdapter.php new file mode 100644 index 0000000000000000000000000000000000000000..814d327eae6914a6e3953710809d2f3d545c6515 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/BaseAdapter.php @@ -0,0 +1,81 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory\RemoteObject\Adapter; + +use ProxyManager\Factory\RemoteObject\AdapterInterface; +use Zend\Server\Client; + +/** + * Remote Object base adapter + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +abstract class BaseAdapter implements AdapterInterface +{ + /** + * Adapter client + * + * @var \Zend\Server\Client + */ + protected $client; + + /** + * Service name mapping + * + * @var string[] + */ + protected $map = array(); + + /** + * Constructor + * + * @param Client $client + * @param array $map map of service names to their aliases + */ + public function __construct(Client $client, array $map = array()) + { + $this->client = $client; + $this->map = $map; + } + + /** + * {@inheritDoc} + */ + public function call($wrappedClass, $method, array $params = array()) + { + $serviceName = $this->getServiceName($wrappedClass, $method); + + if (isset($this->map[$serviceName])) { + $serviceName = $this->map[$serviceName]; + } + + return $this->client->call($serviceName, $params); + } + + /** + * Get the service name will be used by the adapter + * + * @param string $wrappedClass + * @param string $method + * + * @return string Service name + */ + abstract protected function getServiceName($wrappedClass, $method); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/JsonRpc.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/JsonRpc.php new file mode 100644 index 0000000000000000000000000000000000000000..aff27002c2307493486e33d4447c7c3f6eed6ece --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/JsonRpc.php @@ -0,0 +1,36 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory\RemoteObject\Adapter; + +/** + * Remote Object JSON RPC adapter + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class JsonRpc extends BaseAdapter +{ + /** + * {@inheritDoc} + */ + protected function getServiceName($wrappedClass, $method) + { + return $wrappedClass . '.' . $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/Soap.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/Soap.php new file mode 100644 index 0000000000000000000000000000000000000000..69de38623abe3e56983460213a2e8f610d1c4f3f --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/Soap.php @@ -0,0 +1,36 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory\RemoteObject\Adapter; + +/** + * Remote Object SOAP adapter + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class Soap extends BaseAdapter +{ + /** + * {@inheritDoc} + */ + protected function getServiceName($wrappedClass, $method) + { + return (string) $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/XmlRpc.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/XmlRpc.php new file mode 100644 index 0000000000000000000000000000000000000000..0485ccda513fd72ea0a4108a7e313c264f296251 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/XmlRpc.php @@ -0,0 +1,36 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory\RemoteObject\Adapter; + +/** + * Remote Object XML RPC adapter + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class XmlRpc extends BaseAdapter +{ + /** + * {@inheritDoc} + */ + protected function getServiceName($wrappedClass, $method) + { + return $wrappedClass . '.' . $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/AdapterInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/AdapterInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4168f9d78d0a41af5ae17ce3e028bfa8eed0e070 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/AdapterInterface.php @@ -0,0 +1,37 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory\RemoteObject; + +/** + * Remote Object adapter interface + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +interface AdapterInterface +{ + /** + * Call remote object + * + * @param string $wrappedClass + * @param string $method + * @param array $params + */ + public function call($wrappedClass, $method, array $params = array()); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObjectFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObjectFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..f65049b3b755dfb418a5030712aef8e3652742fc --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObjectFactory.php @@ -0,0 +1,71 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Factory; + +use ProxyManager\Configuration; +use ProxyManager\Factory\RemoteObject\AdapterInterface; +use ProxyManager\ProxyGenerator\RemoteObjectGenerator; + +/** + * Factory responsible of producing remote proxy objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectFactory extends AbstractBaseFactory +{ + /** + * @var AdapterInterface + */ + protected $adapter; + + /** + * {@inheritDoc} + * + * @param AdapterInterface $adapter + * @param Configuration $configuration + */ + public function __construct(AdapterInterface $adapter, Configuration $configuration = null) + { + parent::__construct($configuration); + + $this->adapter = $adapter; + } + + /** + * @param string|object $instanceOrClassName + * + * @return \ProxyManager\Proxy\RemoteObjectInterface + */ + public function createProxy($instanceOrClassName) + { + $className = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName; + $proxyClassName = $this->generateProxy($className); + + return new $proxyClassName($this->adapter); + } + + /** + * {@inheritDoc} + */ + protected function getGenerator() + { + return $this->generator ?: $this->generator = new RemoteObjectGenerator(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..197595eadf13fe8773aca73d0228a93cc79f63e0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocator.php @@ -0,0 +1,57 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\FileLocator; + +use ProxyManager\Exception\InvalidProxyDirectoryException; + +/** + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class FileLocator implements FileLocatorInterface +{ + /** + * @var string + */ + protected $proxiesDirectory; + + /** + * @param string $proxiesDirectory + * + * @throws \ProxyManager\Exception\InvalidProxyDirectoryException + */ + public function __construct($proxiesDirectory) + { + $this->proxiesDirectory = realpath($proxiesDirectory); + + if (false === $this->proxiesDirectory) { + throw InvalidProxyDirectoryException::proxyDirectoryNotFound($proxiesDirectory); + } + } + + /** + * {@inheritDoc} + */ + public function getProxyFileName($className) + { + return $this->proxiesDirectory . DIRECTORY_SEPARATOR . str_replace('\\', '', $className) . '.php'; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocatorInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocatorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2980c5d2e6e65faf1e47f9ade8352efab2b344ef --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/FileLocator/FileLocatorInterface.php @@ -0,0 +1,37 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\FileLocator; + +/** + * Basic autoloader utilities required to work with proxy files + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface FileLocatorInterface +{ + /** + * Retrieves the file name for the given proxy + * + * @param $className + * + * @return mixed + */ + public function getProxyFileName($className); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..0304c42f234aa42ca4ad6f5ea894fd90135330b2 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Generator; + +use Zend\Code\Generator\ClassGenerator as ZendClassGenerator; + +/** + * Class generator that ensures that interfaces/classes that are implemented/extended are FQCNs + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassGenerator extends ZendClassGenerator +{ + /** + * {@inheritDoc} + */ + public function setExtendedClass($extendedClass) + { + if ($extendedClass) { + $extendedClass = '\\' . trim($extendedClass, '\\'); + } + + return parent::setExtendedClass($extendedClass); + } + + /** + * {@inheritDoc} + */ + public function setImplementedInterfaces(array $interfaces) + { + foreach ($interfaces as & $interface) { + $interface = '\\' . trim($interface, '\\'); + } + + return parent::setImplementedInterfaces($interfaces); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MagicMethodGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MagicMethodGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..e0bd1f863a1dfb112b34606246b4de1ef8d901f8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MagicMethodGenerator.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Generator; + +use ReflectionClass; + +/** + * Method generator for magic methods + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicMethodGenerator extends MethodGenerator +{ + public function __construct(ReflectionClass $originalClass, $name, array $parameters = array()) + { + parent::__construct( + $name, + $parameters, + static::FLAG_PUBLIC, + null, + $originalClass->hasMethod($name) ? '{@inheritDoc}' : null + ); + + $this->setReturnsReference(strtolower($name) === '__get'); + + if ($originalClass->hasMethod($name)) { + $this->setReturnsReference($originalClass->getMethod($name)->returnsReference()); + } + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MethodGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MethodGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..cffd6afdf52267002ba599b5d4b74882517deee4 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/MethodGenerator.php @@ -0,0 +1,161 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Generator; + +use Zend\Code\Generator\DocBlockGenerator; +use Zend\Code\Generator\MethodGenerator as ZendMethodGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method generator that fixes minor quirks in ZF2's method generator + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MethodGenerator extends ZendMethodGenerator +{ + /** + * @var bool + */ + protected $returnsReference = false; + + /** + * @param boolean $returnsReference + */ + public function setReturnsReference($returnsReference) + { + $this->returnsReference = (bool) $returnsReference; + } + + /** + * @return boolean + */ + public function returnsReference() + { + return $this->returnsReference; + } + + /** + * @override enforces generation of \ProxyManager\Generator\MethodGenerator + * + * {@inheritDoc} + */ + public static function fromReflection(MethodReflection $reflectionMethod) + { + /* @var $method self */ + $method = new static(); + + $method->setSourceContent($reflectionMethod->getContents(false)); + $method->setSourceDirty(false); + + if ($reflectionMethod->getDocComment() != '') { + $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock())); + } + + $method->setFinal($reflectionMethod->isFinal()); + $method->setVisibility(self::extractVisibility($reflectionMethod)); + + foreach ($reflectionMethod->getParameters() as $reflectionParameter) { + $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter)); + } + + $method->setStatic($reflectionMethod->isStatic()); + $method->setName($reflectionMethod->getName()); + $method->setBody($reflectionMethod->getBody()); + $method->setReturnsReference($reflectionMethod->returnsReference()); + + return $method; + } + + /** + * Retrieves the visibility for the given method reflection + * + * @param MethodReflection $reflectionMethod + * + * @return string + */ + private static function extractVisibility(MethodReflection $reflectionMethod) + { + if ($reflectionMethod->isPrivate()) { + return static::VISIBILITY_PRIVATE; + } + + if ($reflectionMethod->isProtected()) { + return static::VISIBILITY_PROTECTED; + } + + return static::VISIBILITY_PUBLIC; + } + + /** + * @override fixes by-reference return value in zf2's method generator + * + * {@inheritDoc} + */ + public function generate() + { + $output = ''; + $indent = $this->getIndentation(); + + if (null !== ($docBlock = $this->getDocBlock())) { + $docBlock->setIndentation($indent); + + $output .= $docBlock->generate(); + } + + $output .= $indent . $this->generateMethodDeclaration() . self::LINE_FEED . $indent . '{' . self::LINE_FEED; + + if ($this->body) { + $output .= preg_replace('#^(.+?)$#m', $indent . $indent . '$1', trim($this->body)) + . self::LINE_FEED; + } + + $output .= $indent . '}' . self::LINE_FEED; + + return $output; + } + + /** + * @return string + */ + private function generateMethodDeclaration() + { + $output = $this->generateVisibility() + . ' function ' + . (($this->returnsReference()) ? '& ' : '') + . $this->getName() . '('; + + $parameterOutput = array(); + + foreach ($this->getParameters() as $parameter) { + $parameterOutput[] = $parameter->generate(); + } + + return $output . implode(', ', $parameterOutput) . ')'; + } + + /** + * @return string + */ + private function generateVisibility() + { + return $this->isAbstract() ? 'abstract ' : (($this->isFinal()) ? 'final ' : '') + . ($this->getVisibility() . (($this->isStatic()) ? ' static' : '')); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..49b9764b923f2e6d411dc096141aa8f3847895a6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php @@ -0,0 +1,151 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Generator; + +use ReflectionException; +use Zend\Code\Generator\ParameterGenerator as ZendParameterGenerator; +use Zend\Code\Generator\ValueGenerator; +use Zend\Code\Reflection\ParameterReflection; + +/** + * Parameter generator that ensures that the parameter type is a FQCN when it is a class + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ParameterGenerator extends ZendParameterGenerator +{ + /** + * @override - uses `static` to instantiate the parameter + * + * {@inheritDoc} + */ + public static function fromReflection(ParameterReflection $reflectionParameter) + { + /* @var $param self */ + $param = new static(); + + $param->setName($reflectionParameter->getName()); + $param->setPosition($reflectionParameter->getPosition()); + + $type = self::extractParameterType($reflectionParameter); + + if (null !== $type) { + $param->setType($type); + } + + self::setOptionalParameter($param, $reflectionParameter); + + $param->setPassedByReference($reflectionParameter->isPassedByReference()); + + return $param; + } + + /** + * Retrieves the type of a reflection parameter (null if none is found) + * + * @param ParameterReflection $reflectionParameter + * + * @return string|null + */ + private static function extractParameterType(ParameterReflection $reflectionParameter) + { + if ($reflectionParameter->isArray()) { + return 'array'; + } + + if (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) { + return 'callable'; + } + + if ($typeClass = $reflectionParameter->getClass()) { + return $typeClass->getName(); + } + + return null; + } + + /** + * @return string + */ + public function generate() + { + return $this->getGeneratedType() + . (true === $this->passedByReference ? '&' : '') + . '$' . $this->name + . $this->generateDefaultValue(); + } + + /** + * @return string + */ + private function generateDefaultValue() + { + if (null === $this->defaultValue) { + return ''; + } + + if (is_string($this->defaultValue)) { + return ' = ' . ValueGenerator::escape($this->defaultValue); + } + + if ($this->defaultValue instanceof ValueGenerator) { + $this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE); + } + + return ' = ' . $this->defaultValue; + } + + /** + * Retrieves the generated parameter type + * + * @return string + */ + private function getGeneratedType() + { + if (! $this->type || in_array($this->type, static::$simple)) { + return ''; + } + + if ('array' === $this->type || 'callable' === $this->type) { + return $this->type . ' '; + } + + return '\\' . trim($this->type, '\\') . ' '; + } + + /** + * Set the default value for a parameter (if it is optional) + * + * @param ZendParameterGenerator $parameterGenerator + * @param ParameterReflection $reflectionParameter + */ + private static function setOptionalParameter( + ZendParameterGenerator $parameterGenerator, + ParameterReflection $reflectionParameter + ) { + if ($reflectionParameter->isOptional()) { + try { + $parameterGenerator->setDefaultValue($reflectionParameter->getDefaultValue()); + } catch (ReflectionException $e) { + $parameterGenerator->setDefaultValue(null); + } + } + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..4bb2b771126edd516e396b7fcaa626ee82d130a9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php @@ -0,0 +1,53 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Generator\Util; + +/** + * Utility class capable of generating unique + * valid class/property/method identifiers + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +abstract class UniqueIdentifierGenerator +{ + const VALID_IDENTIFIER_FORMAT = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/'; + const DEFAULT_IDENTIFIER = 'g'; + + /** + * Generates a valid unique identifier from the given name + * + * @param string $name + * + * @return string + */ + public static function getIdentifier($name) + { + return str_replace( + '.', + '', + uniqid( + preg_match(static::VALID_IDENTIFIER_FORMAT, $name) + ? $name + : static::DEFAULT_IDENTIFIER, + true + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/BaseGeneratorStrategy.php b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/BaseGeneratorStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..1e771208054d89a82c2e820986c5435688bfc128 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/BaseGeneratorStrategy.php @@ -0,0 +1,38 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\GeneratorStrategy; + +use Zend\Code\Generator\ClassGenerator; + +/** + * Generator strategy that generates the class body + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class BaseGeneratorStrategy implements GeneratorStrategyInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ClassGenerator $classGenerator) + { + return $classGenerator->generate(); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..bdb4688c04a8b292031c5b1d418e273199278c69 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php @@ -0,0 +1,69 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\GeneratorStrategy; + +use Zend\Code\Generator\ClassGenerator; + +/** + * Generator strategy that produces the code and evaluates it at runtime + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class EvaluatingGeneratorStrategy implements GeneratorStrategyInterface +{ + /** + * @var bool flag indicating whether {@see eval} can be used + */ + private $canEval = true; + + /** + * Constructor + */ + public function __construct() + { + $this->canEval = ! ini_get('suhosin.executor.disable_eval'); + } + + /** + * Evaluates the generated code before returning it + * + * {@inheritDoc} + */ + public function generate(ClassGenerator $classGenerator) + { + $code = $classGenerator->generate(); + + if (! $this->canEval) { + // @codeCoverageIgnoreStart + $fileName = sys_get_temp_dir() . '/EvaluatingGeneratorStrategy.php.tmp.' . uniqid('', true); + + file_put_contents($fileName, "<?php\n" . $code); + require $fileName; + unlink($fileName); + + return $code; + // @codeCoverageIgnoreEnd + } + + eval($code); + + return $code; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..29ec7caa88b73a8b9287da1f6e6f373646ab5047 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\GeneratorStrategy; + +use ProxyManager\FileLocator\FileLocatorInterface; +use Zend\Code\Generator\ClassGenerator; + +/** + * Generator strategy that writes the generated classes to disk while generating them + * + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class FileWriterGeneratorStrategy implements GeneratorStrategyInterface +{ + /** + * @var \ProxyManager\FileLocator\FileLocatorInterface + */ + protected $fileLocator; + + /** + * @param \ProxyManager\FileLocator\FileLocatorInterface $fileLocator + */ + public function __construct(FileLocatorInterface $fileLocator) + { + $this->fileLocator = $fileLocator; + } + + /** + * Write generated code to disk and return the class code + * + * {@inheritDoc} + */ + public function generate(ClassGenerator $classGenerator) + { + $className = trim($classGenerator->getNamespaceName(), '\\') + . '\\' . trim($classGenerator->getName(), '\\'); + $generatedCode = $classGenerator->generate(); + $fileName = $this->fileLocator->getProxyFileName($className); + $tmpFileName = $fileName . '.' . uniqid('', true); + + // renaming files is necessary to avoid race conditions when the same file is written multiple times + // in a short time period + file_put_contents($tmpFileName, "<?php\n\n" . $generatedCode); + rename($tmpFileName, $fileName); + + return $generatedCode; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/GeneratorStrategyInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/GeneratorStrategyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..b7161e92aa0459bc05233888c45ea9db20b80aa7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/GeneratorStrategyInterface.php @@ -0,0 +1,39 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\GeneratorStrategy; + +use Zend\Code\Generator\ClassGenerator; + +/** + * Generator strategy interface - defines basic behavior of class generators + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface GeneratorStrategyInterface +{ + /** + * Generate the provided class + * + * @param ClassGenerator $classGenerator + * + * @return string the class body + */ + public function generate(ClassGenerator $classGenerator); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflector.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflector.php new file mode 100644 index 0000000000000000000000000000000000000000..c911b25fe63b1c34f21524246c7c40c3fb2d22e6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflector.php @@ -0,0 +1,98 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Inflector; + +use ProxyManager\Inflector\Util\ParameterEncoder; + +/** + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassNameInflector implements ClassNameInflectorInterface +{ + /** + * @var string + */ + protected $proxyNamespace; + + /** + * @var int + */ + private $proxyMarkerLength; + + /** + * @var string + */ + private $proxyMarker; + + /** + * @var \ProxyManager\Inflector\Util\ParameterEncoder + */ + private $parameterEncoder; + + /** + * @param string $proxyNamespace + */ + public function __construct($proxyNamespace) + { + $this->proxyNamespace = (string) $proxyNamespace; + $this->proxyMarker = '\\' . static::PROXY_MARKER . '\\'; + $this->proxyMarkerLength = strlen($this->proxyMarker); + $this->parameterEncoder = new ParameterEncoder(); + } + + /** + * {@inheritDoc} + */ + public function getUserClassName($className) + { + $className = ltrim($className, '\\'); + + if (false === $position = strrpos($className, $this->proxyMarker)) { + return $className; + } + + return substr( + $className, + $this->proxyMarkerLength + $position, + strrpos($className, '\\') - ($position + $this->proxyMarkerLength) + ); + } + + /** + * {@inheritDoc} + */ + public function getProxyClassName($className, array $options = array()) + { + return $this->proxyNamespace + . $this->proxyMarker + . $this->getUserClassName($className) + . '\\' . $this->parameterEncoder->encodeParameters($options); + } + + /** + * {@inheritDoc} + */ + public function isProxyClassName($className) + { + return false !== strrpos($className, $this->proxyMarker); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflectorInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflectorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..db46a78f7ff998a725bcb5536ef93dbc31166416 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ClassNameInflectorInterface.php @@ -0,0 +1,61 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Inflector; + +/** + * Interface for a proxy- to user-class and user- to proxy-class name inflector + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface ClassNameInflectorInterface +{ + /** + * Marker for proxy classes - classes containing this marker are considered proxies + */ + const PROXY_MARKER = '__PM__'; + + /** + * Retrieve the class name of a user-defined class + * + * @param string $className + * + * @return string + */ + public function getUserClassName($className); + + /** + * Retrieve the class name of the proxy for the given user-defined class name + * + * @param string $className + * @param array $options arbitrary options to be used for the generated class name + * + * @return mixed + */ + public function getProxyClassName($className, array $options = array()); + + /** + * Retrieve whether the provided class name is a proxy + * + * @param string $className + * + * @return bool + */ + public function isProxyClassName($className); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/Util/ParameterEncoder.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/Util/ParameterEncoder.php new file mode 100644 index 0000000000000000000000000000000000000000..82d6d8c209d5f10499c575d637c317e65f84f641 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/Util/ParameterEncoder.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Inflector\Util; + +/** + * Encodes parameters into a class-name safe string + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ParameterEncoder +{ + /** + * Converts the given parameters into a set of characters that are safe to + * use in a class name + * + * @param array $parameters + * + * @return string + */ + public function encodeParameters(array $parameters) + { + return strtr(base64_encode(serialize($parameters)), '+/=', '†‡•'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/AccessInterceptorInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/AccessInterceptorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..49d70f221140776d71ff033be6ed69af8f6f46f6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/AccessInterceptorInterface.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Access interceptor object marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface AccessInterceptorInterface extends ProxyInterface +{ + /** + * Set or remove the prefix interceptor for a method + * + * @link https://github.com/Ocramius/ProxyManager/blob/master/docs/access-interceptor-value-holder.md + * + * A prefix interceptor should have a signature like following: + * + * <code> + * $prefixInterceptor = function ($proxy, $instance, $method, $params, & $returnEarly) {}; + * </code> + * + * @param string $methodName name of the intercepted method + * @param \Closure|null $prefixInterceptor interceptor closure or null to unset the currently active interceptor + * + * @return void + */ + public function setMethodPrefixInterceptor($methodName, \Closure $prefixInterceptor = null); + + /** + * Set or remove the suffix interceptor for a method + * + * @link https://github.com/Ocramius/ProxyManager/blob/master/docs/access-interceptor-value-holder.md + * + * A prefix interceptor should have a signature like following: + * + * <code> + * $suffixInterceptor = function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) {}; + * </code> + * + * @param string $methodName name of the intercepted method + * @param \Closure|null $suffixInterceptor interceptor closure or null to unset the currently active interceptor + * + * @return void + */ + public function setMethodSuffixInterceptor($methodName, \Closure $suffixInterceptor = null); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/Exception/RemoteObjectException.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/Exception/RemoteObjectException.php new file mode 100644 index 0000000000000000000000000000000000000000..636a0291ccf769f84c61d0b23dfcfaa2ae50a515 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/Exception/RemoteObjectException.php @@ -0,0 +1,31 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy\Exception; + +use RuntimeException; + +/** + * Remote object exception + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectException extends RuntimeException +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/FallbackValueHolderInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/FallbackValueHolderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bf4bc2a8d4a33f23f61ba72ae1ada891f70580f8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/FallbackValueHolderInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Fallback value holder object marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface FallbackValueHolderInterface extends ProxyInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/GhostObjectInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/GhostObjectInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..77df518a6d9ba6be887b26e2908a5a3517d73859 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/GhostObjectInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Ghost object marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface GhostObjectInterface extends LazyLoadingInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/LazyLoadingInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/LazyLoadingInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..1da90e6506913a2be2d98c0b2dbd0ab9daaf00b1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/LazyLoadingInterface.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Lazy loading object identifier + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface LazyLoadingInterface extends ProxyInterface +{ + /** + * Set or unset the initializer for the proxy instance + * + * @link https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md#lazy-initialization + * + * An initializer should have a signature like following: + * + * <code> + * $initializer = function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {}; + * </code> + * + * @param \Closure|null $initializer + * + * @return mixed + */ + public function setProxyInitializer(\Closure $initializer = null); + + /** + * @return \Closure|null + */ + public function getProxyInitializer(); + + /** + * Force initialization of the proxy + * + * @return bool true if the proxy could be initialized + */ + public function initializeProxy(); + + /** + * Retrieves current initialization status of the proxy + * + * @return bool + */ + public function isProxyInitialized(); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/NullObjectInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/NullObjectInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..cd411154f2bdd337de480dc78dbd30fea1f37a18 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/NullObjectInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Null object marker + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +interface NullObjectInterface extends ProxyInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ProxyInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ProxyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7d402b4559a51edfa9e2a29b36d71444ad78224d --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ProxyInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Base proxy marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface ProxyInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/RemoteObjectInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/RemoteObjectInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..264fa5ec924ad8c220d8dce45c1b992538b92c8b --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/RemoteObjectInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Remote object marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface RemoteObjectInterface extends ProxyInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/SmartReferenceInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/SmartReferenceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2380b32b61e559b13de1a13b58c3e234f29c7f91 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/SmartReferenceInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Smart reference object marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface SmartReferenceInterface extends ProxyInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ValueHolderInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ValueHolderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..126d543908430dd19255a10a12de1a235bb8e19b --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/ValueHolderInterface.php @@ -0,0 +1,33 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Value holder marker + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface ValueHolderInterface extends ProxyInterface +{ + /** + * @return object|null the wrapped value + */ + public function getWrappedValueHolderValue(); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/VirtualProxyInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/VirtualProxyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..fc108c7fb37de644aa2a7785eb56a0490d42b7a8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/Proxy/VirtualProxyInterface.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\Proxy; + +/** + * Virtual Proxy - a lazy initializing object wrapping around the proxied subject + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface VirtualProxyInterface extends LazyLoadingInterface, ValueHolderInterface +{ +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeup.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeup.php new file mode 100644 index 0000000000000000000000000000000000000000..5b7c19d1541b085ef1ae4408776b9a62a44b7175 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeup.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use ReflectionProperty; + +/** + * Magic `__wakeup` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicWakeup extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct(ReflectionClass $originalClass) + { + parent::__construct($originalClass, '__wakeup'); + + /* @var $publicProperties \ReflectionProperty[] */ + $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); + $unsetProperties = array(); + + foreach ($publicProperties as $publicProperty) { + $unsetProperties[] = '$this->' . $publicProperty->getName(); + } + + $this->setBody($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");" : ''); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptor.php new file mode 100644 index 0000000000000000000000000000000000000000..85ba6135952a40429d362a486e21ab86288f70d8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptor.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\AccessInterceptorInterface::setMethodPrefixInterceptor} + * for access interceptor objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetMethodPrefixInterceptor extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $prefixInterceptor) + { + parent::__construct('setMethodPrefixInterceptor'); + + $interceptor = new ParameterGenerator('prefixInterceptor'); + + $interceptor->setType('Closure'); + $interceptor->setDefaultValue(null); + $this->setParameter(new ParameterGenerator('methodName')); + $this->setParameter($interceptor); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('$this->' . $prefixInterceptor->getName() . '[$methodName] = $prefixInterceptor;'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptor.php new file mode 100644 index 0000000000000000000000000000000000000000..74cf81f2332177adc65a2807fc650538b96808ab --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptor.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\AccessInterceptorInterface::setMethodSuffixInterceptor} + * for access interceptor objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetMethodSuffixInterceptor extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $suffixInterceptor) + { + parent::__construct('setMethodSuffixInterceptor'); + + $interceptor = new ParameterGenerator('suffixInterceptor'); + + $interceptor->setType('Closure'); + $interceptor->setDefaultValue(null); + $this->setParameter(new ParameterGenerator('methodName')); + $this->setParameter($interceptor); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('$this->' . $suffixInterceptor->getName() . '[$methodName] = $suffixInterceptor;'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptors.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptors.php new file mode 100644 index 0000000000000000000000000000000000000000..7462d6ef22e39f4530f3a4321aa89119a19c3cea --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptors.php @@ -0,0 +1,43 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the interceptor for operations to be executed before method execution + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MethodPrefixInterceptors extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('methodPrefixInterceptors')); + + $this->setDefaultValue(array()); + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\Closure[] map of interceptors to be called per-method before execution'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptors.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptors.php new file mode 100644 index 0000000000000000000000000000000000000000..2b809a608618eb5aa67f200a1cda1479e697a86c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptors.php @@ -0,0 +1,43 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the interceptor for operations to be executed after method execution + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MethodSuffixInterceptors extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('methodSuffixInterceptors')); + + $this->setDefaultValue(array()); + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\Closure[] map of interceptors to be called per-method after execution'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php new file mode 100644 index 0000000000000000000000000000000000000000..37b196843c9c8aa412efa178e65f004e5ea6e965 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php @@ -0,0 +1,92 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Exception\UnsupportedProxiedClassException; +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * The `__construct` implementation for lazy loading proxies + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Constructor extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct('__construct'); + + $localizedObject = new ParameterGenerator('localizedObject'); + $prefix = new ParameterGenerator('prefixInterceptors'); + $suffix = new ParameterGenerator('suffixInterceptors'); + + $localizedObject->setType($originalClass->getName()); + $prefix->setDefaultValue(array()); + $suffix->setDefaultValue(array()); + $prefix->setType('array'); + $suffix->setType('array'); + + $this->setParameter($localizedObject); + $this->setParameter($prefix); + $this->setParameter($suffix); + + $localizedProperties = array(); + + foreach ($originalClass->getProperties() as $originalProperty) { + if ((PHP_VERSION_ID < 50400 || (defined('HHVM_VERSION'))) && $originalProperty->isPrivate()) { + // @codeCoverageIgnoreStart + throw UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty($originalProperty); + // @codeCoverageIgnoreEnd + } + + $propertyName = $originalProperty->getName(); + + if ($originalProperty->isPrivate()) { + $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n " + . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n" + . '}, $this, ' . var_export($originalProperty->getDeclaringClass()->getName(), true) + . ')->__invoke();'; + } else { + $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";"; + } + } + + $this->setDocblock( + "@override constructor to setup interceptors\n\n" + . "@param \\" . $originalClass->getName() . " \$localizedObject\n" + . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" + . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic" + ); + $this->setBody( + (empty($localizedProperties) ? '' : implode("\n\n", $localizedProperties) . "\n\n") + . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" + . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;" + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethod.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethod.php new file mode 100644 index 0000000000000000000000000000000000000000..b865ca0c4e01521fd1545e061463579a87500625 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethod.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method with additional pre- and post- interceptor logic in the body + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InterceptedMethod extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors + * @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors + * + * @return self + */ + public static function generateMethod( + MethodReflection $originalMethod, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + $forwardedParams = array(); + + foreach ($originalMethod->getParameters() as $parameter) { + $forwardedParams[] = '$' . $parameter->getName(); + } + + $method->setDocblock('{@inheritDoc}'); + $method->setBody( + InterceptorGenerator::createInterceptedMethodBody( + '$returnValue = parent::' + . $originalMethod->getName() . '(' . implode(', ', $forwardedParams) . ');', + $method, + $prefixInterceptors, + $suffixInterceptors + ) + ); + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicClone.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicClone.php new file mode 100644 index 0000000000000000000000000000000000000000..98e9b19aab238e0d5935bcb542e643c03b62db7e --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicClone.php @@ -0,0 +1,53 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__clone` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicClone extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__clone'); + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $originalClass->hasMethod('__clone') ? '$returnValue = parent::__clone();' : '$returnValue = null;', + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGet.php new file mode 100644 index 0000000000000000000000000000000000000000..b6c241fcd9f473434cce8f2b889ad6bf7b0379d4 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGet.php @@ -0,0 +1,73 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__get` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGet extends MagicMethodGenerator +{ + /** + * @param ReflectionClass $originalClass + * @param PropertyGenerator $prefixInterceptors + * @param PropertyGenerator $suffixInterceptors + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__get', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__get'); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if ($override) { + $callParent = '$returnValue = & parent::__get($name);'; + } else { + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'name', + null, + null, + 'returnValue' + ); + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIsset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIsset.php new file mode 100644 index 0000000000000000000000000000000000000000..0021e22a25fcf6bb270fcfccd4d0eb9aee322d6f --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIsset.php @@ -0,0 +1,73 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__isset` method for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIsset extends MagicMethodGenerator +{ + /** + * @param ReflectionClass $originalClass + * @param PropertyGenerator $prefixInterceptors + * @param PropertyGenerator $suffixInterceptors + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__isset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__isset'); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if ($override) { + $callParent = '$returnValue = & parent::__isset($name);'; + } else { + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_ISSET, + 'name', + null, + null, + 'returnValue' + ); + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSet.php new file mode 100644 index 0000000000000000000000000000000000000000..c24780806be0c6387b095acb40639d692a80e9f3 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSet.php @@ -0,0 +1,77 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__set` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSet extends MagicMethodGenerator +{ + /** + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors + * @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct( + $originalClass, + '__set', + array(new ParameterGenerator('name'), new ParameterGenerator('value')) + ); + + $override = $originalClass->hasMethod('__set'); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if ($override) { + $callParent = '$returnValue = & parent::__set($name, $value);'; + } else { + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'name', + 'value', + null, + 'returnValue' + ); + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleep.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleep.php new file mode 100644 index 0000000000000000000000000000000000000000..3ea4a2589357d8a051ddd0dd75f3577ce22f3cc3 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleep.php @@ -0,0 +1,57 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__sleep` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleep extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__sleep'); + + $callParent = $originalClass->hasMethod('__sleep') + ? '$returnValue = & parent::__sleep();' + : '$returnValue = array_keys((array) $this);'; + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnset.php new file mode 100644 index 0000000000000000000000000000000000000000..b2edaaf467de35fe2d420ef39045ea7f243cde1e --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnset.php @@ -0,0 +1,73 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__unset` method for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnset extends MagicMethodGenerator +{ + /** + * @param ReflectionClass $originalClass + * @param PropertyGenerator $prefixInterceptors + * @param PropertyGenerator $suffixInterceptors + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__unset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__unset'); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if ($override) { + $callParent = '$returnValue = & parent::__unset($name);'; + } else { + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_UNSET, + 'name', + null, + null, + 'returnValue' + ); + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..c43463506390288162aff2d7226c3c1e4f63331f --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGenerator.php @@ -0,0 +1,82 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Utility to create pre- and post- method interceptors around a given method body + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @internal - this class is just here as a small utility for this component, + * don't use it in your own code + */ +class InterceptorGenerator +{ + /** + * @param string $methodBody the body of the previously generated code. + * It MUST assign the return value to a variable + * `$returnValue` instead of directly returning + * @param \ProxyManager\Generator\MethodGenerator $method + * @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors + * @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors + * + * @return string + */ + public static function createInterceptedMethodBody( + $methodBody, + MethodGenerator $method, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + $name = var_export($method->getName(), true); + $prefixInterceptors = $prefixInterceptors->getName(); + $suffixInterceptors = $suffixInterceptors->getName(); + $params = array(); + + foreach ($method->getParameters() as $parameter) { + $parameterName = $parameter->getName(); + $params[] = var_export($parameterName, true) . ' => $' . $parameter->getName(); + } + + $paramsString = 'array(' . implode(', ', $params) . ')'; + + return "if (isset(\$this->$prefixInterceptors" . "[$name])) {\n" + . " \$returnEarly = false;\n" + . " \$prefixReturnValue = \$this->$prefixInterceptors" . "[$name]->__invoke(" + . "\$this, \$this, $name, $paramsString, \$returnEarly);\n\n" + . " if (\$returnEarly) {\n" + . " return \$prefixReturnValue;\n" + . " }\n" + . "}\n\n" + . $methodBody . "\n\n" + . "if (isset(\$this->$suffixInterceptors" . "[$name])) {\n" + . " \$returnEarly = false;\n" + . " \$suffixReturnValue = \$this->$suffixInterceptors" . "[$name]->__invoke(" + . "\$this, \$this, $name, $paramsString, \$returnValue, \$returnEarly);\n\n" + . " if (\$returnEarly) {\n" + . " return \$suffixReturnValue;\n" + . " }\n" + . "}\n\n" + . "return \$returnValue;"; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizerGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizerGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..1247f36cb7a8eb12235e2ac185a3bac9145724a2 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizerGenerator.php @@ -0,0 +1,106 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\Exception\InvalidProxiedClassException; + +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor; +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor; +use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors; + +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset; + +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset; + +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\ValueHolderInterface} + * and localizing scope of the proxied object at instantiation + * + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorScopeLocalizerGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + if ($originalClass->isInterface()) { + throw InvalidProxiedClassException::interfaceNotSupported($originalClass); + } + + $classGenerator->setExtendedClass($originalClass->getName()); + $classGenerator->setImplementedInterfaces(array('ProxyManager\\Proxy\\AccessInterceptorInterface')); + $classGenerator->addPropertyFromGenerator($prefixInterceptors = new MethodPrefixInterceptors()); + $classGenerator->addPropertyFromGenerator($suffixInterceptors = new MethodPrefixInterceptors()); + + $methods = ProxiedMethodsFilter::getProxiedMethods( + $originalClass, + array('__get', '__set', '__isset', '__unset', '__clone', '__sleep') + ); + + foreach ($methods as $method) { + $classGenerator->addMethodFromGenerator( + InterceptedMethod::generateMethod( + new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()), + $prefixInterceptors, + $suffixInterceptors + ) + ); + } + + $classGenerator->addMethodFromGenerator( + new Constructor($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator(new SetMethodPrefixInterceptor($prefixInterceptors)); + $classGenerator->addMethodFromGenerator(new SetMethodSuffixInterceptor($suffixInterceptors)); + $classGenerator->addMethodFromGenerator( + new MagicGet($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicSet($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicIsset($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicUnset($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicSleep($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicClone($originalClass, $prefixInterceptors, $suffixInterceptors) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php new file mode 100644 index 0000000000000000000000000000000000000000..a2e9c8acfe0318c572b240bfe434220cc5c891f9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php @@ -0,0 +1,79 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use ReflectionProperty; +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * The `__construct` implementation for lazy loading proxies + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Constructor extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct('__construct'); + + $prefix = new ParameterGenerator('prefixInterceptors'); + $suffix = new ParameterGenerator('suffixInterceptors'); + + $prefix->setDefaultValue(array()); + $suffix->setDefaultValue(array()); + $prefix->setType('array'); + $suffix->setType('array'); + + $this->setParameter(new ParameterGenerator('wrappedObject')); + $this->setParameter($prefix); + $this->setParameter($suffix); + + /* @var $publicProperties \ReflectionProperty[] */ + $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); + $unsetProperties = array(); + + foreach ($publicProperties as $publicProperty) { + $unsetProperties[] = '$this->' . $publicProperty->getName(); + } + + $this->setDocblock( + "@override constructor to setup interceptors\n\n" + . "@param \\" . $originalClass->getName() . " \$wrappedObject\n" + . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" + . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic" + ); + $this->setBody( + ($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') + . '$this->' . $valueHolder->getName() . " = \$wrappedObject;\n" + . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" + . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;" + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethod.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethod.php new file mode 100644 index 0000000000000000000000000000000000000000..46aab2d03d27783b01e3cf81ddec0d62e7bb22fd --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethod.php @@ -0,0 +1,70 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method with additional pre- and post- interceptor logic in the body + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InterceptedMethod extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * @param \Zend\Code\Generator\PropertyGenerator $valueHolderProperty + * @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors + * @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors + * + * @return self + */ + public static function generateMethod( + MethodReflection $originalMethod, + PropertyGenerator $valueHolderProperty, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + $forwardedParams = array(); + + foreach ($originalMethod->getParameters() as $parameter) { + $forwardedParams[] = '$' . $parameter->getName(); + } + + $method->setDocblock('{@inheritDoc}'); + $method->setBody( + InterceptorGenerator::createInterceptedMethodBody( + '$returnValue = $this->' . $valueHolderProperty->getName() . '->' + . $originalMethod->getName() . '(' . implode(', ', $forwardedParams) . ');', + $method, + $valueHolderProperty, + $prefixInterceptors, + $suffixInterceptors + ) + ); + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicClone.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicClone.php new file mode 100644 index 0000000000000000000000000000000000000000..764ba77fa770bcd20a634738120feaf8d08b9f41 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicClone.php @@ -0,0 +1,58 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__clone` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicClone extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolderProperty, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + parent::__construct($originalClass, '__clone'); + + $valueHolder = $valueHolderProperty->getName(); + $prefix = $prefixInterceptors->getName(); + $suffix = $suffixInterceptors->getName(); + + $this->setBody( + "\$this->$valueHolder = clone \$this->$valueHolder;\n\n" + . "foreach (\$this->$prefix as \$key => \$value) {\n" + . " \$this->$prefix" . "[\$key] = clone \$value;\n" + . "}\n\n" + . "foreach (\$this->$suffix as \$key => \$value) {\n" + . " \$this->$suffix" . "[\$key] = clone \$value;\n" + . "}" + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGet.php new file mode 100644 index 0000000000000000000000000000000000000000..77e6c0c94a25a77db25d07cece458a1f59c848d6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGet.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__get` for method interceptor value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGet extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__get', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__get'); + $valueHolderName = $valueHolder->getName(); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'name', + 'value', + $valueHolder, + 'returnValue' + ); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' $returnValue = & $this->' . $valueHolderName . '->$name;' + . "\n} else {\n $callParent\n}\n\n"; + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIsset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIsset.php new file mode 100644 index 0000000000000000000000000000000000000000..daa6b742bff0e0a1905ac5bca1c5afbb67031d28 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIsset.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__isset` for method interceptor value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIsset extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__isset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__isset'); + $valueHolderName = $valueHolder->getName(); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_ISSET, + 'name', + 'value', + $valueHolder, + 'returnValue' + ); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' $returnValue = isset($this->' . $valueHolderName . '->$name);' + . "\n} else {\n $callParent\n}\n\n"; + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSet.php new file mode 100644 index 0000000000000000000000000000000000000000..f79747dff3a18db047eec377726205d97d8eec2a --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSet.php @@ -0,0 +1,82 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__set` for method interceptor value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSet extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors, + PublicPropertiesMap $publicProperties + ) { + parent::__construct( + $originalClass, + '__set', + array(new ParameterGenerator('name'), new ParameterGenerator('value')) + ); + + $override = $originalClass->hasMethod('__set'); + $valueHolderName = $valueHolder->getName(); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'name', + 'value', + $valueHolder, + 'returnValue' + ); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' $returnValue = ($this->' . $valueHolderName . '->$name = $value);' + . "\n} else {\n $callParent\n}\n\n"; + } + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnset.php new file mode 100644 index 0000000000000000000000000000000000000000..1484c14c097f8fd3a243645425705ce2b4acc891 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnset.php @@ -0,0 +1,80 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__unset` for method interceptor value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnset extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__unset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__unset'); + $valueHolderName = $valueHolder->getName(); + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + $callParent = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_UNSET, + 'name', + 'value', + $valueHolder, + 'returnValue' + ); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' unset($this->' . $valueHolderName . '->$name);' + . "\n} else {\n $callParent\n}\n\n"; + } + + $callParent .= '$returnValue = false;'; + + $this->setBody( + InterceptorGenerator::createInterceptedMethodBody( + $callParent, + $this, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..0a6f58acc410b89e0a14d08d0e7319a6e2099718 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGenerator.php @@ -0,0 +1,85 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Utility to create pre- and post- method interceptors around a given method body + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @internal - this class is just here as a small utility for this component, + * don't use it in your own code + */ +class InterceptorGenerator +{ + /** + * @param string $methodBody the body of the previously generated code. + * It MUST assign the return value to a variable + * `$returnValue` instead of directly returning + * @param \ProxyManager\Generator\MethodGenerator $method + * @param \Zend\Code\Generator\PropertyGenerator $valueHolder + * @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors + * @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors + * + * @return string + */ + public static function createInterceptedMethodBody( + $methodBody, + MethodGenerator $method, + PropertyGenerator $valueHolder, + PropertyGenerator $prefixInterceptors, + PropertyGenerator $suffixInterceptors + ) { + $name = var_export($method->getName(), true); + $valueHolder = $valueHolder->getName(); + $prefixInterceptors = $prefixInterceptors->getName(); + $suffixInterceptors = $suffixInterceptors->getName(); + $params = array(); + + foreach ($method->getParameters() as $parameter) { + $parameterName = $parameter->getName(); + $params[] = var_export($parameterName, true) . ' => $' . $parameter->getName(); + } + + $paramsString = 'array(' . implode(', ', $params) . ')'; + + return "if (isset(\$this->$prefixInterceptors" . "[$name])) {\n" + . " \$returnEarly = false;\n" + . " \$prefixReturnValue = \$this->$prefixInterceptors" . "[$name]->__invoke(" + . "\$this, \$this->$valueHolder, $name, $paramsString, \$returnEarly);\n\n" + . " if (\$returnEarly) {\n" + . " return \$prefixReturnValue;\n" + . " }\n" + . "}\n\n" + . $methodBody . "\n\n" + . "if (isset(\$this->$suffixInterceptors" . "[$name])) {\n" + . " \$returnEarly = false;\n" + . " \$suffixReturnValue = \$this->$suffixInterceptors" . "[$name]->__invoke(" + . "\$this, \$this->$valueHolder, $name, $paramsString, \$returnValue, \$returnEarly);\n\n" + . " if (\$returnEarly) {\n" + . " return \$suffixReturnValue;\n" + . " }\n" + . "}\n\n" + . "return \$returnValue;"; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolderGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolderGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..6abac1fb57284d7636f895698a708c72a099434a --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolderGenerator.php @@ -0,0 +1,130 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup; +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor; +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor; +use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors; +use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodSuffixInterceptors; + +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicClone; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicGet; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicSet; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset; + +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty; + +use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\MagicSleep; +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\ValueHolderInterface} + * and {@see \ProxyManager\Proxy\AccessInterceptorInterface} + * + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorValueHolderGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + $publicProperties = new PublicPropertiesMap($originalClass); + $interfaces = array( + 'ProxyManager\\Proxy\\AccessInterceptorInterface', + 'ProxyManager\\Proxy\\ValueHolderInterface', + ); + + if ($originalClass->isInterface()) { + $interfaces[] = $originalClass->getName(); + } else { + $classGenerator->setExtendedClass($originalClass->getName()); + } + + $classGenerator->setImplementedInterfaces($interfaces); + $classGenerator->addPropertyFromGenerator($valueHolder = new ValueHolderProperty()); + $classGenerator->addPropertyFromGenerator($prefixInterceptors = new MethodPrefixInterceptors()); + $classGenerator->addPropertyFromGenerator($suffixInterceptors = new MethodSuffixInterceptors()); + $classGenerator->addPropertyFromGenerator($publicProperties); + + foreach (ProxiedMethodsFilter::getProxiedMethods($originalClass) as $method) { + $classGenerator->addMethodFromGenerator( + InterceptedMethod::generateMethod( + new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()), + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ) + ); + } + + $classGenerator->addMethodFromGenerator( + new Constructor($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new GetWrappedValueHolderValue($valueHolder) + ); + $classGenerator->addMethodFromGenerator( + new SetMethodPrefixInterceptor($prefixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new SetMethodSuffixInterceptor($suffixInterceptors) + ); + + $classGenerator->addMethodFromGenerator( + new MagicGet($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors, $publicProperties) + ); + + $classGenerator->addMethodFromGenerator( + new MagicSet($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors, $publicProperties) + ); + + $classGenerator->addMethodFromGenerator( + new MagicIsset($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors, $publicProperties) + ); + + $classGenerator->addMethodFromGenerator( + new MagicUnset($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors, $publicProperties) + ); + + $classGenerator->addMethodFromGenerator( + new MagicClone($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors) + ); + $classGenerator->addMethodFromGenerator( + new MagicSleep($originalClass, $valueHolder) + ); + $classGenerator->addMethodFromGenerator( + new MagicWakeup($originalClass, $valueHolder) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php new file mode 100644 index 0000000000000000000000000000000000000000..6f80e2f255a699402f9f71f0cbb7580e8a8e7693 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php @@ -0,0 +1,58 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator; + +use ReflectionClass; +use ReflectionProperty; +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * The `__construct` implementation for lazy loading proxies + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Constructor extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty) + { + parent::__construct('__construct'); + + $this->setParameter(new ParameterGenerator('initializer')); + + /* @var $publicProperties \ReflectionProperty[] */ + $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); + $unsetProperties = array(); + + foreach ($publicProperties as $publicProperty) { + $unsetProperties[] = '$this->' . $publicProperty->getName(); + } + + $this->setDocblock("@override constructor for lazy initialization\n\n@param \\Closure|null \$initializer"); + $this->setBody( + ($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') + . '$this->' . $initializerProperty->getName() . ' = $initializer;' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializer.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializer.php new file mode 100644 index 0000000000000000000000000000000000000000..92be722e725c443bfc31170d41b82a16920e66f8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializer.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::isProxyInitialized} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class CallInitializer extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct( + PropertyGenerator $initializerProperty, + PropertyGenerator $publicPropertiesDefaults, + PropertyGenerator $initializationTracker + ) { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('callInitializer')); + $this->setDocblock("Triggers initialization logic for this ghost object"); + + $this->setParameters(array( + new ParameterGenerator('methodName'), + new ParameterGenerator('parameters', 'array'), + )); + + $this->setVisibility(static::VISIBILITY_PRIVATE); + + $initializer = $initializerProperty->getName(); + $initialization = $initializationTracker->getName(); + + $this->setBody( + 'if ($this->' . $initialization . ' || ! $this->' . $initializer . ') {' . "\n return;\n}\n\n" + . "\$this->" . $initialization . " = true;\n\n" + . "foreach (self::\$" . $publicPropertiesDefaults->getName() . " as \$key => \$default) {\n" + . " \$this->\$key = \$default;\n" + . "}\n\n" + . '$this->' . $initializer . '->__invoke' + . '($this, $methodName, $parameters, $this->' . $initializer . ');' . "\n\n" + . "\$this->" . $initialization . " = false;" + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializer.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializer.php new file mode 100644 index 0000000000000000000000000000000000000000..5b1d75a4f63878eb355ae6e304000d219add01c1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializer.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::getProxyInitializer} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetProxyInitializer extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty) + { + parent::__construct('getProxyInitializer'); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('return $this->' . $initializerProperty->getName() . ';'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxy.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxy.php new file mode 100644 index 0000000000000000000000000000000000000000..cf5d417d7bfeea0e8d5cdd8f0531030823798663 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxy.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Generator\MethodGenerator as ZendMethodGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::initializeProxy} + * for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializeProxy extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty, ZendMethodGenerator $callInitializer) + { + parent::__construct('initializeProxy'); + $this->setDocblock('{@inheritDoc}'); + + $this->setBody( + 'return $this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'initializeProxy\', array());' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitialized.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitialized.php new file mode 100644 index 0000000000000000000000000000000000000000..110ef31733ed7f67d42f9004a2d8e17c973cd868 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitialized.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::isProxyInitialized} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class IsProxyInitialized extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty) + { + parent::__construct('isProxyInitialized'); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('return ! $this->' . $initializerProperty->getName() . ';'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php new file mode 100644 index 0000000000000000000000000000000000000000..c5ce434e35e8fecf6fcc03f716b0050a28c432a9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php @@ -0,0 +1,71 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Generator\MethodGenerator as ZendMethodGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method decorator for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingMethodInterceptor extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\MethodGenerator $callInitializer + * + * @return LazyLoadingMethodInterceptor|static + */ + public static function generateMethod( + MethodReflection $originalMethod, + PropertyGenerator $initializerProperty, + ZendMethodGenerator $callInitializer + ) { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + $parameters = $originalMethod->getParameters(); + $methodName = $originalMethod->getName(); + $initializerParams = array(); + $forwardedParams = array(); + + foreach ($parameters as $parameter) { + $parameterName = $parameter->getName(); + $initializerParams[] = var_export($parameterName, true) . ' => $' . $parameterName; + $forwardedParams[] = '$' . $parameterName; + } + + $method->setBody( + '$this->' . $initializerProperty->getName() + . ' && $this->' . $callInitializer->getName() + . '(' . var_export($methodName, true) + . ', array(' . implode(', ', $initializerParams) . "));\n\n" + . 'return parent::' + . $methodName . '(' . implode(', ', $forwardedParams) . ');' + ); + $method->setDocblock('{@inheritDoc}'); + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicClone.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicClone.php new file mode 100644 index 0000000000000000000000000000000000000000..34d999b7b37d28cb42735de43d9e2d1782c6c8dd --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicClone.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__clone` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicClone extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer + ) { + parent::__construct($originalClass, '__clone'); + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__clone\', array());' + . ($originalClass->hasMethod('__clone') ? "\n\nparent::__clone();" : '') + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGet.php new file mode 100644 index 0000000000000000000000000000000000000000..6ede4695ebf9dc6aa40f13ed6adf09857b207f75 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGet.php @@ -0,0 +1,77 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__get` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGet extends MagicMethodGenerator +{ + /** + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\MethodGenerator $callInitializer + * @param \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap $publicProperties + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__get', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__get'); + $callParent = ''; + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return $this->$name;' + . "\n}\n\n"; + } + + if ($override) { + $callParent .= 'return parent::__get($name);'; + } else { + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'name' + ); + } + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__get\', array(\'name\' => $name));' + . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIsset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIsset.php new file mode 100644 index 0000000000000000000000000000000000000000..6c0f67688c4a76a53e83fcb5e88cf8a6ee304965 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIsset.php @@ -0,0 +1,77 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__isset` method for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIsset extends MagicMethodGenerator +{ + /** + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\MethodGenerator $callInitializer + * @param \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap $publicProperties + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__isset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__isset'); + $callParent = ''; + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return isset($this->$name);' + . "\n}\n\n"; + } + + if ($override) { + $callParent .= 'return parent::__isset($name);'; + } else { + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_ISSET, + 'name' + ); + } + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__isset\', array(\'name\' => $name));' + . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSet.php new file mode 100644 index 0000000000000000000000000000000000000000..76edc5097d41cb8583ebefe2748e34a2b4b8d5c0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSet.php @@ -0,0 +1,81 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__set` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSet extends MagicMethodGenerator +{ + /** + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\MethodGenerator $callInitializer + * @param \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap $publicProperties + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer, + PublicPropertiesMap $publicProperties + ) { + parent::__construct( + $originalClass, + '__set', + array(new ParameterGenerator('name'), new ParameterGenerator('value')) + ); + + $override = $originalClass->hasMethod('__set'); + $callParent = ''; + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return ($this->$name = $value);' + . "\n}\n\n"; + } + + if ($override) { + $callParent .= 'return parent::__set($name, $value);'; + } else { + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'name', + 'value' + ); + } + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__set\', array(\'name\' => $name, \'value\' => $value));' . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleep.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleep.php new file mode 100644 index 0000000000000000000000000000000000000000..a8036b2dd08cc0b438e5ebc8b6e9a7847427ec70 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleep.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__sleep` for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleep extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer + ) { + parent::__construct($originalClass, '__sleep'); + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__sleep\', array());' . "\n\n" + . ($originalClass->hasMethod('__sleep') ? 'return parent::__sleep();' : 'return array_keys((array) $this);') + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnset.php new file mode 100644 index 0000000000000000000000000000000000000000..7ad1357d6070f8f27e190eca4b2757071c58d550 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnset.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__unset` method for lazy loading ghost objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnset extends MagicMethodGenerator +{ + /** + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\MethodGenerator $callInitializer + * @param \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap $publicProperties + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + MethodGenerator $callInitializer, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__unset', array(new ParameterGenerator('name'))); + + $override = $originalClass->hasMethod('__unset'); + $callParent = ''; + + $this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' unset($this->$name);' + . "\n\n return;" + . "\n}\n\n"; + } + + if ($override) { + $callParent .= "return parent::__unset(\$name);"; + } else { + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_UNSET, + 'name' + ); + } + + $this->setBody( + '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() + . '(\'__unset\', array(\'name\' => $name));' + . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializer.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializer.php new file mode 100644 index 0000000000000000000000000000000000000000..30e37bbb7a363410bf51445c83da9929da6dadff --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializer.php @@ -0,0 +1,49 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::setProxyInitializer} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetProxyInitializer extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty) + { + parent::__construct('setProxyInitializer'); + + $initializerParameter = new ParameterGenerator('initializer'); + + $initializerParameter->setType('Closure'); + $initializerParameter->setDefaultValue(null); + $this->setParameter($initializerParameter); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTracker.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTracker.php new file mode 100644 index 0000000000000000000000000000000000000000..41b10d9a444d47d438ccd2a85977e3592b9cbf33 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTracker.php @@ -0,0 +1,43 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the initializer for a lazy object + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializationTracker extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('initializationTracker')); + + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var bool tracks initialization status - true while the object is initializing'); + $this->setDefaultValue(false); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerProperty.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerProperty.php new file mode 100644 index 0000000000000000000000000000000000000000..3a3a65076b53f72ed9b333f9e17e9c0ead86af64 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerProperty.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the initializer for a lazy object + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializerProperty extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('initializer')); + + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\Closure|null initializer responsible for generating the wrapped object'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhostGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhostGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..7a2b4e10e1cd1ec76c4c6c6ab4c87e3c9407e726 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhostGenerator.php @@ -0,0 +1,105 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor; + +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer; + +use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty; + +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\GhostObjectInterface} + * + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingGhostGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + $interfaces = array('ProxyManager\\Proxy\\GhostObjectInterface'); + $publicProperties = new PublicPropertiesMap($originalClass); + $publicPropertiesDefaults = new PublicPropertiesDefaults($originalClass); + + if ($originalClass->isInterface()) { + $interfaces[] = $originalClass->getName(); + } else { + $classGenerator->setExtendedClass($originalClass->getName()); + } + + $classGenerator->setImplementedInterfaces($interfaces); + $classGenerator->addPropertyFromGenerator($initializer = new InitializerProperty()); + $classGenerator->addPropertyFromGenerator($initializationTracker = new InitializationTracker()); + $classGenerator->addPropertyFromGenerator($publicProperties); + $classGenerator->addPropertyFromGenerator($publicPropertiesDefaults); + + $init = new CallInitializer($initializer, $publicPropertiesDefaults, $initializationTracker); + + $classGenerator->addMethodFromGenerator($init); + + foreach (ProxiedMethodsFilter::getProxiedMethods($originalClass) as $method) { + $classGenerator->addMethodFromGenerator( + LazyLoadingMethodInterceptor::generateMethod( + new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()), + $initializer, + $init + ) + ); + } + + $classGenerator->addMethodFromGenerator(new Constructor($originalClass, $initializer)); + + $classGenerator->addMethodFromGenerator(new MagicGet($originalClass, $initializer, $init, $publicProperties)); + $classGenerator->addMethodFromGenerator(new MagicSet($originalClass, $initializer, $init, $publicProperties)); + $classGenerator->addMethodFromGenerator(new MagicIsset($originalClass, $initializer, $init, $publicProperties)); + $classGenerator->addMethodFromGenerator(new MagicUnset($originalClass, $initializer, $init, $publicProperties)); + $classGenerator->addMethodFromGenerator(new MagicClone($originalClass, $initializer, $init)); + $classGenerator->addMethodFromGenerator(new MagicSleep($originalClass, $initializer, $init)); + + $classGenerator->addMethodFromGenerator(new SetProxyInitializer($initializer)); + $classGenerator->addMethodFromGenerator(new GetProxyInitializer($initializer)); + $classGenerator->addMethodFromGenerator(new InitializeProxy($initializer, $init)); + $classGenerator->addMethodFromGenerator(new IsProxyInitialized($initializer)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializer.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializer.php new file mode 100644 index 0000000000000000000000000000000000000000..3dd0854845bd9b49aad85452e61bdbf1f0c326d6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializer.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::getProxyInitializer} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetProxyInitializer extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty) + { + parent::__construct('getProxyInitializer'); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('return $this->' . $initializerProperty->getName() . ';'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxy.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxy.php new file mode 100644 index 0000000000000000000000000000000000000000..4c358b100c4fa133956a5e8ad8069aae6b8c4b36 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxy.php @@ -0,0 +1,49 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::initializeProxy} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializeProxy extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty) + { + parent::__construct('initializeProxy'); + $this->setDocblock('{@inheritDoc}'); + + $initializer = $initializerProperty->getName(); + + $this->setBody( + 'return $this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolderProperty->getName() + . ', $this, \'initializeProxy\', array(), $this->' . $initializer . ');' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitialized.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitialized.php new file mode 100644 index 0000000000000000000000000000000000000000..34fdd0bd8880585ce487f45dd6430c50fd59ca0c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitialized.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::isProxyInitialized} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class IsProxyInitialized extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $valueHolderProperty) + { + parent::__construct('isProxyInitialized'); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('return null !== $this->' . $valueHolderProperty->getName() . ';'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptor.php new file mode 100644 index 0000000000000000000000000000000000000000..b4ce370a3d99f3bd617ced0ff2ea6cc1bedba76c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptor.php @@ -0,0 +1,72 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method decorator for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingMethodInterceptor extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty + * @param \Zend\Code\Generator\PropertyGenerator $valueHolderProperty + * + * @return LazyLoadingMethodInterceptor|static + */ + public static function generateMethod( + MethodReflection $originalMethod, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty + ) { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + $initializerName = $initializerProperty->getName(); + $valueHolderName = $valueHolderProperty->getName(); + $parameters = $originalMethod->getParameters(); + $methodName = $originalMethod->getName(); + $initializerParams = array(); + $forwardedParams = array(); + + foreach ($parameters as $parameter) { + $parameterName = $parameter->getName(); + $initializerParams[] = var_export($parameterName, true) . ' => $' . $parameterName; + $forwardedParams[] = '$' . $parameterName; + } + + $method->setBody( + '$this->' . $initializerName + . ' && $this->' . $initializerName + . '->__invoke($this->' . $valueHolderName . ', $this, ' . var_export($methodName, true) + . ', array(' . implode(', ', $initializerParams) . '), $this->' . $initializerName . ");\n\n" + . 'return $this->' . $valueHolderName . '->' + . $methodName . '(' . implode(', ', $forwardedParams) . ');' + ); + $method->setDocblock('{@inheritDoc}'); + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicClone.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicClone.php new file mode 100644 index 0000000000000000000000000000000000000000..d62c46ab17c1ccb37c4dec62e6ac1ab473a92a9c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicClone.php @@ -0,0 +1,53 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__clone` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicClone extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty + ) { + parent::__construct($originalClass, '__clone'); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder + . ', $this, \'__clone\', array(), $this->' . $initializer . ');' . "\n\n" + . '$this->' . $valueHolder . ' = clone $this->' . $valueHolder . ';' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGet.php new file mode 100644 index 0000000000000000000000000000000000000000..ea7fcbcf000b199b2ce93a9e7bc007416fb63014 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGet.php @@ -0,0 +1,69 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__get` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGet extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__get', array(new ParameterGenerator('name'))); + + $this->setDocblock(($originalClass->hasMethod('__get') ? "{@inheritDoc}\n" : '') . '@param string $name'); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return $this->' . $valueHolder . '->$name;' + . "\n}\n\n"; + + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'name', + null, + $valueHolderProperty + ); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder . ', $this, \'__get\', array(\'name\' => $name), $this->' + . $initializer . ');' + . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIsset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIsset.php new file mode 100644 index 0000000000000000000000000000000000000000..09e4a85d3cbe25c81f2c3d0996ae24edfabfa181 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIsset.php @@ -0,0 +1,72 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__isset` method for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIsset extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__isset', array(new ParameterGenerator('name'))); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + $callParent = ''; + + $this->setDocblock(($originalClass->hasMethod('__isset') ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return isset($this->' . $valueHolder . '->$name);' + . "\n}\n\n"; + } + + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_ISSET, + 'name', + null, + $valueHolderProperty + ); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder . ', $this, \'__isset\', array(\'name\' => $name), $this->' + . $initializer . ');' . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSet.php new file mode 100644 index 0000000000000000000000000000000000000000..b797b57251985aa9ca68b848df5032fad4b2f53c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSet.php @@ -0,0 +1,79 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__set` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSet extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty, + PublicPropertiesMap $publicProperties + ) { + parent::__construct( + $originalClass, + '__set', + array(new ParameterGenerator('name'), new ParameterGenerator('value')) + ); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + $callParent = ''; + + $this->setDocblock( + ($originalClass->hasMethod('__set') ? "{@inheritDoc}\n" : '') . "@param string \$name\n@param mixed \$value" + ); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' return ($this->' . $valueHolder . '->$name = $value);' + . "\n}\n\n"; + } + + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'name', + 'value', + $valueHolderProperty + ); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder . ', $this, ' + . '\'__set\', array(\'name\' => $name, \'value\' => $value), $this->' . $initializer . ');' + . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleep.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleep.php new file mode 100644 index 0000000000000000000000000000000000000000..20051c8f2ee01f2ccfe7da0117bc5fd6dcf3e200 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleep.php @@ -0,0 +1,53 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__sleep` for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleep extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty + ) { + parent::__construct($originalClass, '__sleep'); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder . ', $this, \'__sleep\', array(), $this->' + . $initializer . ');' . "\n\n" + . 'return array(' . var_export($valueHolder, true) . ');' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnset.php new file mode 100644 index 0000000000000000000000000000000000000000..7ee256ee215d25c4391356c3c54f9decaac2ec01 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnset.php @@ -0,0 +1,72 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__unset` method for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnset extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct( + ReflectionClass $originalClass, + PropertyGenerator $initializerProperty, + PropertyGenerator $valueHolderProperty, + PublicPropertiesMap $publicProperties + ) { + parent::__construct($originalClass, '__unset', array(new ParameterGenerator('name'))); + + $initializer = $initializerProperty->getName(); + $valueHolder = $valueHolderProperty->getName(); + $callParent = ''; + + $this->setDocblock(($originalClass->hasMethod('__isset') ? "{@inheritDoc}\n" : '') . '@param string $name'); + + if (! $publicProperties->isEmpty()) { + $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" + . ' unset($this->' . $valueHolder . '->$name);' . "\n\n return;" + . "\n}\n\n"; + } + + $callParent .= PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_UNSET, + 'name', + null, + $valueHolderProperty + ); + + $this->setBody( + '$this->' . $initializer . ' && $this->' . $initializer + . '->__invoke($this->' . $valueHolder . ', $this, \'__unset\', array(\'name\' => $name), $this->' + . $initializer . ');' . "\n\n" . $callParent + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializer.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializer.php new file mode 100644 index 0000000000000000000000000000000000000000..db3400f5b96136c656d08003afb8b39afbd77260 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializer.php @@ -0,0 +1,49 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\LazyLoadingInterface::setProxyInitializer} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetProxyInitializer extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $initializerProperty) + { + parent::__construct('setProxyInitializer'); + + $initializerParameter = new ParameterGenerator('initializer'); + + $initializerParameter->setType('Closure'); + $initializerParameter->setDefaultValue(null); + $this->setParameter($initializerParameter); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerProperty.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerProperty.php new file mode 100644 index 0000000000000000000000000000000000000000..317306515f82f0bf5b95ce858773f3b5338691ed --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerProperty.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the initializer for a lazy object + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializerProperty extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('initializer')); + + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\Closure|null initializer responsible for generating the wrapped object'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderProperty.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderProperty.php new file mode 100644 index 0000000000000000000000000000000000000000..7053e6d3d420842bcd2b19e0d40acd505a913b71 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderProperty.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the wrapped value of a lazy loading proxy + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ValueHolderProperty extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('valueHolder')); + + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\Closure|null initializer responsible for generating the wrapped object'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolderGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolderGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..b4be5abd4f55dd0f508767b8c3fb83d72f268bb1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolderGenerator.php @@ -0,0 +1,112 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue; + +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup; + +use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty; + +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\VirtualProxyInterface} + * + * {@inheritDoc} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingValueHolderGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + $interfaces = array('ProxyManager\\Proxy\\VirtualProxyInterface'); + $publicProperties = new PublicPropertiesMap($originalClass); + + if ($originalClass->isInterface()) { + $interfaces[] = $originalClass->getName(); + } else { + $classGenerator->setExtendedClass($originalClass->getName()); + } + + $classGenerator->setImplementedInterfaces($interfaces); + $classGenerator->addPropertyFromGenerator($valueHolder = new ValueHolderProperty()); + $classGenerator->addPropertyFromGenerator($initializer = new InitializerProperty()); + $classGenerator->addPropertyFromGenerator($publicProperties); + + foreach (ProxiedMethodsFilter::getProxiedMethods($originalClass) as $method) { + $classGenerator->addMethodFromGenerator( + LazyLoadingMethodInterceptor::generateMethod( + new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()), + $initializer, + $valueHolder + ) + ); + } + + $classGenerator->addMethodFromGenerator(new Constructor($originalClass, $initializer)); + + $classGenerator->addMethodFromGenerator( + new MagicGet($originalClass, $initializer, $valueHolder, $publicProperties) + ); + $classGenerator->addMethodFromGenerator( + new MagicSet($originalClass, $initializer, $valueHolder, $publicProperties) + ); + $classGenerator->addMethodFromGenerator( + new MagicIsset($originalClass, $initializer, $valueHolder, $publicProperties) + ); + $classGenerator->addMethodFromGenerator( + new MagicUnset($originalClass, $initializer, $valueHolder, $publicProperties) + ); + $classGenerator->addMethodFromGenerator(new MagicClone($originalClass, $initializer, $valueHolder)); + $classGenerator->addMethodFromGenerator(new MagicSleep($originalClass, $initializer, $valueHolder)); + $classGenerator->addMethodFromGenerator(new MagicWakeup($originalClass)); + + $classGenerator->addMethodFromGenerator(new SetProxyInitializer($initializer)); + $classGenerator->addMethodFromGenerator(new GetProxyInitializer($initializer)); + $classGenerator->addMethodFromGenerator(new InitializeProxy($initializer, $valueHolder)); + $classGenerator->addMethodFromGenerator(new IsProxyInitialized($valueHolder)); + + $classGenerator->addMethodFromGenerator(new GetWrappedValueHolderValue($valueHolder)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php new file mode 100644 index 0000000000000000000000000000000000000000..79dc165564d1d40ab7b6a002fb7c7c106ffe87f4 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\NullObject\MethodGenerator; + +use ReflectionClass; +use ReflectionProperty; +use ProxyManager\Generator\MethodGenerator; + +/** + * The `__construct` implementation for null object proxies + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class Constructor extends MethodGenerator +{ + /** + * Constructor + * + * @param ReflectionClass $originalClass Reflection of the class to proxy + */ + public function __construct(ReflectionClass $originalClass) + { + parent::__construct('__construct'); + + /* @var $publicProperties \ReflectionProperty[] */ + $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); + $nullableProperties = array(); + + foreach ($publicProperties as $publicProperty) { + $nullableProperties[] = '$this->' . $publicProperty->getName() . ' = null;'; + } + + $this->setDocblock("@override constructor for null object initialization"); + if ($nullableProperties) { + $this->setBody(implode("\n", $nullableProperties)); + } + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php new file mode 100644 index 0000000000000000000000000000000000000000..2b63e50426cbdc67921e5c1e2c7d5e7180606359 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptor.php @@ -0,0 +1,53 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\NullObject\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Method decorator for null objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectMethodInterceptor extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * + * @return NullObjectMethodInterceptor|static + */ + public static function generateMethod(MethodReflection $originalMethod) + { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + + if ($originalMethod->returnsReference()) { + $reference = UniqueIdentifierGenerator::getIdentifier('ref'); + + $method->setBody("\$$reference = null;\nreturn \$$reference;"); + } else { + $method->setBody(''); + } + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObjectGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObjectGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..61983a2593a7ed68430b12029a70e954260acbeb --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObjectGenerator.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor; +use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor; + +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ReflectionClass; + +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\NullObjectInterface} + * + * {@inheritDoc} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + $interfaces = array('ProxyManager\\Proxy\\NullObjectInterface'); + + if ($originalClass->isInterface()) { + $interfaces[] = $originalClass->getName(); + } else { + foreach ($originalClass->getInterfaceNames() as $name) { + $interfaces[] = $name; + } + } + + $classGenerator->setImplementedInterfaces($interfaces); + + foreach (ProxiedMethodsFilter::getProxiedMethods($originalClass) as $method) { + $classGenerator->addMethodFromGenerator( + NullObjectMethodInterceptor::generateMethod( + new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()) + ) + ); + } + + $classGenerator->addMethodFromGenerator(new Constructor($originalClass)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php new file mode 100644 index 0000000000000000000000000000000000000000..d13d7c7703772af3095d2d88226b9ef81e3dab95 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php @@ -0,0 +1,58 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\PropertyGenerator; + +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use Zend\Code\Generator\PropertyGenerator; +use ReflectionClass; +use ReflectionProperty; + +/** + * Map of public properties that exist in the class being proxied + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class PublicPropertiesDefaults extends PropertyGenerator +{ + /** + * @var bool[] + */ + private $publicProperties = array(); + + /** + * @param \ReflectionClass $originalClass + */ + public function __construct(ReflectionClass $originalClass) + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('publicPropertiesDefaults')); + + $defaults = $originalClass->getDefaultProperties(); + + foreach ($originalClass->getProperties(ReflectionProperty::IS_PUBLIC) as $publicProperty) { + $name = $publicProperty->getName(); + $this->publicProperties[$name] = $defaults[$name]; + } + + $this->setDefaultValue($this->publicProperties); + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setStatic(true); + $this->setDocblock('@var mixed[] map of default property values of the parent class'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesMap.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesMap.php new file mode 100644 index 0000000000000000000000000000000000000000..8b26a7e75c0c8532605a4d4dd997437471c4583b --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesMap.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\PropertyGenerator; + +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use Zend\Code\Generator\PropertyGenerator; +use ReflectionClass; +use ReflectionProperty; + +/** + * Map of public properties that exist in the class being proxied + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class PublicPropertiesMap extends PropertyGenerator +{ + /** + * @var bool[] + */ + private $publicProperties = array(); + + /** + * @param \ReflectionClass $originalClass + */ + public function __construct(ReflectionClass $originalClass) + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('publicProperties')); + + foreach ($originalClass->getProperties(ReflectionProperty::IS_PUBLIC) as $publicProperty) { + $this->publicProperties[$publicProperty->getName()] = true; + } + + $this->setDefaultValue($this->publicProperties); + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setStatic(true); + $this->setDocblock('@var bool[] map of public properties of the parent class'); + } + + /** + * @return bool whether there are no public properties + */ + public function isEmpty() + { + return empty($this->publicProperties); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ProxyGeneratorInterface.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ProxyGeneratorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..df88aa8873257220f53c5694ded66c2944ec0b54 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ProxyGeneratorInterface.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; + +/** + * Base interface for proxy generators - describes how a proxy generator should use + * reflection classes to modify given class generators + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface ProxyGeneratorInterface +{ + /** + * Apply modifications to the provided $classGenerator to proxy logic from $originalClass + * + * @param \ReflectionClass $originalClass + * @param \Zend\Code\Generator\ClassGenerator $classGenerator + * + * @return void + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator); +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php new file mode 100644 index 0000000000000000000000000000000000000000..1a3ae69c14f0ba0da2d9240ce77efd69562be9b5 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ReflectionClass; +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * The `__construct` implementation for remote object proxies + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class Constructor extends MethodGenerator +{ + /** + * Constructor + * + * @param ReflectionClass $originalClass Reflection of the class to proxy + * @param PropertyGenerator $adapter Adapter property + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapter) + { + parent::__construct('__construct'); + + $adapterName = $adapter->getName(); + + $this->setParameter(new ParameterGenerator($adapterName, 'ProxyManager\Factory\RemoteObject\AdapterInterface')); + + $this->setDocblock( + '@override constructor for remote object control\n\n' + . '@param \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface \$adapter' + ); + + $body = '$this->' . $adapterName . ' = $' . $adapterName . ';'; + + foreach ($originalClass->getProperties() as $property) { + if ($property->isPublic() && ! $property->isStatic()) { + $body .= "\nunset(\$this->" . $property->getName() . ');'; + } + } + + $this->setBody($body); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicGet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicGet.php new file mode 100644 index 0000000000000000000000000000000000000000..e321263bbda6fc8c211f994f31a784aa10fe45cb --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicGet.php @@ -0,0 +1,49 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__get` for remote objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicGet extends MagicMethodGenerator +{ + /** + * Constructor + * @param ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $adapterProperty + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty) + { + parent::__construct($originalClass, '__get', array(new ParameterGenerator('name'))); + + $this->setDocblock('@param string $name'); + $this->setBody( + '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) + . ', \'__get\', array($name));' . "\n\n" . 'return $return;' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicIsset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicIsset.php new file mode 100644 index 0000000000000000000000000000000000000000..cf24797acf671ffd1c7a582d5460682c31e75dfb --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicIsset.php @@ -0,0 +1,50 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__isset` method for remote objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicIsset extends MagicMethodGenerator +{ + /** + * Constructor + * @param ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $adapterProperty + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty) + { + parent::__construct($originalClass, '__isset', array(new ParameterGenerator('name'))); + + $this->setDocblock('@param string $name'); + $this->setBody( + '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) + . ', \'__isset\', array($name));' . "\n\n" + . 'return $return;' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicSet.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicSet.php new file mode 100644 index 0000000000000000000000000000000000000000..6efaaf232e9e428af49a032b56d9c847ea0cf1ef --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicSet.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__set` for remote objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicSet extends MagicMethodGenerator +{ + /** + * Constructor + * @param ReflectionClass $originalClass + * @param \Zend\Code\Generator\PropertyGenerator $adapterProperty + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty) + { + parent::__construct( + $originalClass, + '__set', + array(new ParameterGenerator('name'), new ParameterGenerator('value')) + ); + + $this->setDocblock('@param string \$name\n@param mixed \$value'); + $this->setBody( + '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) + . ', \'__set\', array($name, $value));' . "\n\n" + . 'return $return;' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnset.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnset.php new file mode 100644 index 0000000000000000000000000000000000000000..ffe34fbef38b605c3fe1226c40b24e6f723b51db --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnset.php @@ -0,0 +1,51 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__unset` method for remote objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicUnset extends MagicMethodGenerator +{ + /** + * Constructor + * + * @param ReflectionClass $originalClass + * @param PropertyGenerator $adapterProperty + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty) + { + parent::__construct($originalClass, '__unset', array(new ParameterGenerator('name'))); + + $this->setDocblock('@param string $name'); + $this->setBody( + '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) + . ', \'__unset\', array($name));' . "\n\n" + . 'return $return;' + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethod.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethod.php new file mode 100644 index 0000000000000000000000000000000000000000..3d0d1de5e29bb1862201e3f80b8898a6652741ca --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethod.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; +use Zend\Code\Reflection\MethodReflection; +use ReflectionClass; + +/** + * Method decorator for remote objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectMethod extends MethodGenerator +{ + /** + * @param \Zend\Code\Reflection\MethodReflection $originalMethod + * @param \Zend\Code\Generator\PropertyGenerator $adapterProperty + * @param \ReflectionClass $originalClass + * + * @return RemoteObjectMethod|static + */ + public static function generateMethod( + MethodReflection $originalMethod, + PropertyGenerator $adapterProperty, + ReflectionClass $originalClass + ) { + /* @var $method self */ + $method = static::fromReflection($originalMethod); + $parameters = $originalMethod->getParameters(); + $list = array(); + + foreach ($parameters as $parameter) { + $list[] = '$' . $parameter->getName(); + } + + $method->setBody( + '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) + . ', ' . var_export($originalMethod->getName(), true) . ', array('. implode(', ', $list) .'));' . "\n\n" + . 'return $return;' + ); + + return $method; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterProperty.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterProperty.php new file mode 100644 index 0000000000000000000000000000000000000000..10b3dc64ed33061b2f8b51e53c1ffb5564ecde29 --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterProperty.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator; + +use Zend\Code\Generator\PropertyGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Property that contains the remote object adapter + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class AdapterProperty extends PropertyGenerator +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(UniqueIdentifierGenerator::getIdentifier('adapter')); + + $this->setVisibility(self::VISIBILITY_PRIVATE); + $this->setDocblock('@var \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface Remote web service adapter'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObjectGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObjectGenerator.php new file mode 100644 index 0000000000000000000000000000000000000000..d84f02f82a27b5b9f3265f6d9dfe5101f7f4fa3c --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObjectGenerator.php @@ -0,0 +1,84 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator; + +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod; +use ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset; + +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ReflectionClass; +use Zend\Code\Generator\ClassGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Generator for proxies implementing {@see \ProxyManager\Proxy\RemoteObjectInterface} + * + * {@inheritDoc} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectGenerator implements ProxyGeneratorInterface +{ + /** + * {@inheritDoc} + */ + public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) + { + $interfaces = array('ProxyManager\\Proxy\\RemoteObjectInterface'); + + if ($originalClass->isInterface()) { + $interfaces[] = $originalClass->getName(); + } else { + $classGenerator->setExtendedClass($originalClass->getName()); + } + + $classGenerator->setImplementedInterfaces($interfaces); + $classGenerator->addPropertyFromGenerator($adapter = new AdapterProperty()); + + $methods = ProxiedMethodsFilter::getProxiedMethods( + $originalClass, + array('__get', '__set', '__isset', '__unset') + ); + + foreach ($methods as $method) { + $classGenerator->addMethodFromGenerator( + RemoteObjectMethod::generateMethod( + new MethodReflection( + $method->getDeclaringClass()->getName(), + $method->getName() + ), + $adapter, + $originalClass + ) + ); + } + + $classGenerator->addMethodFromGenerator(new Constructor($originalClass, $adapter)); + $classGenerator->addMethodFromGenerator(new MagicGet($originalClass, $adapter)); + $classGenerator->addMethodFromGenerator(new MagicSet($originalClass, $adapter)); + $classGenerator->addMethodFromGenerator(new MagicIsset($originalClass, $adapter)); + $classGenerator->addMethodFromGenerator(new MagicUnset($originalClass, $adapter)); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php new file mode 100644 index 0000000000000000000000000000000000000000..6024e3344bf6300667c41c0d8fec1de90a8ab01f --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php @@ -0,0 +1,56 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\Util; + +use ReflectionClass; +use ReflectionMethod; + +/** + * Utility class used to filter methods that can be proxied + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ProxiedMethodsFilter +{ + /** + * @param ReflectionClass $class reflection class from which methods should be extracted + * @param string[] $excluded methods to be ignored + * + * @return ReflectionMethod[] + */ + public static function getProxiedMethods( + ReflectionClass $class, + array $excluded = array('__get', '__set', '__isset', '__unset', '__clone', '__sleep', '__wakeup') + ) { + $ignored = array_flip(array_map('strtolower', $excluded)); + + return array_filter( + $class->getMethods(ReflectionMethod::IS_PUBLIC), + function (ReflectionMethod $method) use ($ignored) { + return ! ( + $method->isConstructor() + || isset($ignored[strtolower($method->getName())]) + || $method->isFinal() + || $method->isStatic() + ); + } + ); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php new file mode 100644 index 0000000000000000000000000000000000000000..5a823e980d02e5c6aa116daebb5321c5024a12bc --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php @@ -0,0 +1,190 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\Util; + +use Zend\Code\Generator\PropertyGenerator; + +/** + * Generates code necessary to simulate a fatal error in case of unauthorized + * access to class members in magic methods even when in child classes and dealing + * with protected members. + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class PublicScopeSimulator +{ + const OPERATION_SET = 'set'; + const OPERATION_GET = 'get'; + const OPERATION_ISSET = 'isset'; + const OPERATION_UNSET = 'unset'; + + /** + * Generates code for simulating access to a property from the scope that is accessing a proxy. + * This is done by introspecting `debug_backtrace()` and then binding a closure to the scope + * of the parent caller. + * + * @param string $operationType operation to execute: one of 'get', 'set', 'isset' or 'unset' + * @param string $nameParameter name of the `name` parameter of the magic method + * @param string|null $valueParameter name of the `value` parameter of the magic method + * @param PropertyGenerator $valueHolder name of the property containing the target object from which + * to read the property. `$this` if none provided + * @param string|null $returnPropertyName name of the property to which we want to assign the result of + * the operation. Return directly if none provided + * + * @return string + * + * @throws \InvalidArgumentException + */ + public static function getPublicAccessSimulationCode( + $operationType, + $nameParameter, + $valueParameter = null, + PropertyGenerator $valueHolder = null, + $returnPropertyName = null + ) { + $byRef = self::getByRefReturnValue($operationType); + $value = static::OPERATION_SET === $operationType ? ', $value' : ''; + $target = '$this'; + + if ($valueHolder) { + $target = '$this->' . $valueHolder->getName(); + } + + return '$realInstanceReflection = new \\ReflectionClass(get_parent_class($this));' . "\n\n" + . 'if (! $realInstanceReflection->hasProperty($' . $nameParameter . ')) {' . "\n" + . ' $targetObject = ' . $target . ';' . "\n\n" + . self::getUndefinedPropertyNotice($operationType, $nameParameter) + . ' ' . self::getOperation($operationType, $nameParameter, $valueParameter) . ";\n" + . " return;\n" + . '}' . "\n\n" + . '$targetObject = ' . self::getTargetObject($valueHolder) . ";\n" + . '$accessor = function ' . $byRef . '() use ($targetObject, $name' . $value . ') {' . "\n" + . ' ' . self::getOperation($operationType, $nameParameter, $valueParameter) . "\n" + . "};\n" + . self::getScopeReBind() + . ( + $returnPropertyName + ? '$' . $returnPropertyName . ' = ' . $byRef . '$accessor();' + : '$returnValue = ' . $byRef . '$accessor();' . "\n\n" . 'return $returnValue;' + ); + } + + /** + * This will generate code that triggers a notice if access is attempted on a non-existing property + * + * @param string $operationType + * @param string $nameParameter + * + * @return string + */ + private static function getUndefinedPropertyNotice($operationType, $nameParameter) + { + if (static::OPERATION_GET !== $operationType) { + return ''; + } + + // + return ' $backtrace = debug_backtrace(false);' . "\n" + . ' trigger_error(\'Undefined property: \' . get_parent_class($this) . \'::$\' . $' + . $nameParameter + . ' . \' in \' . $backtrace[0][\'file\'] . \' on line \' . $backtrace[0][\'line\'], \E_USER_NOTICE);' + . "\n"; + } + + /** + * Defines whether the given operation produces a reference. + * + * Note: if the object is a wrapper, the wrapped instance is accessed directly. If the object + * is a ghost or the proxy has no wrapper, then an instance of the parent class is created via + * on-the-fly unserialization + * + * @param string $operationType + * + * @return string + */ + private static function getByRefReturnValue($operationType) + { + return (static::OPERATION_GET === $operationType || static::OPERATION_SET === $operationType) ? '& ' : ''; + } + + /** + * Retrieves the logic to fetch the object on which access should be attempted + * + * @param PropertyGenerator $valueHolder + * + * @return string + */ + private static function getTargetObject(PropertyGenerator $valueHolder = null) + { + if ($valueHolder) { + return '$this->' . $valueHolder->getName(); + } + + return 'unserialize(sprintf(\'O:%d:"%s":0:{}\', strlen(get_parent_class($this)), get_parent_class($this)))'; + } + + /** + * @param string $operationType + * @param string $nameParameter + * @param string|null $valueParameter + * + * @return string + * + * @throws \InvalidArgumentException + */ + private static function getOperation($operationType, $nameParameter, $valueParameter) + { + switch ($operationType) { + case static::OPERATION_GET: + return 'return $targetObject->$' . $nameParameter . ";"; + case static::OPERATION_SET: + if (! $valueParameter) { + throw new \InvalidArgumentException('Parameter $valueParameter not provided'); + } + + return 'return $targetObject->$' . $nameParameter . ' = $' . $valueParameter . ';'; + case static::OPERATION_ISSET: + return 'return isset($targetObject->$' . $nameParameter . ');'; + case static::OPERATION_UNSET: + return 'unset($targetObject->$' . $nameParameter . ');'; + } + + throw new \InvalidArgumentException(sprintf('Invalid operation "%s" provided', $operationType)); + } + + /** + * Generates code to bind operations to the parent scope if supported by the current PHP version + * + * @return string + */ + private static function getScopeReBind() + { + if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) { + // @codeCoverageIgnoreStart + return ''; + // @codeCoverageIgnoreEnd + } + + return ' $backtrace = debug_backtrace(true);' . "\n" + . ' $scopeObject = isset($backtrace[1][\'object\'])' + . ' ? $backtrace[1][\'object\'] : new \stdClass();' . "\n" + . ' $accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));' . "\n"; + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValue.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValue.php new file mode 100644 index 0000000000000000000000000000000000000000..7db81d375e7e7bb88ee4ea108d4ae23dc9a9c8cc --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValue.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator; + +use ProxyManager\Generator\MethodGenerator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Implementation for {@see \ProxyManager\Proxy\ValueHolderInterface::getWrappedValueHolderValue} + * for lazy loading value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetWrappedValueHolderValue extends MethodGenerator +{ + /** + * Constructor + */ + public function __construct(PropertyGenerator $valueHolderProperty) + { + parent::__construct('getWrappedValueHolderValue'); + $this->setDocblock('{@inheritDoc}'); + $this->setBody('return $this->' . $valueHolderProperty->getName() . ';'); + } +} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleep.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleep.php new file mode 100644 index 0000000000000000000000000000000000000000..17aa0fd6345072a426539a451fa8c6c3eb2c96ea --- /dev/null +++ b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleep.php @@ -0,0 +1,42 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator; + +use ProxyManager\Generator\MagicMethodGenerator; +use ReflectionClass; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Magic `__sleep` for value holder objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleep extends MagicMethodGenerator +{ + /** + * Constructor + */ + public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolderProperty) + { + parent::__construct($originalClass, '__sleep'); + + $this->setBody('return array(' . var_export($valueHolderProperty->getName(), true) . ');'); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/Bootstrap.php b/vendor/ocramius/proxy-manager/tests/Bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..9f84dcd692c8bba4052de9a9e26dc7220a1c6466 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/Bootstrap.php @@ -0,0 +1,39 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +ini_set('error_reporting', E_ALL | E_STRICT); + +$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'); + +foreach ($files as $file) { + if (file_exists($file)) { + $loader = require $file; + + break; + } +} + +if (! isset($loader)) { + throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); +} + +/* @var $loader \Composer\Autoload\ClassLoader */ +$loader->add('ProxyManagerTest\\', __DIR__); +$loader->add('ProxyManagerTestAsset\\', __DIR__); + +unset($files, $file, $loader); diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0a662c2042ba040c09cb67c340ed82667e2650dd --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php @@ -0,0 +1,130 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Autoloader; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Autoloader\Autoloader; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\Autoloader\Autoloader} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AutoloaderTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \ProxyManager\Autoloader\Autoloader + */ + protected $autoloader; + + /** + * @var \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fileLocator; + + /** + * @var \ProxyManager\Inflector\ClassNameInflectorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $classNameInflector; + + /** + * @covers \ProxyManager\Autoloader\Autoloader::__construct + */ + public function setUp() + { + $this->fileLocator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); + $this->classNameInflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this->autoloader = new Autoloader($this->fileLocator, $this->classNameInflector); + } + + /** + * @covers \ProxyManager\Autoloader\Autoloader::__invoke + */ + public function testWillNotAutoloadUserClasses() + { + $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar'); + $this + ->classNameInflector + ->expects($this->once()) + ->method('isProxyClassName') + ->with($className) + ->will($this->returnValue(false)); + + $this->assertFalse($this->autoloader->__invoke($className)); + } + + /** + * @covers \ProxyManager\Autoloader\Autoloader::__invoke + */ + public function testWillNotAutoloadNonExistingClass() + { + $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar'); + $this + ->classNameInflector + ->expects($this->once()) + ->method('isProxyClassName') + ->with($className) + ->will($this->returnValue(true)); + $this + ->fileLocator + ->expects($this->once()) + ->method('getProxyFileName') + ->will($this->returnValue(__DIR__ . '/non-existing')); + + $this->assertFalse($this->autoloader->__invoke($className)); + } + + /** + * @covers \ProxyManager\Autoloader\Autoloader::__invoke + */ + public function testWillNotAutoloadExistingClass() + { + $this->assertFalse($this->autoloader->__invoke(__CLASS__)); + } + + /** + * @covers \ProxyManager\Autoloader\Autoloader::__invoke + */ + public function testWillAutoloadExistingFile() + { + $namespace = 'Foo'; + $className = UniqueIdentifierGenerator::getIdentifier('Bar'); + $fqcn = $namespace . '\\' . $className; + $fileName = sys_get_temp_dir() . '/foo_' . uniqid() . '.php'; + + file_put_contents($fileName, '<?php namespace ' . $namespace . '; class ' . $className . '{}'); + + $this + ->classNameInflector + ->expects($this->once()) + ->method('isProxyClassName') + ->with($fqcn) + ->will($this->returnValue(true)); + $this + ->fileLocator + ->expects($this->once()) + ->method('getProxyFileName') + ->will($this->returnValue($fileName)); + + $this->assertTrue($this->autoloader->__invoke($fqcn)); + $this->assertTrue(class_exists($fqcn, false)); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..34354636acb1d4de3b978b1161852b408b977997 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php @@ -0,0 +1,124 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Configuration; + +/** + * Tests for {@see \ProxyManager\Configuration} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConfigurationTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \ProxyManager\Configuration + */ + protected $configuration; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->configuration = new Configuration(); + } + + /** + * @covers \ProxyManager\Configuration::getProxiesNamespace + * @covers \ProxyManager\Configuration::setProxiesNamespace + */ + public function testGetSetProxiesNamespace() + { + $this->assertSame( + 'ProxyManagerGeneratedProxy', + $this->configuration->getProxiesNamespace(), + 'Default setting check for BC' + ); + + $this->configuration->setProxiesNamespace('foo'); + $this->assertSame('foo', $this->configuration->getProxiesNamespace()); + } + + /** + * @covers \ProxyManager\Configuration::getClassNameInflector + * @covers \ProxyManager\Configuration::setClassNameInflector + */ + public function testSetGetClassNameInflector() + { + $this->assertInstanceOf( + 'ProxyManager\\Inflector\\ClassNameInflectorInterface', + $this->configuration->getClassNameInflector() + ); + + $inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + + $this->configuration->setClassNameInflector($inflector); + $this->assertSame($inflector, $this->configuration->getClassNameInflector()); + } + + /** + * @covers \ProxyManager\Configuration::getGeneratorStrategy + * @covers \ProxyManager\Configuration::setGeneratorStrategy + */ + public function testSetGetGeneratorStrategy() + { + + $this->assertInstanceOf( + 'ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface', + $this->configuration->getGeneratorStrategy() + ); + + $strategy = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); + + $this->configuration->setGeneratorStrategy($strategy); + $this->assertSame($strategy, $this->configuration->getGeneratorStrategy()); + } + + /** + * @covers \ProxyManager\Configuration::getProxiesTargetDir + * @covers \ProxyManager\Configuration::setProxiesTargetDir + */ + public function testSetGetProxiesTargetDir() + { + $this->assertTrue(is_dir($this->configuration->getProxiesTargetDir())); + + $this->configuration->setProxiesTargetDir(__DIR__); + $this->assertSame(__DIR__, $this->configuration->getProxiesTargetDir()); + } + + /** + * @covers \ProxyManager\Configuration::getProxyAutoloader + * @covers \ProxyManager\Configuration::setProxyAutoloader + */ + public function testSetGetProxyAutoloader() + { + $this->assertInstanceOf( + 'ProxyManager\\Autoloader\\AutoloaderInterface', + $this->configuration->getProxyAutoloader() + ); + + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->configuration->setProxyAutoloader($autoloader); + $this->assertSame($autoloader, $this->configuration->getProxyAutoloader()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..57cae41b8815ea89c520c39868c74fbc49e8f833 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Exception; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Exception\DisabledMethodException; + +/** + * Tests for {@see \ProxyManager\Exception\DisabledMethodException} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class DisabledMethodExceptionTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Exception\DisabledMethodException::disabledMethod + */ + public function testProxyDirectoryNotFound() + { + $exception = DisabledMethodException::disabledMethod('foo::bar'); + + $this->assertSame('Method "foo::bar" is forcefully disabled', $exception->getMessage()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b7b63c9369ad25c160e6801012e41145beeb0e64 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php @@ -0,0 +1,45 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Exception; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Exception\InvalidProxiedClassException; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\Exception\InvalidProxiedClassException} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InvalidProxiedClassExceptionTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Exception\InvalidProxiedClassException::interfaceNotSupported + */ + public function testInterfaceNotSupported() + { + $this->assertSame( + 'Provided interface "ProxyManagerTestAsset\BaseInterface" cannot be proxied', + InvalidProxiedClassException::interfaceNotSupported( + new ReflectionClass('ProxyManagerTestAsset\BaseInterface') + )->getMessage() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c80ff7e444f165c3746465f746d0fce315dc3a53 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Exception; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Exception\InvalidProxyDirectoryException; + +/** + * Tests for {@see \ProxyManager\Exception\InvalidProxyDirectoryException} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InvalidProxyDirectoryExceptionTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Exception\InvalidProxyDirectoryException::proxyDirectoryNotFound + */ + public function testProxyDirectoryNotFound() + { + $exception = InvalidProxyDirectoryException::proxyDirectoryNotFound('foo/bar'); + + $this->assertSame('Provided directory "foo/bar" does not exist', $exception->getMessage()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7370c7f1c6246b8b7490b49fd789e4cf8e220409 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php @@ -0,0 +1,46 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Exception; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Exception\UnsupportedProxiedClassException; +use ReflectionProperty; + +/** + * Tests for {@see \ProxyManager\Exception\UnsupportedProxiedClassException} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class UnsupportedProxiedClassExceptionTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Exception\UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty + */ + public function testUnsupportedLocalizedReflectionProperty() + { + $this->assertSame( + 'Provided reflection property "property0" of class "ProxyManagerTestAsset\ClassWithPrivateProperties" ' + . 'is private and cannot be localized in PHP 5.3', + UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty( + new ReflectionProperty('ProxyManagerTestAsset\ClassWithPrivateProperties', 'property0') + )->getMessage() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e33f41bcd704a1f6abc712b40ca1ac0bbb0ab07c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php @@ -0,0 +1,132 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ReflectionMethod; + +/** + * Tests for {@see \ProxyManager\Factory\AbstractBaseFactory} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\Factory\AbstractBaseFactory + */ +class AbstractBaseFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \ProxyManager\Factory\AbstractBaseFactory + */ + private $factory; + + /** + * @var \ProxyManager\ProxyGenerator\ProxyGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $generator; + + /** + * @var \ProxyManager\Inflector\ClassNameInflectorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $classNameInflector; + + /** + * @var \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $generatorStrategy; + + /** + * @var \ProxyManager\Autoloader\AutoloaderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $proxyAutoloader; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $configuration = $this->getMock('ProxyManager\\Configuration'); + $this->generator = $this->getMock('ProxyManager\\ProxyGenerator\\ProxyGeneratorInterface'); + $this->classNameInflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this->generatorStrategy = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); + $this->proxyAutoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $configuration + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->classNameInflector)); + + $configuration + ->expects($this->any()) + ->method('getGeneratorStrategy') + ->will($this->returnValue($this->generatorStrategy)); + + $configuration + ->expects($this->any()) + ->method('getProxyAutoloader') + ->will($this->returnValue($this->proxyAutoloader)); + + $this + ->classNameInflector + ->expects($this->any()) + ->method('getUserClassName') + ->will($this->returnValue('stdClass')); + + $this->factory = $this->getMockForAbstractClass( + 'ProxyManager\\Factory\\AbstractBaseFactory', + array($configuration) + ); + + $this->factory->expects($this->any())->method('getGenerator')->will($this->returnValue($this->generator)); + } + + public function testGeneratesClass() + { + $generateProxy = new ReflectionMethod($this->factory, 'generateProxy'); + + $generateProxy->setAccessible(true); + $generatedClass = UniqueIdentifierGenerator::getIdentifier('fooBar'); + + $this + ->classNameInflector + ->expects($this->any()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue($generatedClass)); + + $this + ->generatorStrategy + ->expects($this->once()) + ->method('generate') + ->with($this->isInstanceOf('Zend\\Code\\Generator\\ClassGenerator')); + $this + ->proxyAutoloader + ->expects($this->once()) + ->method('__invoke') + ->with($generatedClass) + ->will($this->returnCallback(function ($className) { + eval('class ' . $className . ' {}'); + })); + + $this->assertSame($generatedClass, $generateProxy->invoke($this->factory, 'stdClass')); + $this->assertTrue(class_exists($generatedClass, false)); + $this->assertSame($generatedClass, $generateProxy->invoke($this->factory, 'stdClass')); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..61f83a4692ff77316ec69786e002d8baeb105911 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php @@ -0,0 +1,169 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory; +use ProxyManager\Factory\AccessInterceptorValueHolderFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use stdClass; + +/** + * Tests for {@see \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorScopeLocalizerFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct + */ + public function testWithOptionalFactory() + { + $factory = new AccessInterceptorValueHolderFactory(); + $this->assertAttributeNotEmpty('configuration', $factory); + $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::createProxy + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::getGenerator + */ + public function testWillSkipAutoGeneration() + { + $instance = new stdClass(); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock')); + + $factory = new AccessInterceptorScopeLocalizerFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ + $proxy = $factory->createProxy($instance, array('foo'), array('bar')); + + $this->assertInstanceOf('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock', $proxy); + $this->assertSame($instance, $proxy->instance); + $this->assertSame(array('foo'), $proxy->prefixInterceptors); + $this->assertSame(array('bar'), $proxy->suffixInterceptors); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::createProxy + * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $instance = new stdClass(); + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval( + 'class ' . $proxyClassName + . ' extends \\ProxyManagerTestAsset\\AccessInterceptorValueHolderMock {}' + ); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new AccessInterceptorScopeLocalizerFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ + $proxy = $factory->createProxy($instance, array('foo'), array('bar')); + + $this->assertInstanceOf($proxyClassName, $proxy); + $this->assertSame($instance, $proxy->instance); + $this->assertSame(array('foo'), $proxy->prefixInterceptors); + $this->assertSame(array('bar'), $proxy->suffixInterceptors); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e3995a0549695c2e2914ad585f30b2d621c1deb1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php @@ -0,0 +1,168 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\AccessInterceptorValueHolderFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use stdClass; + +/** + * Tests for {@see \ProxyManager\Factory\AccessInterceptorValueHolderFactory} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorValueHolderFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct + */ + public function testWithOptionalFactory() + { + $factory = new AccessInterceptorValueHolderFactory(); + $this->assertAttributeNotEmpty('configuration', $factory); + $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::createProxy + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::getGenerator + */ + public function testWillSkipAutoGeneration() + { + $instance = new stdClass(); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock')); + + $factory = new AccessInterceptorValueHolderFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ + $proxy = $factory->createProxy($instance, array('foo'), array('bar')); + + $this->assertInstanceOf('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock', $proxy); + $this->assertSame($instance, $proxy->instance); + $this->assertSame(array('foo'), $proxy->prefixInterceptors); + $this->assertSame(array('bar'), $proxy->suffixInterceptors); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::createProxy + * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $instance = new stdClass(); + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval( + 'class ' . $proxyClassName + . ' extends \\ProxyManagerTestAsset\\AccessInterceptorValueHolderMock {}' + ); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new AccessInterceptorValueHolderFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ + $proxy = $factory->createProxy($instance, array('foo'), array('bar')); + + $this->assertInstanceOf($proxyClassName, $proxy); + $this->assertSame($instance, $proxy->instance); + $this->assertSame(array('foo'), $proxy->prefixInterceptors); + $this->assertSame(array('bar'), $proxy->suffixInterceptors); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9a7d376bead0b64cd72415aa6c38f7989363c0c3 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php @@ -0,0 +1,163 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\LazyLoadingGhostFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\Factory\LazyLoadingGhostFactory} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingGhostFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct + */ + public function testWithOptionalFactory() + { + $factory = new LazyLoadingGhostFactory(); + $this->assertAttributeNotEmpty('configuration', $factory); + $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::createProxy + */ + public function testWillSkipAutoGeneration() + { + $className = UniqueIdentifierGenerator::getIdentifier('foo'); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with($className) + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new LazyLoadingGhostFactory($this->config); + $initializer = function () { + }; + /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ + $proxy = $factory->createProxy($className, $initializer); + + $this->assertInstanceOf('ProxyManagerTestAsset\\LazyLoadingMock', $proxy); + $this->assertSame($initializer, $proxy->initializer); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::createProxy + * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $className = UniqueIdentifierGenerator::getIdentifier('foo'); + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval('class ' . $proxyClassName . ' extends \\ProxyManagerTestAsset\\LazyLoadingMock {}'); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with($className) + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with($className) + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new LazyLoadingGhostFactory($this->config); + $initializer = function () { + }; + /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ + $proxy = $factory->createProxy($className, $initializer); + + $this->assertInstanceOf($proxyClassName, $proxy); + $this->assertSame($initializer, $proxy->initializer); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c9da4512f7db5a567a001eeb8d092853324bb031 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php @@ -0,0 +1,163 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\LazyLoadingValueHolderFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\Factory\LazyLoadingValueHolderFactory} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingValueHolderFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct + */ + public function testWithOptionalFactory() + { + $factory = new LazyLoadingValueHolderFactory(); + $this->assertAttributeNotEmpty('configuration', $factory); + $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::createProxy + */ + public function testWillSkipAutoGeneration() + { + $className = UniqueIdentifierGenerator::getIdentifier('foo'); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with($className) + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new LazyLoadingValueHolderFactory($this->config); + $initializer = function () { + }; + /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ + $proxy = $factory->createProxy($className, $initializer); + + $this->assertInstanceOf('ProxyManagerTestAsset\\LazyLoadingMock', $proxy); + $this->assertSame($initializer, $proxy->initializer); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::createProxy + * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $className = UniqueIdentifierGenerator::getIdentifier('foo'); + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval('class ' . $proxyClassName . ' extends \\ProxyManagerTestAsset\\LazyLoadingMock {}'); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with($className) + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with($className) + ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); + + $factory = new LazyLoadingValueHolderFactory($this->config); + $initializer = function () { + }; + /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ + $proxy = $factory->createProxy($className, $initializer); + + $this->assertInstanceOf($proxyClassName, $proxy); + $this->assertSame($initializer, $proxy->initializer); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7fa6b2b9ff68fa4fe0c6fc3bd30aae8120fff917 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php @@ -0,0 +1,150 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\NullObjectFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use stdClass; + +/** + * Tests for {@see \ProxyManager\Factory\NullObjectFactory} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\NullObjectFactory::__construct + * @covers \ProxyManager\Factory\NullObjectFactory::createProxy + * @covers \ProxyManager\Factory\NullObjectFactory::getGenerator + */ + public function testWillSkipAutoGeneration() + { + $instance = new stdClass(); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\NullObjectMock')); + + $factory = new NullObjectFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\NullObjectMock */ + $proxy = $factory->createProxy($instance); + + $this->assertInstanceOf('ProxyManagerTestAsset\\NullObjectMock', $proxy); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\NullObjectFactory::__construct + * @covers \ProxyManager\Factory\NullObjectFactory::createProxy + * @covers \ProxyManager\Factory\NullObjectFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $instance = new stdClass(); + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval( + 'class ' . $proxyClassName + . ' extends \\ProxyManagerTestAsset\\NullObjectMock {}' + ); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('stdClass') + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with('stdClass') + ->will($this->returnValue('ProxyManagerTestAsset\\NullObjectMock')); + + $factory = new NullObjectFactory($this->config); + /* @var $proxy \ProxyManagerTestAsset\NullObjectMock */ + $proxy = $factory->createProxy($instance); + + $this->assertInstanceOf($proxyClassName, $proxy); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cb7f1e7944d3aff031e65e771894780b315c7491 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php @@ -0,0 +1,99 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory\RemoteObject\Adapter; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObject\Adapter\Soap; + +/** + * Tests for {@see \ProxyManager\Factory\RemoteObject\Adapter\Soap} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class BaseAdapterTest extends PHPUnit_Framework_TestCase +{ + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct + * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call + * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName + */ + public function testBaseAdapter() + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $adapter = $this->getMockForAbstractClass( + 'ProxyManager\\Factory\\RemoteObject\\Adapter\\BaseAdapter', + array($client) + ); + + $client + ->expects($this->once()) + ->method('call') + ->with('foobarbaz', array('tab' => 'taz')) + ->will($this->returnValue('baz')); + + $adapter + ->expects($this->once()) + ->method('getServiceName') + ->with('foo', 'bar') + ->will($this->returnValue('foobarbaz')); + + $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct + * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call + * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName + */ + public function testBaseAdapterWithServiceMap() + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $adapter = $this->getMockForAbstractClass( + 'ProxyManager\\Factory\\RemoteObject\\Adapter\\BaseAdapter', + array($client, array('foobarbaz' => 'mapped')) + ); + + $client + ->expects($this->once()) + ->method('call') + ->with('mapped', array('tab' => 'taz')) + ->will($this->returnValue('baz')); + + $adapter + ->expects($this->once()) + ->method('getServiceName') + ->with('foo', 'bar') + ->will($this->returnValue('foobarbaz')); + + $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d2dd02859999683fe9b8103aa8ae8a3a2291e993 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory\RemoteObject\Adapter; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObject\Adapter\JsonRpc; + +/** + * Tests for {@see \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class JsonRpcTest extends PHPUnit_Framework_TestCase +{ + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc::__construct + * @covers \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc::getServiceName + */ + public function testCanBuildAdapterWithJsonRpcClient() + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $adapter = new JsonRpc($client); + + $client + ->expects($this->once()) + ->method('call') + ->with('foo.bar', array('tab' => 'taz')) + ->will($this->returnValue('baz')); + + $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6dae8b783d0b81824fb28e88b6abcd6890198604 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory\RemoteObject\Adapter; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObject\Adapter\Soap; + +/** + * Tests for {@see \ProxyManager\Factory\RemoteObject\Adapter\Soap} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class SoapTest extends PHPUnit_Framework_TestCase +{ + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::__construct + * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName + */ + public function testCanBuildAdapterWithSoapRpcClient() + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $adapter = new Soap($client); + + $client + ->expects($this->once()) + ->method('call') + ->with('bar', array('tab' => 'taz')) + ->will($this->returnValue('baz')); + + $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fb6661c3bbb79aacb3dbb40b9921e708a913dd36 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory\RemoteObject\Adapter; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObject\Adapter\XmlRpc; + +/** + * Tests for {@see \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class XmlRpcTest extends PHPUnit_Framework_TestCase +{ + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc::__construct + * @covers \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc::getServiceName + */ + public function testCanBuildAdapterWithXmlRpcClient() + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $adapter = new XmlRpc($client); + + $client + ->expects($this->once()) + ->method('call') + ->with('foo.bar', array('tab' => 'taz')) + ->will($this->returnValue('baz')); + + $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ad073e6b59fa95e8f7e5931eb79dfa21ce4d3121 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php @@ -0,0 +1,148 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Factory; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObjectFactory; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\Factory\RemoteObjectFactory} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectFactoryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $inflector; + + /** + * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->config = $this->getMock('ProxyManager\\Configuration'); + $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); + $this + ->config + ->expects($this->any()) + ->method('getClassNameInflector') + ->will($this->returnValue($this->inflector)); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObjectFactory::__construct + * @covers \ProxyManager\Factory\RemoteObjectFactory::createProxy + * @covers \ProxyManager\Factory\RemoteObjectFactory::getGenerator + */ + public function testWillSkipAutoGeneration() + { + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('ProxyManagerTestAsset\\BaseInterface') + ->will($this->returnValue('StdClass')); + + $adapter = $this->getMock('ProxyManager\Factory\RemoteObject\AdapterInterface'); + $factory = new RemoteObjectFactory($adapter, $this->config); + /* @var $proxy \stdClass */ + $proxy = $factory->createProxy('ProxyManagerTestAsset\\BaseInterface', $adapter); + + $this->assertInstanceOf('stdClass', $proxy); + } + + /** + * {@inheritDoc} + * + * @covers \ProxyManager\Factory\RemoteObjectFactory::__construct + * @covers \ProxyManager\Factory\RemoteObjectFactory::createProxy + * @covers \ProxyManager\Factory\RemoteObjectFactory::getGenerator + * + * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful + */ + public function testWillTryAutoGeneration() + { + $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); + $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); + $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); + + $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); + $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); + + $generator + ->expects($this->once()) + ->method('generate') + ->with( + $this->callback( + function (ClassGenerator $targetClass) use ($proxyClassName) { + return $targetClass->getName() === $proxyClassName; + } + ) + ); + + // simulate autoloading + $autoloader + ->expects($this->once()) + ->method('__invoke') + ->with($proxyClassName) + ->will( + $this->returnCallback( + function () use ($proxyClassName) { + eval( + 'class ' . $proxyClassName + . ' extends stdClass {}' + ); + } + ) + ); + + $this + ->inflector + ->expects($this->once()) + ->method('getProxyClassName') + ->with('ProxyManagerTestAsset\\BaseInterface') + ->will($this->returnValue($proxyClassName)); + + $this + ->inflector + ->expects($this->once()) + ->method('getUserClassName') + ->with('ProxyManagerTestAsset\\BaseInterface') + ->will($this->returnValue('stdClass')); + + $adapter = $this->getMock('ProxyManager\Factory\RemoteObject\AdapterInterface'); + $factory = new RemoteObjectFactory($adapter, $this->config); + /* @var $proxy \stdClass */ + $proxy = $factory->createProxy('ProxyManagerTestAsset\\BaseInterface', $adapter); + + $this->assertInstanceOf($proxyClassName, $proxy); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1ea2fca26a59870ce2e1743e39eb0e25e2805864 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\FileLocator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\FileLocator\FileLocator; + +/** + * Tests for {@see \ProxyManager\FileLocator\FileLocator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class FileLocatorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\FileLocator\FileLocator::__construct + * @covers \ProxyManager\FileLocator\FileLocator::getProxyFileName + */ + public function testGetProxyFileName() + { + $locator = new FileLocator(__DIR__); + + $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'FooBarBaz.php', $locator->getProxyFileName('Foo\\Bar\\Baz')); + $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'Foo_Bar_Baz.php', $locator->getProxyFileName('Foo_Bar_Baz')); + } + + /** + * @covers \ProxyManager\FileLocator\FileLocator::__construct + */ + public function testRejectsNonExistingDirectory() + { + $this->setExpectedException('ProxyManager\\Exception\\InvalidProxyDirectoryException'); + new FileLocator(__DIR__ . '/non-existing'); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bedb96097cf30352595365ec2c76361ca487fc2e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php @@ -0,0 +1,372 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_SkippedTestError; +use PHPUnit_Framework_TestCase; +use ProxyManager\Exception\UnsupportedProxiedClassException; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\Proxy\AccessInterceptorInterface; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator; +use ProxyManagerTestAsset\BaseClass; +use ProxyManagerTestAsset\ClassWithPublicArrayProperty; +use ProxyManagerTestAsset\ClassWithPublicProperties; +use ReflectionClass; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class AccessInterceptorScopeLocalizerFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * {@inheritDoc} + */ + public static function setUpBeforeClass() + { + if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) { + throw new PHPUnit_Framework_SkippedTestError( + 'PHP 5.3 doesn\'t support scope localization of private properties' + ); + } + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCalls($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $proxy = new $proxyName($instance); + + $this->assertProxySynchronized($instance, $proxy); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $listener = $this->getMock('stdClass', array('__invoke')); + $listener + ->expects($this->once()) + ->method('__invoke') + ->with($proxy, $proxy, $method, $params, false); + + $proxy->setMethodPrefixInterceptor( + $method, + function ($proxy, $instance, $method, $params, & $returnEarly) use ($listener) { + $listener->__invoke($proxy, $instance, $method, $params, $returnEarly); + } + ); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $random = uniqid(); + + $proxy->setMethodPrefixInterceptor( + $method, + function ($proxy, $instance, $method, $params, & $returnEarly) use ($random) { + $returnEarly = true; + + return $random; + } + ); + + $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsWithSuffixListener($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $proxy = new $proxyName($instance); + $listener = $this->getMock('stdClass', array('__invoke')); + $listener + ->expects($this->once()) + ->method('__invoke') + ->with($proxy, $proxy, $method, $params, $expectedValue, false); + + $proxy->setMethodSuffixInterceptor( + $method, + function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($listener) { + $listener->__invoke($proxy, $instance, $method, $params, $returnValue, $returnEarly); + } + ); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $random = uniqid(); + + $proxy->setMethodSuffixInterceptor( + $method, + function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($random) { + $returnEarly = true; + + return $random; + } + ); + + $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $proxy = unserialize(serialize(new $proxyName($instance))); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $proxy = new $proxyName($instance); + $cloned = clone $proxy; + + $this->assertProxySynchronized($instance, $proxy); + $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $this->assertSame($propertyValue, $proxy->$publicProperty); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyWriteAccess($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $newValue = uniqid(); + $proxy->$publicProperty = $newValue; + + $this->assertSame($newValue, $proxy->$publicProperty); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyExistence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); + $this->assertProxySynchronized($instance, $proxy); + + $instance->$publicProperty = null; + $this->assertFalse(isset($proxy->$publicProperty)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyUnset($instance, $proxy, $publicProperty) + { + $this->markTestSkipped('It is currently not possible to synchronize properties un-setting'); + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ + unset($proxy->$publicProperty); + + $this->assertFalse(isset($instance->$publicProperty)); + $this->assertFalse(isset($proxy->$publicProperty)); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * Verifies that accessing a public property containing an array behaves like in a normal context + */ + public function testCanWriteToArrayKeysInPublicProperty() + { + $instance = new ClassWithPublicArrayProperty(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicArrayProperty */ + $proxy = new $proxyName($instance); + + $proxy->arrayProperty['foo'] = 'bar'; + + $this->assertSame('bar', $proxy->arrayProperty['foo']); + + $proxy->arrayProperty = array('tab' => 'taz'); + + $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * Verifies that public properties retrieved via `__get` don't get modified in the object state + */ + public function testWillNotModifyRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($instance); + $variable = $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('property0', $proxy->property0); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * Verifies that public properties references retrieved via `__get` modify in the object state + */ + public function testWillModifyByRefRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($instance); + $variable = & $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('foo', $proxy->property0); + $this->assertProxySynchronized($instance, $proxy); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + * + * @throws UnsupportedProxiedClassException + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new AccessInterceptorScopeLocalizerGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicTypeHintedMethod', + array('param' => new \stdClass()), + 'publicTypeHintedMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicByReferenceMethod', + array(), + 'publicByReferenceMethodDefault' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + $instance1 = new BaseClass(); + $proxyName1 = $this->generateProxy(get_class($instance1)); + + return array( + array( + $instance1, + new $proxyName1($instance1), + 'publicProperty', + 'publicPropertyDefault', + ), + ); + } + + /** + * @param object $instance + * @param AccessInterceptorInterface $proxy + */ + private function assertProxySynchronized($instance, AccessInterceptorInterface $proxy) + { + $reflectionClass = new ReflectionClass($instance); + + foreach ($reflectionClass->getProperties() as $property) { + $property->setAccessible(true); + + $this->assertSame( + $property->getValue($instance), + $property->getValue($proxy), + 'Property "' . $property->getName() . '" is synchronized between instance and proxy' + ); + } + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c71edb60a91e4cca234b24bf44576234b25d69e6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php @@ -0,0 +1,344 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator; +use ProxyManagerTestAsset\BaseClass; +use ProxyManagerTestAsset\ClassWithPublicArrayProperty; +use ProxyManagerTestAsset\ClassWithPublicProperties; +use ReflectionClass; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class AccessInterceptorValueHolderFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getProxyMethods + */ + public function testMethodCalls($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $proxy = new $proxyName($instance); + + $this->assertSame($instance, $proxy->getWrappedValueHolderValue()); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $listener = $this->getMock('stdClass', array('__invoke')); + $listener + ->expects($this->once()) + ->method('__invoke') + ->with($proxy, $instance, $method, $params, false); + + $proxy->setMethodPrefixInterceptor( + $method, + function ($proxy, $instance, $method, $params, & $returnEarly) use ($listener) { + $listener->__invoke($proxy, $instance, $method, $params, $returnEarly); + } + ); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $random = uniqid(); + + $proxy->setMethodPrefixInterceptor( + $method, + function ($proxy, $instance, $method, $params, & $returnEarly) use ($random) { + $returnEarly = true; + + return $random; + } + ); + + $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsWithSuffixListener($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $proxy = new $proxyName($instance); + $listener = $this->getMock('stdClass', array('__invoke')); + $listener + ->expects($this->once()) + ->method('__invoke') + ->with($proxy, $instance, $method, $params, $expectedValue, false); + + $proxy->setMethodSuffixInterceptor( + $method, + function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($listener) { + $listener->__invoke($proxy, $instance, $method, $params, $returnValue, $returnEarly); + } + ); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + + $random = uniqid(); + + $proxy->setMethodSuffixInterceptor( + $method, + function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($random) { + $returnEarly = true; + + return $random; + } + ); + + $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $proxy = unserialize(serialize(new $proxyName($instance))); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $proxy = new $proxyName($instance); + $cloned = clone $proxy; + + $this->assertNotSame($proxy->getWrappedValueHolderValue(), $cloned->getWrappedValueHolderValue()); + $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); + $this->assertEquals($instance, $cloned->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $this->assertSame($propertyValue, $proxy->$publicProperty); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyWriteAccess($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $newValue = uniqid(); + $proxy->$publicProperty = $newValue; + + $this->assertSame($newValue, $proxy->$publicProperty); + $this->assertSame($newValue, $proxy->getWrappedValueHolderValue()->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyExistence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + + $proxy->getWrappedValueHolderValue()->$publicProperty = null; + $this->assertFalse(isset($proxy->$publicProperty)); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyUnset($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ + $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; + unset($proxy->$publicProperty); + + $this->assertFalse(isset($instance->$publicProperty)); + $this->assertFalse(isset($proxy->$publicProperty)); + } + + /** + * Verifies that accessing a public property containing an array behaves like in a normal context + */ + public function testCanWriteToArrayKeysInPublicProperty() + { + $instance = new ClassWithPublicArrayProperty(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicArrayProperty */ + $proxy = new $proxyName($instance); + + $proxy->arrayProperty['foo'] = 'bar'; + + $this->assertSame('bar', $proxy->arrayProperty['foo']); + + $proxy->arrayProperty = array('tab' => 'taz'); + + $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); + } + + /** + * Verifies that public properties retrieved via `__get` don't get modified in the object state + */ + public function testWillNotModifyRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($instance); + $variable = $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('property0', $proxy->property0); + } + + /** + * Verifies that public properties references retrieved via `__get` modify in the object state + */ + public function testWillModifyByRefRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($instance); + $variable = & $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('foo', $proxy->property0); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new AccessInterceptorValueHolderGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicTypeHintedMethod', + array('param' => new \stdClass()), + 'publicTypeHintedMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicByReferenceMethod', + array(), + 'publicByReferenceMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseInterface', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + $instance1 = new BaseClass(); + $proxyName1 = $this->generateProxy(get_class($instance1)); + $instance2 = new BaseClass(); + $proxyName2 = $this->generateProxy(get_class($instance2)); + + return array( + array( + $instance1, + new $proxyName1($instance1), + 'publicProperty', + 'publicPropertyDefault', + ), + array( + $instance2, + unserialize(serialize(new $proxyName2($instance2))), + 'publicProperty', + 'publicPropertyDefault', + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d00fa415fd655d49822f8ebea368fee933f7e326 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php @@ -0,0 +1,196 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +/** + * Base performance test logic for lazy loading proxies + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Performance + * @coversNothing + */ +abstract class BaseLazyLoadingPerformanceTest extends BasePerformanceTest +{ + /** + * @param string $className + * @param object[] $instances + * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies + * @param string $methodName + * @param array $parameters + */ + protected function profileMethodAccess($className, array $instances, array $proxies, $methodName, array $parameters) + { + $iterations = count($instances); + + $this->startCapturing(); + + foreach ($instances as $instance) { + call_user_func_array(array($instance, $methodName), $parameters); + } + + $baseProfile = $this->endCapturing( + $iterations . ' calls to ' . $className . '#' . $methodName . ': %fms / %fKb' + ); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + call_user_func_array(array($proxy, $methodName), $parameters); + } + + $proxyProfile = $this->endCapturing( + $iterations . ' calls to proxied ' . $className . '#' . $methodName . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + } + + /** + * @param string $className + * @param object[] $instances + * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies + * @param string $property + */ + protected function profilePropertyWrites($className, array $instances, array $proxies, $property) + { + $iterations = count($instances); + + $this->startCapturing(); + + foreach ($instances as $instance) { + $instance->$property = 'foo'; + } + + $baseProfile = $this->endCapturing( + $iterations . ' writes of ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + $proxy->$property = 'foo'; + } + + $proxyProfile = $this->endCapturing( + $iterations . ' writes of proxied ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + } + + /** + * @param string $className + * @param object[] $instances + * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies + * @param string $property + */ + protected function profilePropertyReads($className, array $instances, array $proxies, $property) + { + $iterations = count($instances); + + $this->startCapturing(); + + foreach ($instances as $instance) { + $instance->$property; + } + + $baseProfile = $this->endCapturing( + $iterations . ' reads of ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + $proxy->$property; + } + + $proxyProfile = $this->endCapturing( + $iterations . ' reads of proxied ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + } + + /** + * @param string $className + * @param object[] $instances + * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies + * @param string $property + */ + protected function profilePropertyIsset($className, array $instances, array $proxies, $property) + { + $iterations = count($instances); + + $this->startCapturing(); + + foreach ($instances as $instance) { + isset($instance->$property); + } + + $baseProfile = $this->endCapturing( + $iterations . ' isset of ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + isset($proxy->$property); + } + + $proxyProfile = $this->endCapturing( + $iterations . ' isset of proxied ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + } + + /** + * @param string $className + * @param object[] $instances + * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies + * @param string $property + */ + protected function profilePropertyUnset($className, array $instances, array $proxies, $property) + { + $iterations = count($instances); + + $this->startCapturing(); + + foreach ($instances as $instance) { + unset($instance->$property); + } + + $baseProfile = $this->endCapturing( + $iterations . ' unset of ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + unset($proxy->$property); + } + + $proxyProfile = $this->endCapturing( + $iterations . ' unset of proxied ' . $className . '::' . $property . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + abstract protected function generateProxy($parentClassName); +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b9dc803e7029bb8394ca1a19ae28d7b7fd7cca0e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php @@ -0,0 +1,101 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; + +/** + * Base performance test logic + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Performance + * @coversNothing + */ +abstract class BasePerformanceTest extends PHPUnit_Framework_TestCase +{ + /** + * @var float time when last capture was started + */ + private $startTime = 0; + + /** + * @var int bytes when last capture was started + */ + private $startMemory = 0; + + /** + * {@inheritDoc} + */ + public static function setUpBeforeClass() + { + $header = "Performance test - " . get_called_class() . ":"; + + echo "\n\n" . str_repeat('=', strlen($header)) . "\n" . $header . "\n\n"; + } + + /** + * Start profiler snapshot + */ + protected function startCapturing() + { + $this->startMemory = memory_get_usage(); + $this->startTime = microtime(true); + } + + /** + * Echo current profiler output + * + * @param string $messageTemplate + * + * @return array + */ + protected function endCapturing($messageTemplate) + { + $time = microtime(true) - $this->startTime; + $memory = memory_get_usage() - $this->startMemory; + + if (gc_enable()) { + gc_collect_cycles(); + } + + echo sprintf($messageTemplate, $time, $memory / 1024) . "\n"; + + return array( + 'time' => $time, + 'memory' => $memory + ); + } + + /** + * Display comparison between two profiles + * + * @param array $baseProfile + * @param array $proxyProfile + */ + protected function compareProfile(array $baseProfile, array $proxyProfile) + { + $baseMemory = max(1, $baseProfile['memory']); + $timeOverhead = (($proxyProfile['time'] / $baseProfile['time']) - 1) * 100; + $memoryOverhead = (($proxyProfile['memory'] / $baseMemory) - 1) * 100; + + echo sprintf('Comparison time / memory: %.2f%% / %.2f%%', $timeOverhead, $memoryOverhead) . "\n\n"; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..30b8ceb68f660b4a9e71620f6604aecfbcca34cd --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php @@ -0,0 +1,425 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use PHPUnit_Framework_MockObject_MockObject as Mock; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\Proxy\GhostObjectInterface; +use ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator; +use ProxyManagerTestAsset\BaseClass; +use ProxyManagerTestAsset\ClassWithPublicArrayProperty; +use ProxyManagerTestAsset\ClassWithPublicProperties; +use ProxyManagerTestAsset\ClassWithProtectedProperties; +use ProxyManagerTestAsset\ClassWithPrivateProperties; +use ReflectionClass; +use ReflectionProperty; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class LazyLoadingGhostFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getProxyMethods + */ + public function testMethodCalls($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ + $proxy = new $proxyName($this->createInitializer($className, $instance)); + + $this->assertFalse($proxy->isProxyInitialized()); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + $this->assertTrue($proxy->isProxyInitialized()); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ + $proxy = unserialize(serialize(new $proxyName($this->createInitializer($className, $instance)))); + + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ + $proxy = new $proxyName($this->createInitializer($className, $instance)); + $cloned = clone $proxy; + + $this->assertTrue($cloned->isProxyInitialized()); + $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) + { + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + $this->assertSame($propertyValue, $proxy->$publicProperty); + $this->assertTrue($proxy->isProxyInitialized()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyWriteAccess($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + $newValue = uniqid(); + $proxy->$publicProperty = $newValue; + + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertSame($newValue, $proxy->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyExistence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); + $this->assertTrue($proxy->isProxyInitialized()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyAbsence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + $proxy->$publicProperty = null; + $this->assertFalse(isset($proxy->$publicProperty)); + $this->assertTrue($proxy->isProxyInitialized()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyUnset($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + + unset($proxy->$publicProperty); + + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertTrue(isset($instance->$publicProperty)); + $this->assertFalse(isset($proxy->$publicProperty)); + } + + /** + * Verifies that accessing a public property containing an array behaves like in a normal context + */ + public function testCanWriteToArrayKeysInPublicProperty() + { + $instance = new ClassWithPublicArrayProperty(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicArrayProperty */ + $proxy = new $proxyName($initializer); + + $proxy->arrayProperty['foo'] = 'bar'; + + $this->assertSame('bar', $proxy->arrayProperty['foo']); + + $proxy->arrayProperty = array('tab' => 'taz'); + + $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); + } + + /** + * Verifies that public properties retrieved via `__get` don't get modified in the object itself + */ + public function testWillNotModifyRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($initializer); + $variable = $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('property0', $proxy->property0); + } + + /** + * Verifies that public properties references retrieved via `__get` modify in the object state + */ + public function testWillModifyByRefRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($initializer); + $variable = & $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('foo', $proxy->property0); + } + + public function testKeepsInitializerWhenNotOverwitten() + { + $instance = new BaseClass(); + $proxyName = $this->generateProxy(get_class($instance)); + $initializer = function () { + }; + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ + $proxy = new $proxyName($initializer); + + $proxy->initializeProxy(); + + $this->assertSame($initializer, $proxy->getProxyInitializer()); + } + + /** + * Verifies that public properties are not being initialized multiple times + */ + public function testKeepsInitializedPublicProperties() + { + $instance = new BaseClass(); + $proxyName = $this->generateProxy(get_class($instance)); + $initializer = function (BaseClass $proxy, $method, $parameters, & $initializer) { + $initializer = null; + $proxy->publicProperty = 'newValue'; + }; + /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ + $proxy = new $proxyName($initializer); + + $proxy->initializeProxy(); + $this->assertSame('newValue', $proxy->publicProperty); + + $proxy->publicProperty = 'otherValue'; + + $proxy->initializeProxy(); + + $this->assertSame('otherValue', $proxy->publicProperty); + } + + /** + * Verifies that properties' default values are preserved + */ + public function testPublicPropertyDefaultWillBePreserved() + { + $instance = new ClassWithPublicProperties(); + $proxyName = $this->generateProxy(get_class($instance)); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName(function () { + }); + + $this->assertSame('property0', $proxy->property0); + } + + /** + * Verifies that protected properties' default values are preserved + */ + public function testProtectedPropertyDefaultWillBePreserved() + { + $instance = new ClassWithProtectedProperties(); + $proxyName = $this->generateProxy(get_class($instance)); + /* @var $proxy ClassWithProtectedProperties */ + $proxy = new $proxyName(function () { + }); + + // Check protected property via reflection + $reflectionProperty = new ReflectionProperty($instance, 'property0'); + $reflectionProperty->setAccessible(true); + + $this->assertSame('property0', $reflectionProperty->getValue($proxy)); + } + + /** + * Verifies that private properties' default values are preserved + */ + public function testPrivatePropertyDefaultWillBePreserved() + { + $instance = new ClassWithPrivateProperties(); + $proxyName = $this->generateProxy(get_class($instance)); + /* @var $proxy ClassWithPrivateProperties */ + $proxy = new $proxyName(function () { + }); + + // Check protected property via reflection + $reflectionProperty = new ReflectionProperty($instance, 'property0'); + $reflectionProperty->setAccessible(true); + + $this->assertSame('property0', $reflectionProperty->getValue($proxy)); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new LazyLoadingGhostGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * @param string $className + * @param object $realInstance + * @param Mock $initializerMatcher + * + * @return \Closure + */ + private function createInitializer($className, $realInstance, Mock $initializerMatcher = null) + { + if (null === $initializerMatcher) { + $initializerMatcher = $this->getMock('stdClass', array('__invoke')); + + $initializerMatcher + ->expects($this->once()) + ->method('__invoke') + ->with( + $this->logicalAnd( + $this->isInstanceOf('ProxyManager\\Proxy\\GhostObjectInterface'), + $this->isInstanceOf($className) + ) + ); + } + + $initializerMatcher = $initializerMatcher ?: $this->getMock('stdClass', array('__invoke')); + + return function ( + GhostObjectInterface $proxy, + $method, + $params, + & $initializer + ) use ( + $initializerMatcher, + $realInstance + ) { + $initializer = null; + $reflectionClass = new ReflectionClass($realInstance); + + foreach ($reflectionClass->getProperties() as $property) { + $property->setAccessible(true); + $property->setValue($proxy, $property->getValue($realInstance)); + } + + $initializerMatcher->__invoke($proxy, $method, $params); + }; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicTypeHintedMethod', + array(new \stdClass()), + 'publicTypeHintedMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicByReferenceMethod', + array(), + 'publicByReferenceMethodDefault' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + $instance1 = new BaseClass(); + $proxyName1 = $this->generateProxy(get_class($instance1)); + $instance2 = new BaseClass(); + $proxyName2 = $this->generateProxy(get_class($instance2)); + + return array( + array( + $instance1, + new $proxyName1($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance1)), + 'publicProperty', + 'publicPropertyDefault', + ), + array( + $instance2, + unserialize( + serialize(new $proxyName2($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance2))) + ), + 'publicProperty', + 'publicPropertyDefault', + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..21b9f49ca6844177358dfaa25aaa5e735297a984 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php @@ -0,0 +1,160 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\Proxy\GhostObjectInterface; +use ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Performance + * @coversNothing + */ +class LazyLoadingGhostPerformanceTest extends BaseLazyLoadingPerformanceTest +{ + /** + * @outputBuffering + * @dataProvider getTestedClasses + * + * @param string $className + * @param array $methods + * @param array $properties + * @param \ReflectionProperty[] $reflectionProperties + * + * @return void + */ + public function testProxyInstantiationPerformance( + $className, + array $methods, + array $properties, + array $reflectionProperties + ) { + $proxyName = $this->generateProxy($className); + $iterations = 20000; + $instances = array(); + /* @var $proxies \ProxyManager\Proxy\GhostObjectInterface[] */ + $proxies = array(); + $realInstance = new $className(); + $initializer = function ( + GhostObjectInterface $proxy, + $method, + $params, + & $initializer + ) use ( + $reflectionProperties, + $realInstance + ) { + $initializer = null; + + foreach ($reflectionProperties as $reflectionProperty) { + $reflectionProperty->setValue($proxy, $reflectionProperty->getValue($realInstance)); + } + + return true; + }; + + $this->startCapturing(); + + for ($i = 0; $i < $iterations; $i += 1) { + $instances[] = new $className(); + } + + $baseProfile = $this->endCapturing( + 'Instantiation for ' . $iterations . ' objects of type ' . $className . ': %fms / %fKb' + ); + $this->startCapturing(); + + for ($i = 0; $i < $iterations; $i += 1) { + $proxies[] = new $proxyName($initializer); + } + + $proxyProfile = $this->endCapturing( + 'Instantiation for ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + $proxy->initializeProxy(); + } + + $this->endCapturing('Initialization of ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb'); + + foreach ($methods as $methodName => $parameters) { + $this->profileMethodAccess($className, $instances, $proxies, $methodName, $parameters); + } + + foreach ($properties as $property) { + $this->profilePropertyWrites($className, $instances, $proxies, $property); + $this->profilePropertyReads($className, $instances, $proxies, $property); + $this->profilePropertyIsset($className, $instances, $proxies, $property); + $this->profilePropertyUnset($className, $instances, $proxies, $property); + } + } + + /** + * @return array + */ + public function getTestedClasses() + { + $testedClasses = array( + array('stdClass', array(), array()), + array('ProxyManagerTestAsset\\BaseClass', array('publicMethod' => array()), array('publicProperty')), + ); + + foreach ($testedClasses as $key => $testedClass) { + $reflectionProperties = array(); + $reflectionClass = new ReflectionClass($testedClass[0]); + + foreach ($reflectionClass->getProperties() as $property) { + $property->setAccessible(true); + + $reflectionProperties[$property->getName()] = $property; + } + + $testedClasses[$key][] = $reflectionProperties; + } + + return $testedClasses; + } + + /** + * {@inheritDoc} + */ + protected function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new LazyLoadingGhostGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6dc1d3b30021e07f37f7acc96f11516a115c2f83 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php @@ -0,0 +1,347 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use PHPUnit_Framework_MockObject_MockObject as Mock; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\Proxy\VirtualProxyInterface; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator; +use ProxyManagerTestAsset\BaseClass; +use ProxyManagerTestAsset\ClassWithPublicArrayProperty; +use ProxyManagerTestAsset\ClassWithPublicProperties; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class LazyLoadingValueHolderFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getProxyMethods + */ + public function testMethodCalls($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $proxy = new $proxyName($this->createInitializer($className, $instance)); + + $this->assertFalse($proxy->isProxyInitialized()); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertSame($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $proxy = unserialize(serialize(new $proxyName($this->createInitializer($className, $instance)))); + + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $proxy = new $proxyName($this->createInitializer($className, $instance)); + $cloned = clone $proxy; + + $this->assertTrue($cloned->isProxyInitialized()); + $this->assertNotSame($proxy->getWrappedValueHolderValue(), $cloned->getWrappedValueHolderValue()); + $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); + $this->assertEquals($instance, $cloned->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) + { + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $this->assertSame($propertyValue, $proxy->$publicProperty); + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyWriteAccess($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $newValue = uniqid(); + $proxy->$publicProperty = $newValue; + + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertSame($newValue, $proxy->$publicProperty); + $this->assertSame($newValue, $proxy->getWrappedValueHolderValue()->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyExistence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); + $this->assertTrue($proxy->isProxyInitialized()); + $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyAbsence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; + $instance->$publicProperty = null; + $this->assertFalse(isset($proxy->$publicProperty)); + $this->assertTrue($proxy->isProxyInitialized()); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyUnset($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ + $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; + unset($proxy->$publicProperty); + + $this->assertTrue($proxy->isProxyInitialized()); + + $this->assertFalse(isset($instance->$publicProperty)); + $this->assertFalse(isset($proxy->$publicProperty)); + } + + /** + * Verifies that accessing a public property containing an array behaves like in a normal context + */ + public function testCanWriteToArrayKeysInPublicProperty() + { + $instance = new ClassWithPublicArrayProperty(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicArrayProperty */ + $proxy = new $proxyName($initializer); + + $proxy->arrayProperty['foo'] = 'bar'; + + $this->assertSame('bar', $proxy->arrayProperty['foo']); + + $proxy->arrayProperty = array('tab' => 'taz'); + + $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); + } + + /** + * Verifies that public properties retrieved via `__get` don't get modified in the object itself + */ + public function testWillNotModifyRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($initializer); + $variable = $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('property0', $proxy->property0); + } + + /** + * Verifies that public properties references retrieved via `__get` modify in the object state + */ + public function testWillModifyByRefRetrievedPublicProperties() + { + $instance = new ClassWithPublicProperties(); + $className = get_class($instance); + $initializer = $this->createInitializer($className, $instance); + $proxyName = $this->generateProxy($className); + /* @var $proxy ClassWithPublicProperties */ + $proxy = new $proxyName($initializer); + $variable = & $proxy->property0; + + $this->assertSame('property0', $variable); + + $variable = 'foo'; + + $this->assertSame('foo', $proxy->property0); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new LazyLoadingValueHolderGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * @param string $className + * @param object $realInstance + * @param Mock $initializerMatcher + * + * @return \Closure + */ + private function createInitializer($className, $realInstance, Mock $initializerMatcher = null) + { + if (null === $initializerMatcher) { + $initializerMatcher = $this->getMock('stdClass', array('__invoke')); + + $initializerMatcher + ->expects($this->once()) + ->method('__invoke') + ->with( + $this->logicalAnd( + $this->isInstanceOf('ProxyManager\\Proxy\\VirtualProxyInterface'), + $this->isInstanceOf($className) + ), + $realInstance + ); + } + + $initializerMatcher = $initializerMatcher ?: $this->getMock('stdClass', array('__invoke')); + + return function ( + & $wrappedObject, + VirtualProxyInterface $proxy, + $method, + $params, + & $initializer + ) use ( + $initializerMatcher, + $realInstance + ) { + $initializer = null; + $wrappedObject = $realInstance; + + $initializerMatcher->__invoke($proxy, $wrappedObject, $method, $params); + }; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicTypeHintedMethod', + array(new \stdClass()), + 'publicTypeHintedMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicByReferenceMethod', + array(), + 'publicByReferenceMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseInterface', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + $instance1 = new BaseClass(); + $proxyName1 = $this->generateProxy(get_class($instance1)); + $instance2 = new BaseClass(); + $proxyName2 = $this->generateProxy(get_class($instance2)); + + return array( + array( + $instance1, + new $proxyName1($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance1)), + 'publicProperty', + 'publicPropertyDefault', + ), + array( + $instance2, + unserialize( + serialize(new $proxyName2($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance2))) + ), + 'publicProperty', + 'publicPropertyDefault', + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1279526ae4f9fb24602960c685b573c625b18c15 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php @@ -0,0 +1,134 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\Proxy\VirtualProxyInterface; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator} produced objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @group Performance + * @coversNothing + */ +class LazyLoadingValueHolderPerformanceTest extends BaseLazyLoadingPerformanceTest +{ + /** + * @outputBuffering + * @dataProvider getTestedClasses + * + * @param string $className + * @param array $methods + * @param array $properties + * + * @return void + */ + public function testProxyInstantiationPerformance($className, array $methods, array $properties) + { + $proxyName = $this->generateProxy($className); + $iterations = 20000; + $instances = array(); + /* @var $proxies \ProxyManager\Proxy\VirtualProxyInterface[] */ + $proxies = array(); + $initializer = function ( + & $valueHolder, + VirtualProxyInterface $proxy, + $method, + $params, + & $initializer + ) use ($className) { + $initializer = null; + $valueHolder = new $className(); + + return true; + }; + + $this->startCapturing(); + + for ($i = 0; $i < $iterations; $i += 1) { + $instances[] = new $className(); + } + + $baseProfile = $this->endCapturing( + 'Instantiation for ' . $iterations . ' objects of type ' . $className . ': %fms / %fKb' + ); + $this->startCapturing(); + + for ($i = 0; $i < $iterations; $i += 1) { + $proxies[] = new $proxyName($initializer); + } + + $proxyProfile = $this->endCapturing( + 'Instantiation for ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb' + ); + $this->compareProfile($baseProfile, $proxyProfile); + $this->startCapturing(); + + foreach ($proxies as $proxy) { + $proxy->initializeProxy(); + } + + $this->endCapturing('Initialization of ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb'); + + foreach ($methods as $methodName => $parameters) { + $this->profileMethodAccess($className, $instances, $proxies, $methodName, $parameters); + } + + foreach ($properties as $property) { + $this->profilePropertyWrites($className, $instances, $proxies, $property); + $this->profilePropertyReads($className, $instances, $proxies, $property); + $this->profilePropertyIsset($className, $instances, $proxies, $property); + $this->profilePropertyUnset($className, $instances, $proxies, $property); + } + } + + /** + * @return array + */ + public function getTestedClasses() + { + return array( + array('stdClass', array(), array()), + array('ProxyManagerTestAsset\\BaseClass', array('publicMethod' => array()), array('publicProperty')), + ); + } + + /** + * {@inheritDoc} + */ + protected function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new LazyLoadingValueHolderGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4686293d43419c11b3810c6fddd254bcaa38fe9b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php @@ -0,0 +1,116 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory; +use ProxyManager\Factory\AccessInterceptorValueHolderFactory; +use ProxyManager\Factory\LazyLoadingGhostFactory; +use ProxyManager\Factory\LazyLoadingValueHolderFactory; +use ReflectionClass; +use ReflectionProperty; + +/** + * Verifies that proxy factories don't conflict with each other when generating proxies + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @link https://github.com/Ocramius/ProxyManager/issues/10 + * + * @group Functional + * @group issue-10 + * @coversNothing + */ +class MultipleProxyGenerationTest extends PHPUnit_Framework_TestCase +{ + /** + * Verifies that proxies generated from different factories will retain their specific implementation + * and won't conflict + * + * @dataProvider getTestedClasses + */ + public function testCanGenerateMultipleDifferentProxiesForSameClass($className) + { + $skipScopeLocalizerTests = false; + $ghostProxyFactory = new LazyLoadingGhostFactory(); + $virtualProxyFactory = new LazyLoadingValueHolderFactory(); + $accessInterceptorFactory = new AccessInterceptorValueHolderFactory(); + $accessInterceptorScopeLocalizerFactory = new AccessInterceptorScopeLocalizerFactory(); + $initializer = function () { + }; + + $reflectionClass = new ReflectionClass($className); + + if ((defined('HHVM_VERSION') || PHP_VERSION_ID < 50400) + && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE) + ) { + $skipScopeLocalizerTests = true; + } + + $generated = array( + $ghostProxyFactory->createProxy($className, $initializer), + $virtualProxyFactory->createProxy($className, $initializer), + $accessInterceptorFactory->createProxy(new $className()), + ); + + if (! $skipScopeLocalizerTests) { + $generated[] = $accessInterceptorScopeLocalizerFactory->createProxy(new $className()); + } + + foreach ($generated as $key => $proxy) { + $this->assertInstanceOf($className, $proxy); + + foreach ($generated as $comparedKey => $comparedProxy) { + if ($comparedKey === $key) { + continue; + } + + $this->assertNotSame(get_class($comparedProxy), get_class($proxy)); + } + } + + $this->assertInstanceOf('ProxyManager\Proxy\GhostObjectInterface', $generated[0]); + $this->assertInstanceOf('ProxyManager\Proxy\VirtualProxyInterface', $generated[1]); + $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[2]); + $this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $generated[2]); + + if (! $skipScopeLocalizerTests) { + $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[3]); + } + } + + /** + * @return string[][] + */ + public function getTestedClasses() + { + return array( + array('ProxyManagerTestAsset\\BaseClass'), + array('ProxyManagerTestAsset\\ClassWithMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithMixedProperties'), + array('ProxyManagerTestAsset\\ClassWithPrivateProperties'), + array('ProxyManagerTestAsset\\ClassWithProtectedProperties'), + array('ProxyManagerTestAsset\\ClassWithPublicProperties'), + array('ProxyManagerTestAsset\\EmptyClass'), + array('ProxyManagerTestAsset\\HydratedObject'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a84842404fa2a3065547015917a74ac77f300d7a --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php @@ -0,0 +1,207 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\ProxyGenerator\NullObjectGenerator; +use ProxyManagerTestAsset\BaseClass; +use ReflectionClass; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\NullObjectGenerator} produced objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class NullObjectFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getProxyMethods + */ + public function testMethodCalls($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $proxy = new $proxyName(); + + $this->assertSame(null, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $proxy = unserialize(serialize(new $proxyName())); + + $this->assertSame(null, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($className); + + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $proxy = new $proxyName(); + $cloned = clone $proxy; + + $this->assertSame(null, call_user_func_array(array($cloned, $method), $params)); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) + { + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $this->assertSame(null, $proxy->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyWriteAccess($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $newValue = uniqid(); + $proxy->$publicProperty = $newValue; + + $this->assertSame($newValue, $proxy->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyExistence($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $this->assertSame(null, $proxy->$publicProperty); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testPropertyUnset($instance, $proxy, $publicProperty) + { + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + unset($proxy->$publicProperty); + + $this->assertTrue(isset($instance->$publicProperty)); + $this->assertFalse(isset($proxy->$publicProperty)); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new NullObjectGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicTypeHintedMethod', + array('param' => new \stdClass()), + 'publicTypeHintedMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseClass', + new BaseClass(), + 'publicByReferenceMethod', + array(), + 'publicByReferenceMethodDefault' + ), + array( + 'ProxyManagerTestAsset\\BaseInterface', + new BaseClass(), + 'publicMethod', + array(), + 'publicMethodDefault' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + $instance1 = new BaseClass(); + $proxyName1 = $this->generateProxy(get_class($instance1)); + $instance2 = new BaseClass(); + $proxyName2 = $this->generateProxy(get_class($instance2)); + + return array( + array( + $instance1, + new $proxyName1($instance1), + 'publicProperty', + 'publicPropertyDefault', + ), + array( + $instance2, + unserialize(serialize(new $proxyName2($instance2))), + 'publicProperty', + 'publicPropertyDefault', + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9356e876c7e5f9ade6d36f36e9776b3a991b1e9f --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php @@ -0,0 +1,216 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Functional; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Factory\RemoteObject\Adapter\JsonRpc as JsonRpcAdapter; +use ProxyManager\Factory\RemoteObject\Adapter\XmlRpc as XmlRpcAdapter; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\ProxyGenerator\RemoteObjectGenerator; +use ProxyManagerTestAsset\RemoteProxy\Foo; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObjectGenerator} produced objects + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + * + * @group Functional + * @coversNothing + */ +class RemoteObjectFunctionalTest extends PHPUnit_Framework_TestCase +{ + /** + * @param mixed $expectedValue + * @param string $method + * @param array $params + * + * @return XmlRpcAdapter + */ + protected function getXmlRpcAdapter($expectedValue, $method, array $params) + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $client + ->expects($this->any()) + ->method('call') + ->with($this->stringEndsWith($method), $params) + ->will($this->returnValue($expectedValue)); + + $adapter = new XmlRpcAdapter( + $client, + array( + 'ProxyManagerTestAsset\RemoteProxy\Foo.foo' + => 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface.foo' + ) + ); + + return $adapter; + } + + /** + * @param mixed $expectedValue + * @param string $method + * @param array $params + * + * @return JsonRpcAdapter + */ + protected function getJsonRpcAdapter($expectedValue, $method, array $params) + { + $client = $this + ->getMockBuilder('Zend\Server\Client') + ->setMethods(array('call')) + ->getMock(); + + $client + ->expects($this->any()) + ->method('call') + ->with($this->stringEndsWith($method), $params) + ->will($this->returnValue($expectedValue)); + + $adapter = new JsonRpcAdapter( + $client, + array( + 'ProxyManagerTestAsset\RemoteProxy\Foo.foo' + => 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface.foo' + ) + ); + + return $adapter; + } + + /** + * @dataProvider getProxyMethods + */ + public function testXmlRpcMethodCalls($instanceOrClassname, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($instanceOrClassname); + + /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ + $proxy = new $proxyName($this->getXmlRpcAdapter($expectedValue, $method, $params)); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getProxyMethods + */ + public function testJsonRpcMethodCalls($instanceOrClassname, $method, $params, $expectedValue) + { + $proxyName = $this->generateProxy($instanceOrClassname); + + /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ + $proxy = new $proxyName($this->getJsonRpcAdapter($expectedValue, $method, $params)); + + $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); + } + + /** + * @dataProvider getPropertyAccessProxies + */ + public function testJsonRpcPropertyReadAccess($instanceOrClassname, $publicProperty, $propertyValue) + { + $proxyName = $this->generateProxy($instanceOrClassname); + + /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ + $proxy = new $proxyName( + $this->getJsonRpcAdapter($propertyValue, '__get', array($publicProperty)) + ); + + /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ + $this->assertSame($propertyValue, $proxy->$publicProperty); + } + + /** + * Generates a proxy for the given class name, and retrieves its class name + * + * @param string $parentClassName + * + * @return string + */ + private function generateProxy($parentClassName) + { + $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); + $generator = new RemoteObjectGenerator(); + $generatedClass = new ClassGenerator($generatedClassName); + $strategy = new EvaluatingGeneratorStrategy(); + + $generator->generate(new ReflectionClass($parentClassName), $generatedClass); + $strategy->generate($generatedClass); + + return $generatedClassName; + } + + /** + * Generates a list of object | invoked method | parameters | expected result + * + * @return array + */ + public function getProxyMethods() + { + return array( + array( + 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface', + 'foo', + array(), + 'bar remote' + ), + array( + 'ProxyManagerTestAsset\RemoteProxy\Foo', + 'foo', + array(), + 'bar remote' + ), + array( + new Foo(), + 'foo', + array(), + 'bar remote' + ), + array( + 'ProxyManagerTestAsset\RemoteProxy\BazServiceInterface', + 'baz', + array('baz'), + 'baz remote' + ), + ); + } + + /** + * Generates proxies and instances with a public property to feed to the property accessor methods + * + * @return array + */ + public function getPropertyAccessProxies() + { + return array( + array( + 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface', + 'publicProperty', + 'publicProperty remote', + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8bab3accf2a80eb7f69ef91469b43c5715a82177 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Generator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ClassGenerator; + +/** + * Tests for {@see \ProxyManager\Generator\ClassGenerator} + * + * @author Gordon Stratton <gordon.stratton@gmail.com> + * @license MIT + */ +class ClassGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Generator\ClassGenerator::setExtendedClass + */ + public function testExtendedClassesAreFQCNs() + { + $desiredFqcn = '\\stdClass'; + $classNameInputs = array('stdClass', '\\stdClass\\'); + + foreach ($classNameInputs as $className) { + $classGenerator = new ClassGenerator(); + $classGenerator->setExtendedClass($className); + + $this->assertEquals($desiredFqcn, $classGenerator->getExtendedClass()); + } + } + + /** + * @covers \ProxyManager\Generator\ClassGenerator::setImplementedInterfaces + */ + public function testImplementedInterfacesAreFQCNs() + { + $desiredFqcns = array('\\Countable'); + $interfaceNameInputs = array(array('Countable'), array('\\Countable\\')); + + foreach ($interfaceNameInputs as $interfaceNames) { + $classGenerator = new ClassGenerator(); + $classGenerator->setImplementedInterfaces($interfaceNames); + + $this->assertEquals($desiredFqcns, $classGenerator->getImplementedInterfaces()); + } + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f9cd0334957b42aaab0a5a827b15b8373a94ab40 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Generator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\MagicMethodGenerator; + +/** + * Tests for {@see \ProxyManager\Generator\MagicMethodGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicMethodGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\Generator\MagicMethodGenerator::__construct + */ + public function testGeneratesCorrectByRefReturnValue() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'); + $magicMethod = new MagicMethodGenerator($reflection, '__get', array('name')); + + $this->assertTrue($magicMethod->returnsReference()); + } + + /** + * @covers \ProxyManager\Generator\MagicMethodGenerator::__construct + */ + public function testGeneratesCorrectByValReturnValue() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $magicMethod = new MagicMethodGenerator($reflection, '__get', array('name')); + + $this->assertFalse($magicMethod->returnsReference()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6a6c8307e98994eb8f77e09a03b7f73817ddf66e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Generator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\MethodGenerator; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\Generator\MethodGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\Generator\MethodGenerator + */ +class MethodGeneratorTest extends PHPUnit_Framework_TestCase +{ + public function testGenerateSimpleMethod() + { + $methodGenerator = new MethodGenerator(); + + $methodGenerator->setReturnsReference(true); + $methodGenerator->setName('methodName'); + $methodGenerator->setVisibility('protected'); + $methodGenerator->setBody('/* body */'); + $methodGenerator->setDocBlock('docBlock'); + $methodGenerator->setParameter(new ParameterGenerator('foo')); + + $this->assertSame(true, $methodGenerator->returnsReference()); + $this->assertStringMatchesFormat( + '%a/**%adocBlock%a*/%aprotected function & methodName($foo)%a{%a/* body */%a}', + $methodGenerator->generate() + ); + } + + /** + * Verify that building from reflection works + */ + public function testGenerateFromReflection() + { + $method = MethodGenerator::fromReflection(new MethodReflection(__CLASS__, __FUNCTION__)); + + $this->assertSame(__FUNCTION__, $method->getName()); + $this->assertSame(MethodGenerator::VISIBILITY_PUBLIC, $method->getVisibility()); + $this->assertFalse($method->isStatic()); + $this->assertSame('Verify that building from reflection works', $method->getDocBlock()->getShortDescription()); + + $method = MethodGenerator::fromReflection( + new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'protectedMethod') + ); + + $this->assertSame(MethodGenerator::VISIBILITY_PROTECTED, $method->getVisibility()); + + $method = MethodGenerator::fromReflection( + new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'privateMethod') + ); + + $this->assertSame(MethodGenerator::VISIBILITY_PRIVATE, $method->getVisibility()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f9874084810c29c599ec0088dabac466936490c4 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php @@ -0,0 +1,129 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Generator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ParameterGenerator; +use Zend\Code\Reflection\ParameterReflection; + +/** + * Tests for {@see \ProxyManager\Generator\ParameterGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\Generator\ParameterGenerator + */ +class ParameterGeneratorTest extends PHPUnit_Framework_TestCase +{ + public function testGeneratesProperTypeHint() + { + $generator = new ParameterGenerator('foo'); + + $generator->setType('array'); + $this->assertSame('array $foo', $generator->generate()); + + $generator->setType('stdClass'); + $this->assertSame('\\stdClass $foo', $generator->generate()); + + $generator->setType('\\fooClass'); + $this->assertSame('\\fooClass $foo', $generator->generate()); + } + + public function testGeneratesMethodWithCallableType() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0'); + } + + $generator = new ParameterGenerator(); + + $generator->setType('callable'); + $generator->setName('foo'); + + $this->assertSame('callable $foo', $generator->generate()); + } + + public function testVisitMethodWithCallable() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0'); + } + + $parameter = new ParameterReflection( + array('ProxyManagerTestAsset\\CallableTypeHintClass', 'callableTypeHintMethod'), + 'parameter' + ); + + $generator = ParameterGenerator::fromReflection($parameter); + + $this->assertSame('callable', $generator->getType()); + } + + public function testReadsParameterDefaults() + { + $parameter = ParameterGenerator::fromReflection(new ParameterReflection( + array( + 'ProxyManagerTestAsset\\ClassWithMethodWithDefaultParameters', + 'publicMethodWithDefaults' + ), + 'parameter' + )); + + /* @var $defaultValue \Zend\Code\Generator\ValueGenerator */ + $defaultValue = $parameter->getDefaultValue(); + + $this->assertInstanceOf('Zend\\Code\\Generator\\ValueGenerator', $defaultValue); + $this->assertSame(array('foo'), $defaultValue->getValue()); + + $this->assertStringMatchesFormat('array%a$parameter%a=%aarray(\'foo\')', $parameter->generate()); + } + + public function testReadsParameterTypeHint() + { + $parameter = ParameterGenerator::fromReflection(new ParameterReflection( + array('ProxyManagerTestAsset\\BaseClass', 'publicTypeHintedMethod'), + 'param' + )); + + $this->assertSame('stdClass', $parameter->getType()); + } + + public function testGeneratesParameterPassedByReference() + { + $parameter = new ParameterGenerator('foo'); + + $parameter->setPassedByReference(true); + + $this->assertStringMatchesFormat('&%A$foo', $parameter->generate()); + } + + public function testGeneratesDefaultParameterForInternalPhpClasses() + { + $parameter = ParameterGenerator::fromReflection(new ParameterReflection( + array( + 'Phar', + 'compress' + ), + 1 + )); + + $this->assertNull($parameter->getDefaultValue()->getValue()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b513978e626fda8586095c041669246e39c7a091 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php @@ -0,0 +1,75 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Generator\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\Generator\Util\UniqueIdentifierGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class UniqueIdentifierGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getBaseIdentifierNames + * + * @covers \ProxyManager\Generator\Util\UniqueIdentifierGenerator::getIdentifier + */ + public function testGeneratesUniqueIdentifiers($name) + { + $this->assertNotSame( + UniqueIdentifierGenerator::getIdentifier($name), + UniqueIdentifierGenerator::getIdentifier($name) + ); + } + + /** + * @dataProvider getBaseIdentifierNames + * + * @covers \ProxyManager\Generator\Util\UniqueIdentifierGenerator::getIdentifier + */ + public function testGeneratesValidIdentifiers($name) + { + $this->assertRegExp( + '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/', + UniqueIdentifierGenerator::getIdentifier($name) + ); + } + + /** + * Data provider generating identifier names to be checked + * + * @return string[][] + */ + public function getBaseIdentifierNames() + { + return array( + array(''), + array('1'), + array('foo'), + array('Foo'), + array('bar'), + array('Bar'), + array('foo_bar'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3d5f2fc4401b80f5be089230546242a7a15db00d --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php @@ -0,0 +1,46 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\GeneratorStrategy; + +use PHPUnit_Framework_TestCase; +use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\GeneratorStrategy\BaseGeneratorStrategy} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class BaseGeneratorStrategyTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\GeneratorStrategy\BaseGeneratorStrategy::generate + */ + public function testGenerate() + { + $strategy = new BaseGeneratorStrategy(); + $className = UniqueIdentifierGenerator::getIdentifier('Foo'); + $classGenerator = new ClassGenerator($className); + $generated = $strategy->generate($classGenerator); + + $this->assertGreaterThan(0, strpos($generated, $className)); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..79c9307388fcdef1c0e96346669c2b57e1dac4dc --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\GeneratorStrategy; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; + +/** + * Tests for {@see \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class EvaluatingGeneratorStrategyTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate + * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct + */ + public function testGenerate() + { + $strategy = new EvaluatingGeneratorStrategy(); + $className = UniqueIdentifierGenerator::getIdentifier('Foo'); + $classGenerator = new ClassGenerator($className); + $generated = $strategy->generate($classGenerator); + + $this->assertGreaterThan(0, strpos($generated, $className)); + $this->assertTrue(class_exists($className, false)); + } + + /** + * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate + * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct + */ + public function testGenerateWithDisabledEval() + { + if (! ini_get('suhosin.executor.disable_eval')) { + $this->markTestSkipped('Ini setting "suhosin.executor.disable_eval" is needed to run this test'); + } + + $strategy = new EvaluatingGeneratorStrategy(); + $className = 'Foo' . uniqid(); + $classGenerator = new ClassGenerator($className); + $generated = $strategy->generate($classGenerator); + + $this->assertGreaterThan(0, strpos($generated, $className)); + $this->assertTrue(class_exists($className, false)); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..eeb5abe173003ddfa42c7fc9e1d967191dff05ad --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\GeneratorStrategy; + +use PHPUnit_Framework_TestCase; +use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; + +/** + * Tests for {@see \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class FileWriterGeneratorStrategyTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy::__construct + * @covers \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy::generate + */ + public function testGenerate() + { + $locator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); + $generator = new FileWriterGeneratorStrategy($locator); + $tmpFile = sys_get_temp_dir() . '/FileWriterGeneratorStrategyTest' . uniqid() . '.php'; + $namespace = 'Foo'; + $className = UniqueIdentifierGenerator::getIdentifier('Bar'); + $fqcn = $namespace . '\\' . $className; + + $locator + ->expects($this->any()) + ->method('getProxyFileName') + ->with($fqcn) + ->will($this->returnValue($tmpFile)); + + $body = $generator->generate(new ClassGenerator($fqcn)); + + $this->assertGreaterThan(0, strpos($body, $className)); + $this->assertFalse(class_exists($fqcn, false)); + $this->assertTrue(file_exists($tmpFile)); + + require $tmpFile; + + $this->assertTrue(class_exists($fqcn, false)); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2c172bd8f97190d852d883bb5b9bba0b327a90e0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php @@ -0,0 +1,119 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Inflector; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Inflector\ClassNameInflector; +use ProxyManager\Inflector\ClassNameInflectorInterface; + +/** + * Tests for {@see \ProxyManager\Inflector\ClassNameInflector} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassNameInflectorTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getClassNames + * + * @covers \ProxyManager\Inflector\ClassNameInflector::__construct + * @covers \ProxyManager\Inflector\ClassNameInflector::getUserClassName + * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName + * @covers \ProxyManager\Inflector\ClassNameInflector::isProxyClassName + */ + public function testInflector($realClassName, $proxyClassName) + { + $inflector = new ClassNameInflector('ProxyNS'); + + $this->assertFalse($inflector->isProxyClassName($realClassName)); + $this->assertTrue($inflector->isProxyClassName($proxyClassName)); + $this->assertStringMatchesFormat($realClassName, $inflector->getUserClassName($realClassName)); + $this->assertStringMatchesFormat($proxyClassName, $inflector->getProxyClassName($proxyClassName)); + $this->assertStringMatchesFormat($proxyClassName, $inflector->getProxyClassName($realClassName)); + $this->assertStringMatchesFormat($realClassName, $inflector->getUserClassName($proxyClassName)); + } + + /** + * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName + */ + public function testGeneratesSameClassNameWithSameParameters() + { + $inflector = new ClassNameInflector('ProxyNS'); + + $this->assertSame($inflector->getProxyClassName('Foo\\Bar'), $inflector->getProxyClassName('Foo\\Bar')); + $this->assertSame( + $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')), + $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')) + ); + $this->assertSame( + $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')), + $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) + ); + } + + /** + * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName + */ + public function testGeneratesDifferentClassNameWithDifferentParameters() + { + $inflector = new ClassNameInflector('ProxyNS'); + + $this->assertNotSame( + $inflector->getProxyClassName('Foo\\Bar'), + $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar')) + ); + $this->assertNotSame( + $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')), + $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) + ); + $this->assertNotSame( + $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar', 'tab' => 'baz')), + $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar')) + ); + $this->assertNotSame( + $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar', 'tab' => 'baz')), + $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz', 'foo' => 'bar')) + ); + } + + /** + * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName + */ + public function testGeneratesCorrectClassNameWhenGivenLeadingBackslash() + { + $inflector = new ClassNameInflector('ProxyNS'); + + $this->assertSame( + $inflector->getProxyClassName('\\Foo\\Bar', array('tab' => 'baz')), + $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) + ); + } + + /** + * @return array + */ + public function getClassNames() + { + return array( + array('Foo', 'ProxyNS\\' . ClassNameInflectorInterface::PROXY_MARKER . '\\Foo\\%s'), + array('Foo\\Bar', 'ProxyNS\\' . ClassNameInflectorInterface::PROXY_MARKER . '\\Foo\\Bar\\%s'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5098a5e5ae8015abfac4deb644603c95a972f016 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\Inflector\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Inflector\Util\ParameterEncoder; + +/** + * Tests for {@see \ProxyManager\Inflector\Util\ParameterEncoder} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ParameterEncoderTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getParameters + * + * @covers \ProxyManager\Inflector\Util\ParameterEncoder::encodeParameters + */ + public function testGeneratesValidClassName(array $parameters) + { + $encoder = new ParameterEncoder(); + + $this->assertRegExp( + '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+/', + $encoder->encodeParameters($parameters), + 'Encoded string is a valid class identifier' + ); + } + + /** + * @return array + */ + public function getParameters() + { + return array( + array(array()), + array(array('foo' => 'bar')), + array(array('bar' => 'baz')), + array(array(null)), + array(array(null, null)), + array(array('bar' => null)), + array(array('bar' => 12345)), + array(array('foo' => 'bar', 'bar' => 'baz')), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ff6e4671016253260689a5fc629f722ff1b15a87 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php @@ -0,0 +1,93 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ReflectionClass; + +/** + * Base test for proxy generators + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +abstract class AbstractProxyGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTestedImplementations + * + * Verifies that generated code is valid and implements expected interfaces + */ + public function testGeneratesValidCode($className) + { + $generator = $this->getProxyGenerator(); + $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); + $generatedClass = new ClassGenerator($generatedClassName); + $originalClass = new ReflectionClass($className); + $generatorStrategy = new EvaluatingGeneratorStrategy(); + + $generator->generate($originalClass, $generatedClass); + $generatorStrategy->generate($generatedClass); + + $generatedReflection = new ReflectionClass($generatedClassName); + + if ($originalClass->isInterface()) { + $this->assertTrue($generatedReflection->implementsInterface($className)); + } else { + $this->assertSame($originalClass->getName(), $generatedReflection->getParentClass()->getName()); + } + + $this->assertSame($generatedClassName, $generatedReflection->getName()); + + foreach ($this->getExpectedImplementedInterfaces() as $interface) { + $this->assertTrue($generatedReflection->implementsInterface($interface)); + } + } + + /** + * Retrieve a new generator instance + * + * @return \ProxyManager\ProxyGenerator\ProxyGeneratorInterface + */ + abstract protected function getProxyGenerator(); + + /** + * Retrieve interfaces that should be implemented by the generated code + * + * @return string[] + */ + abstract protected function getExpectedImplementedInterfaces(); + + /** + * @return array + */ + public function getTestedImplementations() + { + return array( + array('ProxyManagerTestAsset\\BaseClass'), + array('ProxyManagerTestAsset\\ClassWithMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithMixedProperties'), + array('ProxyManagerTestAsset\\BaseInterface'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c7cb0e12126eee23bd961a11f2cd9778868e98f9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php @@ -0,0 +1,60 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicWakeupTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $magicWakeup = new MagicWakeup($reflection); + + $this->assertSame('__wakeup', $magicWakeup->getName()); + $this->assertCount(0, $magicWakeup->getParameters()); + $this->assertSame("unset(\$this->bar, \$this->baz);", $magicWakeup->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup::__construct + */ + public function testBodyStructureWithoutPublicProperties() + { + $magicWakeup = new MagicWakeup(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); + + $this->assertSame('__wakeup', $magicWakeup->getName()); + $this->assertCount(0, $magicWakeup->getParameters()); + $this->assertEmpty($magicWakeup->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..277e4765007951713e5b625f282c9fc0335a980a --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor; +use PHPUnit_Framework_TestCase; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetMethodPrefixInterceptorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor::__construct + */ + public function testBodyStructure() + { + $suffix = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $suffix->expects($this->once())->method('getName')->will($this->returnValue('foo')); + + $setter = new SetMethodPrefixInterceptor($suffix); + + $this->assertSame('setMethodPrefixInterceptor', $setter->getName()); + $this->assertCount(2, $setter->getParameters()); + $this->assertSame('$this->foo[$methodName] = $prefixInterceptor;', $setter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c718325841756d0287b077155428fa389f29924b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\MethodGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor; +use PHPUnit_Framework_TestCase; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetMethodSuffixInterceptorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor::__construct + */ + public function testBodyStructure() + { + $suffix = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $suffix->expects($this->once())->method('getName')->will($this->returnValue('foo')); + + $setter = new SetMethodSuffixInterceptor($suffix); + + $this->assertSame('setMethodSuffixInterceptor', $setter->getName()); + $this->assertCount(2, $setter->getParameters()); + $this->assertSame('$this->foo[$methodName] = $suffixInterceptor;', $setter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..002761fae7903ca6023b52696ed6bbdeedad7ba9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\PropertyGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors + */ +class MethodPrefixInterceptorsTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new MethodPrefixInterceptors(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8e5b4b3039147fb0212d1a03abb7fd837eb5e72d --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\PropertyGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodSuffixInterceptors; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodSuffixInterceptors} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodSuffixInterceptors + */ +class MethodSuffixInterceptorsTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new MethodSuffixInterceptors(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9202412a65f4f5d033844db812ab7a6d3a6fe461 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php @@ -0,0 +1,205 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConstructorTest extends PHPUnit_Framework_TestCase +{ + private $prefixInterceptors; + private $suffixInterceptors; + public function setUp() + { + $this->prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $this->suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $this->prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $this->suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct + */ + public function testSignature() + { + $constructor = new Constructor( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'), + $this->prefixInterceptors, + $this->suffixInterceptors + ); + $this->assertSame('__construct', $constructor->getName()); + + $parameters = $constructor->getParameters(); + + $this->assertCount(3, $parameters); + + $this->assertSame( + 'ProxyManagerTestAsset\\ClassWithProtectedProperties', + $parameters['localizedObject']->getType() + ); + $this->assertSame('array', $parameters['prefixInterceptors']->getType()); + $this->assertSame('array', $parameters['suffixInterceptors']->getType()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct + */ + public function testBodyStructure() + { + $constructor = new Constructor( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties'), + $this->prefixInterceptors, + $this->suffixInterceptors + ); + + $this->assertSame( + '$this->property0 = & $localizedObject->property0; + +$this->property1 = & $localizedObject->property1; + +$this->property2 = & $localizedObject->property2; + +$this->property3 = & $localizedObject->property3; + +$this->property4 = & $localizedObject->property4; + +$this->property5 = & $localizedObject->property5; + +$this->property6 = & $localizedObject->property6; + +$this->property7 = & $localizedObject->property7; + +$this->property8 = & $localizedObject->property8; + +$this->property9 = & $localizedObject->property9; + +$this->pre = $prefixInterceptors; +$this->post = $suffixInterceptors;', + $constructor->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct + */ + public function testBodyStructureWithProtectedProperties() + { + $constructor = new Constructor( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'), + $this->prefixInterceptors, + $this->suffixInterceptors + ); + + $this->assertSame( + '$this->property0 = & $localizedObject->property0; + +$this->property1 = & $localizedObject->property1; + +$this->property2 = & $localizedObject->property2; + +$this->property3 = & $localizedObject->property3; + +$this->property4 = & $localizedObject->property4; + +$this->property5 = & $localizedObject->property5; + +$this->property6 = & $localizedObject->property6; + +$this->property7 = & $localizedObject->property7; + +$this->property8 = & $localizedObject->property8; + +$this->property9 = & $localizedObject->property9; + +$this->pre = $prefixInterceptors; +$this->post = $suffixInterceptors;', + $constructor->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct + */ + public function testBodyStructureWithPrivateProperties() + { + if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) { + $this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException'); + } + + $constructor = new Constructor( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithPrivateProperties'), + $this->prefixInterceptors, + $this->suffixInterceptors + ); + + $this->assertSame( + '\Closure::bind(function () use ($localizedObject) { + $this->property0 = & $localizedObject->property0; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property1 = & $localizedObject->property1; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property2 = & $localizedObject->property2; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property3 = & $localizedObject->property3; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property4 = & $localizedObject->property4; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property5 = & $localizedObject->property5; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property6 = & $localizedObject->property6; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property7 = & $localizedObject->property7; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property8 = & $localizedObject->property8; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +\Closure::bind(function () use ($localizedObject) { + $this->property9 = & $localizedObject->property9; +}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); + +$this->pre = $prefixInterceptors; +$this->post = $suffixInterceptors;', + $constructor->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9fb8a2613cac62bd337b88c91ef5779c044a51db --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php @@ -0,0 +1,61 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod + */ +class InterceptedMethodTest extends PHPUnit_Framework_TestCase +{ + public function testBodyStructure() + { + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $method = InterceptedMethod::generateMethod( + new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'), + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertInstanceOf('ProxyManager\\Generator\\MethodGenerator', $method); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertGreaterThan( + 0, + strpos( + $method->getBody(), + '$returnValue = parent::publicByReferenceParameterMethod($param, $byRefParam);' + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3327f0d030ce75c87c0d7b4d498f80b9d56b81a1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php @@ -0,0 +1,70 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicCloneTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); + + $this->assertSame('__clone', $magicClone->getName()); + $this->assertCount(0, $magicClone->getParameters()); + $this->assertStringMatchesFormat("%a\n\n\$returnValue = null;\n\n%a", $magicClone->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); + + $this->assertSame('__clone', $magicClone->getName()); + $this->assertCount(0, $magicClone->getParameters()); + $this->assertStringMatchesFormat("%a\n\n\$returnValue = parent::__clone();\n\n%a", $magicClone->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3d188bb5c74859d4ca0d4eda66a0c023f62c95f7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicGet( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & $accessor();%a', $magicGet->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicGet( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & parent::__get($name);%a', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..13dfd00950cb944fd360a4f0fc6df3b8ca475526 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIssetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicIsset( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__isset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = $accessor();%a', $magicGet->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicIsset( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__isset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & parent::__isset($name);%a', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..14f6ccf43fcdaf0afb82f014528840fd7cef4599 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicSet( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__set', $magicGet->getName()); + $this->assertCount(2, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & $accessor();%a', $magicGet->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicSet( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__set', $magicGet->getName()); + $this->assertCount(2, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & parent::__set($name, $value);%a', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3f3d9265703de5e6c7d40bf29580d2837ac12f7c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleepTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicSleep( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__sleep', $magicGet->getName()); + $this->assertEmpty($magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = array_keys((array) $this);%a', $magicGet->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicSleep( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__sleep', $magicGet->getName()); + $this->assertEmpty($magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & parent::__sleep();%a', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f22bc9899f0099430bded62cfb527a72c9337a86 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php @@ -0,0 +1,78 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnsetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicUnset( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__unset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = $accessor();%a', $magicGet->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructureWithInheritedMethod() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicGet = new MagicUnset( + $reflection, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame('__unset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%a$returnValue = & parent::__unset($name);%a', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d32889854d2037532cad37125efe7c21044fe988 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php @@ -0,0 +1,79 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InterceptorGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator + */ + public function testInterceptorGenerator() + { + $method = $this->getMock('ProxyManager\\Generator\\MethodGenerator'); + $bar = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); + $baz = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $bar->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $baz->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $method->expects($this->any())->method('getName')->will($this->returnValue('fooMethod')); + $method->expects($this->any())->method('getParameters')->will($this->returnValue(array($bar, $baz))); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $body = InterceptorGenerator::createInterceptedMethodBody( + '$returnValue = "foo";', + $method, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame( + 'if (isset($this->pre[\'fooMethod\'])) {' . "\n" + . ' $returnEarly = false;' . "\n" + . ' $prefixReturnValue = $this->pre[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', ' + . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnEarly);' . "\n\n" + . ' if ($returnEarly) {' . "\n" + . ' return $prefixReturnValue;' . "\n" + . ' }' . "\n" + . '}' . "\n\n" + . '$returnValue = "foo";' . "\n\n" + . 'if (isset($this->post[\'fooMethod\'])) {' . "\n" + . ' $returnEarly = false;' . "\n" + . ' $suffixReturnValue = $this->post[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', ' + . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnValue, $returnEarly);' . "\n\n" + . ' if ($returnEarly) {' . "\n" + . ' return $suffixReturnValue;' . "\n" + . ' }' . "\n" + . '}' . "\n\n" + . 'return $returnValue;', + $body + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f90decc8e303f1fee2fb745f7026e7f9c49cbbdf --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php @@ -0,0 +1,75 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator; +use ReflectionClass; +use ReflectionProperty; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator + */ +class AccessInterceptorScopeLocalizerTest extends AbstractProxyGeneratorTest +{ + /** + * @dataProvider getTestedImplementations + * + * {@inheritDoc} + */ + public function testGeneratesValidCode($className) + { + $reflectionClass = new ReflectionClass($className); + + if ($reflectionClass->isInterface()) { + // @todo interfaces *may* be proxied by deferring property localization to the constructor (no hardcoding) + $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException'); + + return parent::testGeneratesValidCode($className); + } + + if ((PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) + && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE) + ) { + $this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException'); + } + + return parent::testGeneratesValidCode($className); + } + + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new AccessInterceptorScopeLocalizerGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array('ProxyManager\\Proxy\\AccessInterceptorInterface'); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8f61250aeacd84a912ff22c4321cff8ec2179aa0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoading\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConstructorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $constructor = new Constructor($reflection, $initializer); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(1, $constructor->getParameters()); + $this->assertSame("unset(\$this->bar, \$this->baz);\n\n\$this->foo = \$initializer;", $constructor->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor::__construct + */ + public function testBodyStructureWithoutPublicProperties() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $constructor = new Constructor(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'), $initializer); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(1, $constructor->getParameters()); + $this->assertSame("\$this->foo = \$initializer;", $constructor->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..931a5bf003613554e79a29146f5ca31cf6d2ca12 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php @@ -0,0 +1,84 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConstructorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor::__construct + */ + public function testBodyStructure() + { + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $constructor = new Constructor($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(3, $constructor->getParameters()); + $this->assertSame( + "unset(\$this->bar, \$this->baz);\n\n\$this->foo = \$wrappedObject;\n\$this->pre = \$prefixInterceptors;" + . "\n\$this->post = \$suffixInterceptors;", + $constructor->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor::__construct + */ + public function testBodyStructureWithoutPublicProperties() + { + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $constructor = new Constructor($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(3, $constructor->getParameters()); + $this->assertSame( + "\$this->foo = \$wrappedObject;\n\$this->pre = \$prefixInterceptors;" + . "\n\$this->post = \$suffixInterceptors;", + $constructor->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php new file mode 100644 index 0000000000000000000000000000000000000000..069eedcb5bb19249d1ebe3583ca8cce99a274e2d --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod::generateMethod + */ +class InterceptedMethodTest extends PHPUnit_Framework_TestCase +{ + /** + * + */ + public function testBodyStructure() + { + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $method = InterceptedMethod::generateMethod( + new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'), + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertInstanceOf('ProxyManager\\Generator\\MethodGenerator', $method); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertGreaterThan( + 0, + strpos( + $method->getBody(), + '$returnValue = $this->foo->publicByReferenceParameterMethod($param, $byRefParam);' + ) + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1e88b746cdad08bc624affc7e0dbb3931a2751a9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php @@ -0,0 +1,62 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicClone; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicClone} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicCloneTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicClone::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $magicClone = new MagicClone($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); + + $this->assertSame('__clone', $magicClone->getName()); + $this->assertCount(0, $magicClone->getParameters()); + $this->assertSame( + '$this->bar = clone $this->bar;' . "\n\n" + . 'foreach ($this->pre as $key => $value) {' . "\n" + . ' $this->pre[$key] = clone $value;' . "\n" + . '}' . "\n\n" + . 'foreach ($this->post as $key => $value) {' . "\n" + . ' $this->post[$key] = clone $value;' . "\n" + . '}', + $magicClone->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d450b09e7c3b6651e3a9ffb4ab9be120bc80cc00 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicGet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicGet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + + $magicGet = new MagicGet( + $reflection, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors, + $publicProperties + ); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat('%A$returnValue = & $this->bar->$name;%A', $magicGet->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f5a13ff4982b06c8da79c016748faa2450e7b5b6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIssetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + + $magicIsset = new MagicIsset( + $reflection, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors, + $publicProperties + ); + + $this->assertSame('__isset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertGreaterThan(0, strpos($magicIsset->getBody(), '$returnValue = isset($this->bar->$name);')); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d5e5357e06c71c5a5f711557a69b2f0c70da82e0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php @@ -0,0 +1,64 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicSet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicSet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + + $magicSet = new MagicSet( + $reflection, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors, + $publicProperties + ); + + $this->assertSame('__set', $magicSet->getName()); + $this->assertCount(2, $magicSet->getParameters()); + $this->assertGreaterThan(0, strpos($magicSet->getBody(), '$returnValue = ($this->bar->$name = $value);')); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e785287ed8241eb6229a9f1663946ed2bee399f9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php @@ -0,0 +1,67 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnsetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + + $magicUnset = new MagicUnset( + $reflection, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors, + $publicProperties + ); + + $this->assertSame('__unset', $magicUnset->getName()); + $this->assertCount(1, $magicUnset->getParameters()); + $this->assertGreaterThan( + 0, + strpos($magicUnset->getBody(), 'unset($this->bar->$name);') + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f4950b310e0a41e220821a78a912e602a8804b8f --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php @@ -0,0 +1,82 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InterceptorGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator + */ + public function testInterceptorGenerator() + { + $method = $this->getMock('ProxyManager\\Generator\\MethodGenerator'); + $bar = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); + $baz = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $bar->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $baz->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $method->expects($this->any())->method('getName')->will($this->returnValue('fooMethod')); + $method->expects($this->any())->method('getParameters')->will($this->returnValue(array($bar, $baz))); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); + $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); + + $body = InterceptorGenerator::createInterceptedMethodBody( + '$returnValue = "foo";', + $method, + $valueHolder, + $prefixInterceptors, + $suffixInterceptors + ); + + $this->assertSame( + 'if (isset($this->pre[\'fooMethod\'])) {' . "\n" + . ' $returnEarly = false;' . "\n" + . ' $prefixReturnValue = $this->pre[\'fooMethod\']->__invoke($this, $this->foo, \'fooMethod\', ' + . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnEarly);' . "\n\n" + . ' if ($returnEarly) {' . "\n" + . ' return $prefixReturnValue;' . "\n" + . ' }' . "\n" + . '}' . "\n\n" + . '$returnValue = "foo";' . "\n\n" + . 'if (isset($this->post[\'fooMethod\'])) {' . "\n" + . ' $returnEarly = false;' . "\n" + . ' $suffixReturnValue = $this->post[\'fooMethod\']->__invoke($this, $this->foo, \'fooMethod\', ' + . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnValue, $returnEarly);' . "\n\n" + . ' if ($returnEarly) {' . "\n" + . ' return $suffixReturnValue;' . "\n" + . ' }' . "\n" + . '}' . "\n\n" + . 'return $returnValue;', + $body + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..58410b4fd7952b182bf493a665c06b1f96337eac --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php @@ -0,0 +1,51 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator + */ +class AccessInterceptorValueHolderTest extends AbstractProxyGeneratorTest +{ + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new AccessInterceptorValueHolderGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array( + 'ProxyManager\\Proxy\\AccessInterceptorInterface', + 'ProxyManager\\Proxy\\ValueHolderInterface', + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..32c0a975373d05732659acaaa4b659d16d0f4f84 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php @@ -0,0 +1,57 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class CallInitializerTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $propertiesDefaults = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initializationTracker = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('init')); + $propertiesDefaults->expects($this->any())->method('getName')->will($this->returnValue('props')); + $initializationTracker->expects($this->any())->method('getName')->will($this->returnValue('track')); + + $callInitializer = new CallInitializer($initializer, $propertiesDefaults, $initializationTracker); + + $this->assertStringMatchesFormat( + '%Aif ($this->track || ! $this->init) {%areturn;%a}%a' + . '$this->track = true;%a' + . 'foreach (self::$props as $key => $default) {%a' + . '$this->$key = $default;%a' + . '$this->init->__invoke(%a);%a' + . '$this->track = false;', + $callInitializer->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5b7be9ab18dd2b8c87f222c26817f2339b45934b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetProxyInitializerTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $getter = new GetProxyInitializer($initializer); + + $this->assertSame('getProxyInitializer', $getter->getName()); + $this->assertCount(0, $getter->getParameters()); + $this->assertSame('return $this->foo;', $getter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..842b34800be81853044ce23f3359932ff8d7a4b9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializeProxyTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $initializeProxy = new InitializeProxy($initializer, $initCall); + + $this->assertSame('initializeProxy', $initializeProxy->getName()); + $this->assertCount(0, $initializeProxy->getParameters()); + $this->assertSame( + 'return $this->foo && $this->bar(\'initializeProxy\', array());', + $initializeProxy->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..26d5a346fecf25748f5f1aab54f6277720f21671 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class IsProxyInitializedTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $isProxyInitialized = new IsProxyInitialized($initializer); + + $this->assertSame('isProxyInitialized', $isProxyInitialized->getName()); + $this->assertCount(0, $isProxyInitialized->getParameters()); + $this->assertSame('return ! $this->foo;', $isProxyInitialized->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e202458246af868ffa56142c0729e9d3d637e9e7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php @@ -0,0 +1,79 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingMethodInterceptorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); + $method = LazyLoadingMethodInterceptor::generateMethod($reflection, $initializer, $initCall); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertSame( + "\$this->foo && \$this->bar('publicByReferenceParameterMethod', " + . "array('param' => \$param, 'byRefParam' => \$byRefParam));\n\n" + . "return parent::publicByReferenceParameterMethod(\$param, \$byRefParam);", + $method->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor + */ + public function testBodyStructureWithoutParameters() + { + $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $method = LazyLoadingMethodInterceptor::generateMethod($reflectionMethod, $initializer, $initCall); + + $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); + $this->assertCount(0, $method->getParameters()); + $this->assertSame( + "\$this->foo && \$this->bar('testBodyStructureWithoutParameters', array());\n\n" + . "return parent::testBodyStructureWithoutParameters();", + $method->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d3524020ff3a8a9557c73c8fe88e9f6356fa1238 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicCloneTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicClone = new MagicClone($reflection, $initializer, $initCall); + + $this->assertSame('__clone', $magicClone->getName()); + $this->assertCount(0, $magicClone->getParameters()); + $this->assertSame( + "\$this->foo && \$this->bar('__clone', array());", + $magicClone->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..33a73e886534a39a8f2852deb7567313c486a01f --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php @@ -0,0 +1,122 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGetTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initializer; + + /** + * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initMethod; + + /** + * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject + */ + protected $publicProperties; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + $this->publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" + . "%a", + $magicGet->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructureWithPublicProperties() + { + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" + . "%a", + $magicGet->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructureWithOverriddenMagicGet() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertSame( + "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" + . "return parent::__get(\$name);", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ea6f61d1b0bd5b84a1770883186dd73cd97a35b7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php @@ -0,0 +1,121 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIssetTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initializer; + + /** + * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initMethod; + + /** + * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject + */ + protected $publicProperties; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + $this->publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__isset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" + . "%areturn %s;", + $magicIsset->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructureWithPublicProperties() + { + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__isset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" + . "%areturn %s;", + $magicIsset->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructureWithOverriddenMagicGet() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__isset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertSame( + "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" + . "return parent::__isset(\$name);", + $magicIsset->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..60f6a103cb01d85298acb65159e8309a93a302ca --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php @@ -0,0 +1,122 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSetTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initializer; + + /** + * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initMethod; + + /** + * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject + */ + protected $publicProperties; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + $this->publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__set', $magicSet->getName()); + $this->assertCount(2, $magicSet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" + . "%areturn %s;", + $magicSet->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructureWithPublicProperties() + { + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__set', $magicSet->getName()); + $this->assertCount(2, $magicSet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" + . "%areturn %s;", + $magicSet->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructureWithOverriddenMagicGet() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__set', $magicSet->getName()); + $this->assertCount(2, $magicSet->getParameters()); + $this->assertSame( + "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" + . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" + . "return parent::__set(\$name, \$value);", + $magicSet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php new file mode 100644 index 0000000000000000000000000000000000000000..43be100a9e8650d46a5dcbe5831348fd5317289e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleepTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $initMethod->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicSleep = new MagicSleep($reflection, $initializer, $initMethod); + + $this->assertSame('__sleep', $magicSleep->getName()); + $this->assertCount(0, $magicSleep->getParameters()); + $this->assertSame( + "\$this->foo && \$this->bar('__sleep', array());" + . "\n\nreturn array_keys((array) \$this);", + $magicSleep->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3c202f644a59fdc0abd081e00b53ba526cd8f0b9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php @@ -0,0 +1,122 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnsetTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initializer; + + /** + * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $initMethod; + + /** + * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject + */ + protected $publicProperties; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); + $this->publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); + $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__unset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}" + . "%areturn %s;", + $magicIsset->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructureWithPublicProperties() + { + $reflection = new ReflectionClass( + 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' + ); + + $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__unset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}" + . "%areturn %s;", + $magicIsset->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructureWithOverriddenMagicGet() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); + $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); + + $this->assertSame('__unset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertSame( + "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" + . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}\n\n" + . "return parent::__unset(\$name);", + $magicIsset->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c5bdb1908767b69c5e5bf238a4b2f25b8c26a3bf --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetProxyInitializerTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $setter = new SetProxyInitializer($initializer); + $parameters = $setter->getParameters(); + + $this->assertSame('setProxyInitializer', $setter->getName()); + $this->assertCount(1, $parameters); + + /* @var $initializer \ProxyManager\Generator\ParameterGenerator */ + $initializer = array_shift($parameters); + + $this->assertInstanceOf('ProxyManager\\Generator\\ParameterGenerator', $initializer); + $this->assertSame('initializer', $initializer->getName()); + $this->assertSame('$this->foo = $initializer;', $setter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..83eacbc03d0322a5ef36cdd1525f3eefc6408638 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\PropertyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker + */ +class InitializationTrackerTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new InitializationTracker(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c7ef25891bff20726ca3133521127f535227d7c1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\PropertyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty + */ +class InitializerPropertyTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new InitializerProperty(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ca1b34938bc51b351d002baf74aa7d73c2035bc5 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php @@ -0,0 +1,48 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator + */ +class LazyLoadingGhostGeneratorTest extends AbstractProxyGeneratorTest +{ + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new LazyLoadingGhostGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array('ProxyManager\\Proxy\\GhostObjectInterface'); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..40596402a9187b5297a766a1ee2eaaae458ebb5b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetProxyInitializerTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $getter = new GetProxyInitializer($initializer); + + $this->assertSame('getProxyInitializer', $getter->getName()); + $this->assertCount(0, $getter->getParameters()); + $this->assertSame('return $this->foo;', $getter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cd39fdb9edf66afb11c472e2760eed1ee7c5f54b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class InitializeProxyTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $initializeProxy = new InitializeProxy($initializer, $valueHolder); + + $this->assertSame('initializeProxy', $initializeProxy->getName()); + $this->assertCount(0, $initializeProxy->getParameters()); + $this->assertSame( + 'return $this->foo && $this->foo->__invoke($this->bar, $this, \'initializeProxy\', array(), $this->foo);', + $initializeProxy->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e6823b685ae9a0ed51dea17a9da07a688ec4b465 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class IsProxyInitializedTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized::__construct + */ + public function testBodyStructure() + { + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $isProxyInitialized = new IsProxyInitialized($valueHolder); + + $this->assertSame('isProxyInitialized', $isProxyInitialized->getName()); + $this->assertCount(0, $isProxyInitialized->getParameters()); + $this->assertSame('return null !== $this->bar;', $isProxyInitialized->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..be2ff40f6559a23586d489885e7699cd98a634c0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php @@ -0,0 +1,82 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingMethodInterceptorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); + $method = LazyLoadingMethodInterceptor::generateMethod($reflection, $initializer, $valueHolder); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertSame( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, 'publicByReferenceParameterMethod', " + . "array('param' => \$param, 'byRefParam' => \$byRefParam), \$this->foo);\n\n" + . "return \$this->bar->publicByReferenceParameterMethod(\$param, \$byRefParam);", + $method->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor + */ + public function testBodyStructureWithoutParameters() + { + $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $method = LazyLoadingMethodInterceptor::generateMethod($reflectionMethod, $initializer, $valueHolder); + + $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); + $this->assertCount(0, $method->getParameters()); + $this->assertSame( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " + . "'testBodyStructureWithoutParameters', array(), \$this->foo);\n\n" + . "return \$this->bar->testBodyStructureWithoutParameters();", + $method->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..44b9cb9e754d852ad548f63dd3aa767d5b57f302 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicCloneTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicClone = new MagicClone($reflection, $initializer, $valueHolder); + + $this->assertSame('__clone', $magicClone->getName()); + $this->assertCount(0, $magicClone->getParameters()); + $this->assertSame( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " + . "'__clone', array(), \$this->foo);\n\n\$this->bar = clone \$this->bar;", + $magicClone->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..442c95e6e1af382455f3bd4889fdadd8edffce10 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicGetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicGet = new MagicGet($reflection, $initializer, $valueHolder, $publicProperties); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__get', array('name' => \$name)" + . ", \$this->foo);\n\n" + . "if (isset(self::\$bar[\$name])) {\n return \$this->bar->\$name;\n}" + . "%areturn %s;", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a3ed157ac502053d83b03e45891e25a78c74dd5c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicIssetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicIsset = new MagicIsset($reflection, $initializer, $valueHolder, $publicProperties); + + $this->assertSame('__isset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__isset', array('name' => \$name)" + . ", \$this->foo);\n\n" + . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->bar->\$name);\n}" + . "%areturn %s;", + $magicIsset->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f8edc38e9d6f61c85f1f8ade4b0592d81e329a06 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicSet = new MagicSet($reflection, $initializer, $valueHolder, $publicProperties); + + $this->assertSame('__set', $magicSet->getName()); + $this->assertCount(2, $magicSet->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " + . "'__set', array('name' => \$name, 'value' => \$value), \$this->foo);\n\n" + . "if (isset(self::\$bar[\$name])) {\n return (\$this->bar->\$name = \$value);\n}" + . "%areturn %s;", + $magicSet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d156041855d6cc9fa6c9dcd7122e8ba2769e7cec --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleepTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicSleep = new MagicSleep($reflection, $initializer, $valueHolder); + + $this->assertSame('__sleep', $magicSleep->getName()); + $this->assertCount(0, $magicSleep->getParameters()); + $this->assertSame( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__sleep', array(), \$this->foo);" + . "\n\nreturn array('bar');", + $magicSleep->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5d8e8433e95cfde91c935812c96b54803ba299cd --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php @@ -0,0 +1,63 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicUnsetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $publicProperties = $this + ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') + ->disableOriginalConstructor() + ->getMock(); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); + $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicIsset = new MagicUnset($reflection, $initializer, $valueHolder, $publicProperties); + + $this->assertSame('__unset', $magicIsset->getName()); + $this->assertCount(1, $magicIsset->getParameters()); + $this->assertStringMatchesFormat( + "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__unset', array('name' => \$name)" + . ", \$this->foo);\n\n" + . "if (isset(self::\$bar[\$name])) {\n unset(\$this->bar->\$name);\n\n return;\n}" + . "%areturn %s;", + $magicIsset->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0bd1735c3b5cd7dd35ec3198a1336dcf4f30edf8 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php @@ -0,0 +1,54 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class SetProxyInitializerTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer::__construct + */ + public function testBodyStructure() + { + $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $setter = new SetProxyInitializer($initializer); + $parameters = $setter->getParameters(); + + $this->assertSame('setProxyInitializer', $setter->getName()); + $this->assertCount(1, $parameters); + + /* @var $initializer \ProxyManager\Generator\ParameterGenerator */ + $initializer = array_shift($parameters); + + $this->assertInstanceOf('ProxyManager\\Generator\\ParameterGenerator', $initializer); + $this->assertSame('initializer', $initializer->getName()); + $this->assertSame('$this->foo = $initializer;', $setter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..48785042e6bfca25fb366dc2b72b485408798172 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty + */ +class InitializerPropertyTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new InitializerProperty(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9033d0e9faac234bf5891c9ef21a0c6048ff0577 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty + */ +class ValueHolderPropertyTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new ValueHolderProperty(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a9a3e6cfd4c1aadc6109c92508aef3d861a7d1a5 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php @@ -0,0 +1,48 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator + */ +class LazyLoadingValueHolderGeneratorTest extends AbstractProxyGeneratorTest +{ + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new LazyLoadingValueHolderGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array('ProxyManager\\Proxy\\VirtualProxyInterface'); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8044a0bd818b10d22a08b99af3630093ddfd4c62 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php @@ -0,0 +1,62 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\NullObject\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConstructorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMixedProperties'); + $constructor = new Constructor($reflection); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(0, $constructor->getParameters()); + $this->assertSame( + "\$this->publicProperty0 = null;\n\$this->publicProperty1 = null;\n\$this->publicProperty2 = null;", + $constructor->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor::__construct + */ + public function testBodyStructureWithoutPublicProperties() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithPrivateProperties'); + $constructor = new Constructor($reflection); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(0, $constructor->getParameters()); + $body = $constructor->getBody(); + $this->assertTrue(empty($body)); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b84b0e87753774e95d1a2894278633feaf79d786 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php @@ -0,0 +1,73 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\NullObject\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor; +use Zend\Code\Reflection\MethodReflection; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectMethodInterceptorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor + */ + public function testBodyStructure() + { + $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); + $method = NullObjectMethodInterceptor::generateMethod($reflection); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertSame("", $method->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor + */ + public function testBodyStructureWithoutParameters() + { + $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); + + $method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); + + $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); + $this->assertCount(0, $method->getParameters()); + $this->assertSame("", $method->getBody()); + } + + /** + * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor + */ + public function testBodyStructureWithoutByRefReturn() + { + $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\BaseClass', 'publicByReferenceMethod'); + + $method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); + + $this->assertSame('publicByReferenceMethod', $method->getName()); + $this->assertCount(0, $method->getParameters()); + $this->assertStringMatchesFormat("\$ref%s = null;\nreturn \$ref%s;", $method->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6eb0d2696bc0e9d4b3fccb59c65398cb3d2cf651 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php @@ -0,0 +1,116 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\ProxyGenerator\NullObjectGenerator; +use ReflectionClass; +use ReflectionProperty; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\NullObjectGenerator} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\NullObjectGenerator + */ +class NullObjectGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTestedImplementations + * + * Verifies that generated code is valid and implements expected interfaces + */ + public function testGeneratesValidCode($className) + { + $generator = $this->getProxyGenerator(); + $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); + $generatedClass = new ClassGenerator($generatedClassName); + $originalClass = new ReflectionClass($className); + $generatorStrategy = new EvaluatingGeneratorStrategy(); + + $generator->generate($originalClass, $generatedClass); + $generatorStrategy->generate($generatedClass); + + $generatedReflection = new ReflectionClass($generatedClassName); + + if ($originalClass->isInterface()) { + $this->assertTrue($generatedReflection->implementsInterface($className)); + } else { + $this->assertEmpty( + array_diff($originalClass->getInterfaceNames(), $generatedReflection->getInterfaceNames()) + ); + } + + $this->assertSame($generatedClassName, $generatedReflection->getName()); + + foreach ($this->getExpectedImplementedInterfaces() as $interface) { + $this->assertTrue($generatedReflection->implementsInterface($interface)); + } + + $proxyGenerated = new $generatedClassName(); + + foreach ($generatedReflection->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { + $this->assertNull($proxyGenerated->$property); + } + + /** @var \ReflectionMethod $method */ + foreach ($generatedReflection->getMethods(ReflectionProperty::IS_PUBLIC) as $method) { + if ($method->getNumberOfParameters() == 0) { + $this->assertNull(call_user_func(array($proxyGenerated, $method->getName()))); + } + } + } + + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new NullObjectGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array( + 'ProxyManager\\Proxy\\NullObjectInterface', + ); + } + + /** + * @return array + */ + public function getTestedImplementations() + { + return array( + array('ProxyManagerTestAsset\\BaseClass'), + array('ProxyManagerTestAsset\\ClassWithMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithMixedProperties'), + array('ProxyManagerTestAsset\\BaseInterface'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4f63271eeb23012eeb98d7e6e819287afd8d7b7b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\PropertyGenerator; + +use PHPUnit_Framework_TestCase; + +/** + * Base test for unique property names + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +abstract class AbstractUniquePropertyNameTest extends PHPUnit_Framework_TestCase +{ + /** + * Verifies that a given property name is unique across two different instantiations of the property + */ + public function testUniqueProperty() + { + $property1 = $this->createProperty(); + $property2 = $this->createProperty(); + + $this->assertSame($property1->getName(), $property1->getName()); + $this->assertNotEquals($property1->getName(), $property2->getName()); + } + + /** + * @return \Zend\Code\Generator\PropertyGenerator + */ + abstract protected function createProperty(); +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0dfd9307ea1b86da5645553948aeeaef70fce393 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php @@ -0,0 +1,71 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults + */ +class PublicPropertiesDefaultsTest extends PHPUnit_Framework_TestCase +{ + public function testEmptyClass() + { + $publicProperties = new PublicPropertiesDefaults(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); + + $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + $this->assertEmpty($publicProperties->getDefaultValue()->getValue()); + $this->assertTrue($publicProperties->isStatic()); + $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); + } + + public function testClassWithPublicProperties() + { + $publicProperties = new PublicPropertiesDefaults( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties') + ); + + $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + $this->assertCount(10, $publicProperties->getDefaultValue()->getValue()); + $this->assertTrue($publicProperties->isStatic()); + $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); + } + + public function testBaseClass() + { + $publicProperties = new PublicPropertiesDefaults( + new ReflectionClass('ProxyManagerTestAsset\\BaseClass') + ); + + $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + $this->assertSame( + array('publicProperty' => 'publicPropertyDefault'), + $publicProperties->getDefaultValue()->getValue() + ); + $this->assertTrue($publicProperties->isStatic()); + $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php new file mode 100644 index 0000000000000000000000000000000000000000..38b3ac037fa5b9886c3678b23dabb6a5812ffba2 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php @@ -0,0 +1,58 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap + */ +class PublicPropertiesMapTest extends PHPUnit_Framework_TestCase +{ + public function testEmptyClass() + { + $publicProperties = new PublicPropertiesMap(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); + + $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + $this->assertEmpty($publicProperties->getDefaultValue()->getValue()); + $this->assertTrue($publicProperties->isStatic()); + $this->assertSame('private', $publicProperties->getVisibility()); + $this->assertTrue($publicProperties->isEmpty()); + } + + public function testClassWithPublicProperties() + { + $publicProperties = new PublicPropertiesMap( + new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties') + ); + + $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); + $this->assertCount(10, $publicProperties->getDefaultValue()->getValue()); + $this->assertTrue($publicProperties->isStatic()); + $this->assertSame('private', $publicProperties->getVisibility()); + $this->assertFalse($publicProperties->isEmpty()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ede0aa7ff1a1d047348b96cd91055ce2b44e0ae1 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ConstructorTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor::__construct + */ + public function testBodyStructure() + { + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); + + $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMixedProperties'); + $constructor = new Constructor($reflection, $adapter); + + $this->assertSame('__construct', $constructor->getName()); + $this->assertCount(1, $constructor->getParameters()); + $this->assertSame( + "\$this->adapter = \$adapter;\nunset(\$this->publicProperty0);" + . "\nunset(\$this->publicProperty1);\nunset(\$this->publicProperty2);", + $constructor->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e7dcac83b44281d044abac29b090abd57b67fa1b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicGetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $magicGet = new MagicGet($reflection, $adapter); + + $this->assertSame('__get', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__get\', array($name));' + . "\n\nreturn \$return;", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0253b8c03fc098aa32e74aa97320177be74c9cce --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicIssetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $magicGet = new MagicIsset($reflection, $adapter); + + $this->assertSame('__isset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__isset\', array($name));' + . "\n\nreturn \$return;", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..14b53c812d5e27bebb0858155782ab8ca4c1d0e9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicSetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $magicGet = new MagicSet($reflection, $adapter); + + $this->assertSame('__set', $magicGet->getName()); + $this->assertCount(2, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__set\', array($name, $value));' + . "\n\nreturn \$return;", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c4ffb21a734ff217497770beb47aae146c5ff9fc --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class MagicUnsetTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $magicGet = new MagicUnset($reflection, $adapter); + + $this->assertSame('__unset', $magicGet->getName()); + $this->assertCount(1, $magicGet->getParameters()); + $this->assertStringMatchesFormat( + '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__unset\', array($name));' + . "\n\nreturn \$return;", + $magicGet->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6e72166c176d02fd9d0402cc93bf5efdf063059b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php @@ -0,0 +1,114 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod; +use Zend\Code\Reflection\MethodReflection; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class RemoteObjectMethodTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod + */ + public function testBodyStructureWithParameters() + { + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); + + $reflectionMethod = new MethodReflection( + 'ProxyManagerTestAsset\\BaseClass', + 'publicByReferenceParameterMethod' + ); + + $method = RemoteObjectMethod::generateMethod( + $reflectionMethod, + $adapter, + new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') + ); + + $this->assertSame('publicByReferenceParameterMethod', $method->getName()); + $this->assertCount(2, $method->getParameters()); + $this->assertSame( + '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' + . '\'publicByReferenceParameterMethod\', array($param, $byRefParam));' + . "\n\nreturn \$return;", + $method->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod + */ + public function testBodyStructureWithArrayParameter() + { + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); + + $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicArrayHintedMethod'); + + $method = RemoteObjectMethod::generateMethod( + $reflectionMethod, + $adapter, + new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') + ); + + $this->assertSame('publicArrayHintedMethod', $method->getName()); + $this->assertCount(1, $method->getParameters()); + $this->assertSame( + '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' + . '\'publicArrayHintedMethod\', array($param));' + . "\n\nreturn \$return;", + $method->getBody() + ); + } + + /** + * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod + */ + public function testBodyStructureWithoutParameters() + { + $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); + + $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); + + $method = RemoteObjectMethod::generateMethod( + $reflectionMethod, + $adapter, + new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') + ); + + $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); + $this->assertCount(0, $method->getParameters()); + $this->assertSame( + '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' + . '\'testBodyStructureWithoutParameters\', array());' + . "\n\nreturn \$return;", + $method->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b19a8ae9273933f5cc494c5003419263085331ff --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\RemoteObject\PropertyGenerator; + +use ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty; +use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty + */ +class AdapterPropertyTest extends AbstractUniquePropertyNameTest +{ + /** + * {@inheritDoc} + */ + protected function createProperty() + { + return new AdapterProperty(); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..958a9dabe1ef34bcecb4a48be48e17d4309c59bf --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php @@ -0,0 +1,102 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\Generator\ClassGenerator; +use ProxyManager\Generator\Util\UniqueIdentifierGenerator; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; +use ProxyManager\ProxyGenerator\RemoteObjectGenerator; +use ReflectionClass; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObjectGenerator} + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\RemoteObjectGenerator + */ +class RemoteObjectGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTestedImplementations + * + * Verifies that generated code is valid and implements expected interfaces + */ + public function testGeneratesValidCode($className) + { + $generator = $this->getProxyGenerator(); + $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); + $generatedClass = new ClassGenerator($generatedClassName); + $originalClass = new ReflectionClass($className); + $generatorStrategy = new EvaluatingGeneratorStrategy(); + + $generator->generate($originalClass, $generatedClass); + $generatorStrategy->generate($generatedClass); + + $generatedReflection = new ReflectionClass($generatedClassName); + + if ($originalClass->isInterface()) { + $this->assertTrue($generatedReflection->implementsInterface($className)); + } else { + $this->assertEmpty( + array_diff($originalClass->getInterfaceNames(), $generatedReflection->getInterfaceNames()) + ); + } + + $this->assertSame($generatedClassName, $generatedReflection->getName()); + + foreach ($this->getExpectedImplementedInterfaces() as $interface) { + $this->assertTrue($generatedReflection->implementsInterface($interface)); + } + } + + /** + * {@inheritDoc} + */ + protected function getProxyGenerator() + { + return new RemoteObjectGenerator(); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedImplementedInterfaces() + { + return array( + 'ProxyManager\\Proxy\\RemoteObjectInterface', + ); + } + + /** + * @return array + */ + public function getTestedImplementations() + { + return array( + array('ProxyManagerTestAsset\\BaseClass'), + array('ProxyManagerTestAsset\\ClassWithMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), + array('ProxyManagerTestAsset\\ClassWithMixedProperties'), + array('ProxyManagerTestAsset\\BaseInterface'), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3f2d91bdd46ad6208190fa5e457b4dc10d797739 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php @@ -0,0 +1,113 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; +use ReflectionClass; +use ReflectionMethod; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter + */ +class ProxiedMethodsFilterTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider expectedMethods + */ + public function testFiltering(ReflectionClass $reflectionClass, $excludes, array $expectedMethods) + { + if (is_array($excludes)) { + $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass, $excludes); + } else { + $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass); + } + + foreach ($filtered as $method) { + $this->assertInstanceOf('ReflectionMethod', $method); + } + + $keys = array_map( + function (ReflectionMethod $method) { + return $method->getName(); + }, + $filtered + ); + + sort($keys); + sort($expectedMethods); + + $this->assertSame($keys, $expectedMethods); + } + + /** + * @return array[][] + */ + public function expectedMethods() + { + return array( + array( + new ReflectionClass('ProxyManagerTestAsset\\BaseClass'), + null, + array( + 'publicArrayHintedMethod', + 'publicByReferenceMethod', + 'publicByReferenceParameterMethod', + 'publicMethod', + 'publicTypeHintedMethod', + ), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'), + null, + array(), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'), + null, + array(), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'), + array(), + array(), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), + array('doFoo'), + array('__get'), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), + array('Dofoo'), + array('__get'), + ), + array( + new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), + array(), + array('doFoo', '__get'), + ), + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2a754056ee417dd2ea5e8ffd2a3ccae15f4b8283 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php @@ -0,0 +1,132 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\Util; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; +use Zend\Code\Generator\PropertyGenerator; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + * + * @covers \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator + */ +class PublicScopeSimulatorTest extends PHPUnit_Framework_TestCase +{ + public function testSimpleGet() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'foo', + null, + null, + 'bar' + ); + + $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%a$bar = %s;', $code); + } + + public function testSimpleSet() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'foo', + 'baz', + null, + 'bar' + ); + + $this->assertStringMatchesFormat('%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;', $code); + } + + public function testSimpleIsset() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_ISSET, + 'foo', + null, + null, + 'bar' + ); + + $this->assertStringMatchesFormat('%a{%areturn isset($%s->$foo);%a}%a$bar = %s;', $code); + } + + public function testSimpleUnset() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_UNSET, + 'foo', + null, + null, + 'bar' + ); + + $this->assertStringMatchesFormat('%a{%aunset($%s->$foo);%a}%a$bar = %s;', $code); + } + + public function testSetRequiresValueParameterName() + { + $this->setExpectedException('InvalidArgumentException'); + + PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'foo', + null, + null, + 'bar' + ); + } + + public function testDelegatesToValueHolderWhenAvailable() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_SET, + 'foo', + 'baz', + new PropertyGenerator('valueHolder'), + 'bar' + ); + + $this->assertStringMatchesFormat( + '%A$targetObject = $this->valueHolder;%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;', + $code + ); + } + + public function testSetRequiresValidOperation() + { + $this->setExpectedException('InvalidArgumentException'); + + PublicScopeSimulator::getPublicAccessSimulationCode('invalid', 'foo'); + } + + public function testWillReturnDirectlyWithNoReturnParam() + { + $code = PublicScopeSimulator::getPublicAccessSimulationCode( + PublicScopeSimulator::OPERATION_GET, + 'foo' + ); + + $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%areturn %s;', $code); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e4a1108cff78a69682e83f7d6fff9e2654d671fa --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\ValueHolder\MethodGenerator; + +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class GetWrappedValueHolderValueTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue::__construct + */ + public function testBodyStructure() + { + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); + + $getter = new GetWrappedValueHolderValue($valueHolder); + + $this->assertSame('getWrappedValueHolderValue', $getter->getName()); + $this->assertCount(0, $getter->getParameters()); + $this->assertSame('return $this->foo;', $getter->getBody()); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d5038c618bd2baef53d3773f39a4e03cff744f0c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php @@ -0,0 +1,52 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTest\ProxyGenerator\ValueHolder\MethodGenerator; + +use ReflectionClass; +use PHPUnit_Framework_TestCase; +use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\MagicSleep; + +/** + * Tests for {@see \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\MagicSleep} + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class MagicSleepTest extends PHPUnit_Framework_TestCase +{ + /** + * @covers \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\MagicSleep::__construct + */ + public function testBodyStructure() + { + $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); + $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); + + $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); + + $magicSleep = new MagicSleep($reflection, $valueHolder); + + $this->assertSame('__sleep', $magicSleep->getName()); + $this->assertCount(0, $magicSleep->getParameters()); + $this->assertSame( + "return array('bar');", + $magicSleep->getBody() + ); + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php new file mode 100644 index 0000000000000000000000000000000000000000..8324d978fa2b9d71bd52bd6f285bc07cdfa2b625 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php @@ -0,0 +1,55 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to catch instantiations of access interceptor value holders + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class AccessInterceptorValueHolderMock +{ + /** + * @var mixed + */ + public $instance; + + /** + * @var mixed + */ + public $prefixInterceptors; + + /** + * @var mixed + */ + public $suffixInterceptors; + + /** + * @param mixed $instance + * @param mixed $prefixInterceptors + * @param mixed $suffixInterceptors + */ + public function __construct($instance, $prefixInterceptors, $suffixInterceptors) + { + $this->instance = $instance; + $this->prefixInterceptors = $prefixInterceptors; + $this->suffixInterceptors = $suffixInterceptors; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php new file mode 100644 index 0000000000000000000000000000000000000000..4d58a116458ecc144a6bf4cf9ed6a345778d5fe0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php @@ -0,0 +1,108 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class with various intercepted properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class BaseClass implements BaseInterface +{ + /** + * @var string + */ + public $publicProperty = 'publicPropertyDefault'; + + /** + * @var string + */ + protected $protectedProperty = 'protectedPropertyDefault'; + + /** + * @var string + */ + private $privateProperty = 'privatePropertyDefault'; + + /** + * @return string + */ + public function publicMethod() + { + return 'publicMethodDefault'; + } + + /** + * @return string + */ + protected function protectedMethod() + { + return 'protectedMethodDefault'; + } + + /** + * @return string + */ + private function privateMethod() + { + return 'privateMethodDefault'; + } + + /** + * @param \stdClass $param + * + * @return string + */ + public function publicTypeHintedMethod(\stdClass $param) + { + return 'publicTypeHintedMethodDefault'; + } + + /** + * @param array $param + * + * @return string + */ + public function publicArrayHintedMethod(array $param) + { + return 'publicArrayHintedMethodDefault'; + } + + /** + * @return string + */ + public function & publicByReferenceMethod() + { + $returnValue = 'publicByReferenceMethodDefault'; + + return $returnValue; + } + + /** + * @param mixed $param + * @param mixed $byRefParam + * + * @return string + */ + public function publicByReferenceParameterMethod($param, & $byRefParam) + { + return 'publicByReferenceParameterMethodDefault'; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..8749a8df7ef31b177f7c00d401f88fc7ef0a1134 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php @@ -0,0 +1,33 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base interface used to verify that the proxy generators can actually work with interfaces + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface BaseInterface +{ + /** + * @return mixed + */ + public function publicMethod(); +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php new file mode 100644 index 0000000000000000000000000000000000000000..4a65595f00e6f8eef2d5a18cc5a02a925b99a66b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php @@ -0,0 +1,39 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Class with a callable type hint in a method - used to test callable type hint + * generation + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class CallableTypeHintClass +{ + /** + * @param callable $parameter + * + * @return callable + */ + public function callableTypeHintMethod(callable $parameter) + { + return $parameter; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php new file mode 100644 index 0000000000000000000000000000000000000000..6f0ab5d2eca51330e53010c53db54da43f19d07e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php @@ -0,0 +1,74 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Test class used to verify that proxy-manager respects magic getters with a byref return value + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithByRefMagicMethods +{ + /** + * {@inheritDoc} + */ + public function & __set($name, $value) + { + return array($name => $value); + } + + /** + * {@inheritDoc} + */ + public function & __get($name) + { + return $name; + } + + /** + * {@inheritDoc} + */ + public function & __isset($name) + { + return (bool) $name; + } + + /** + * {@inheritDoc} + */ + public function & __unset($name) + { + return (bool) $name; + } + + /** + * {@inheritDoc} + */ + public function & __sleep() + { + } + + /** + * {@inheritDoc} + */ + public function & __wakeup() + { + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php new file mode 100644 index 0000000000000000000000000000000000000000..2bd26e50af103c3308f796ce3af9509b40ce88b0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php @@ -0,0 +1,81 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to play around with pre-existing magic methods + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithMagicMethods +{ + /** + * {@inheritDoc} + */ + public function __set($name, $value) + { + return array($name => $value); + } + + /** + * {@inheritDoc} + */ + public function __get($name) + { + return $name; + } + + /** + * {@inheritDoc} + */ + public function __isset($name) + { + return (bool) $name; + } + + /** + * {@inheritDoc} + */ + public function __unset($name) + { + return (bool) $name; + } + + /** + * {@inheritDoc} + */ + public function __sleep() + { + } + + /** + * {@inheritDoc} + */ + public function __wakeup() + { + } + + /** + * {@inheritDoc} + */ + public function __clone() + { + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php new file mode 100644 index 0000000000000000000000000000000000000000..fa6134a3f6cce5cdf0db8694c085f8656ade0afa --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php @@ -0,0 +1,38 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Test asset class with method with default values + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithMethodWithDefaultParameters +{ + /** + * @param array $parameter + * + * @return string + */ + public function publicMethodWithDefaults(array $parameter = array('foo')) + { + return 'defaultValue'; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php new file mode 100644 index 0000000000000000000000000000000000000000..3ebf27cbfcda2327ed0abacaf0e3672bdc9325b0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php @@ -0,0 +1,46 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to play around with mixed visibility properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithMixedProperties +{ + public $publicProperty0 = 'publicProperty0'; + + public $publicProperty1 = 'publicProperty1'; + + public $publicProperty2 = 'publicProperty2'; + + protected $protectedProperty0 = 'protectedProperty0'; + + protected $protectedProperty1 = 'protectedProperty1'; + + protected $protectedProperty2 = 'protectedProperty2'; + + private $privateProperty0 = 'privateProperty0'; + + private $privateProperty1 = 'privateProperty1'; + + private $privateProperty2 = 'privateProperty2'; +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php new file mode 100644 index 0000000000000000000000000000000000000000..96a7a93684f846aa4f587a1944af9fa47cc54165 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php @@ -0,0 +1,48 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to play around with private properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithPrivateProperties +{ + private $property0 = 'property0'; + + private $property1 = 'property1'; + + private $property2 = 'property2'; + + private $property3 = 'property3'; + + private $property4 = 'property4'; + + private $property5 = 'property5'; + + private $property6 = 'property6'; + + private $property7 = 'property7'; + + private $property8 = 'property8'; + + private $property9 = 'property9'; +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php new file mode 100644 index 0000000000000000000000000000000000000000..ad600d18b1d0a72bc801a05c6fd7c1430ecb4137 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php @@ -0,0 +1,48 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to play around with protected properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithProtectedProperties +{ + protected $property0 = 'property0'; + + protected $property1 = 'property1'; + + protected $property2 = 'property2'; + + protected $property3 = 'property3'; + + protected $property4 = 'property4'; + + protected $property5 = 'property5'; + + protected $property6 = 'property6'; + + protected $property7 = 'property7'; + + protected $property8 = 'property8'; + + protected $property9 = 'property9'; +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php new file mode 100644 index 0000000000000000000000000000000000000000..af68ceb3e52fd3cb2b46ac99823082acc706cb18 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php @@ -0,0 +1,31 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to verify that proxies actually modify the array keys of + * public properties that keep an array + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithPublicArrayProperty +{ + public $arrayProperty = array(); +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php new file mode 100644 index 0000000000000000000000000000000000000000..d36ea8cf40f4134da3169b00a68cfbc5acf4c0e0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php @@ -0,0 +1,48 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to play around with public properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithPublicProperties +{ + public $property0 = 'property0'; + + public $property1 = 'property1'; + + public $property2 = 'property2'; + + public $property3 = 'property3'; + + public $property4 = 'property4'; + + public $property5 = 'property5'; + + public $property6 = 'property6'; + + public $property7 = 'property7'; + + public $property8 = 'property8'; + + public $property9 = 'property9'; +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php new file mode 100644 index 0000000000000000000000000000000000000000..e74a0f7fecbd04c2f27ed310d041eec2e93b0422 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test asset + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class EmptyClass +{ +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php new file mode 100644 index 0000000000000000000000000000000000000000..198bf6ca2670568b3d51cba0932c85e14d4e0a3f --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php @@ -0,0 +1,60 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Test object to be hydrated + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class HydratedObject +{ + /** + * @var mixed + */ + public $foo = 1; + + /** + * @var mixed + */ + protected $bar = 2; + + /** + * @var mixed + */ + private $baz = 3; + + /** + * Method to be disabled + */ + public function doFoo() + { + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get($name) + { + return $this->$name; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php new file mode 100644 index 0000000000000000000000000000000000000000..b199f8fa923c7463e5698b2091837ba890fd2869 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php @@ -0,0 +1,41 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to catch instantiations of lazy loading objects + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class LazyLoadingMock +{ + /** + * @var mixed + */ + public $initializer; + + /** + * @param mixed $initializer + */ + public function __construct($initializer) + { + $this->initializer = $initializer; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php new file mode 100644 index 0000000000000000000000000000000000000000..b747f3b39f7fd07808af52632333e5e56849cb39 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php @@ -0,0 +1,29 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset; + +/** + * Base test class to catch instantiations of null object + * + * @author Vincent Blanchon <blanchon.vincent@gmail.com> + * @license MIT + */ +class NullObjectMock +{ +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php new file mode 100644 index 0000000000000000000000000000000000000000..bb34b58badd03acc8c8b5449cb4b5194537ddc14 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php @@ -0,0 +1,38 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset\ProxyGenerator\LazyLoading\MethodGenerator; + +/** + * Test asset with 2 public properties + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class ClassWithTwoPublicProperties +{ + /** + * @var mixed + */ + public $bar; + + /** + * @var mixed + */ + public $baz; +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..08df058ace2d3e7b9b9b5966d03838bb051b9a37 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php @@ -0,0 +1,35 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset\RemoteProxy; + +/** + * Simple interface for a remote API + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface BazServiceInterface +{ + /** + * @param string $param + * + * @return string + */ + public function baz($param); +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php new file mode 100644 index 0000000000000000000000000000000000000000..9304f705ecfb250d1c5a5d4c9172592fe46122b0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php @@ -0,0 +1,56 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset\RemoteProxy; + +/** + * Simple interface for a remote API + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +class Foo implements FooServiceInterface, BazServiceInterface +{ + /** + * @return string + */ + public function foo() + { + return 'bar remote'; + } + + /** + * @param string $param + * + * @return string + */ + public function baz($param) + { + return $param . ' remote'; + } + + /** + * @param string $name + * + * @return string + */ + public function __get($name) + { + return $name . ' remote'; + } +} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4894b213899599ed2a9311ec67dd8770858464e0 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php @@ -0,0 +1,33 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +namespace ProxyManagerTestAsset\RemoteProxy; + +/** + * Simple interface for a remote API + * + * @author Marco Pivetta <ocramius@gmail.com> + * @license MIT + */ +interface FooServiceInterface +{ + /** + * @return mixed + */ + public function foo(); +} diff --git a/vendor/ocramius/proxy-manager/tests/TestConfiguration.php.dist b/vendor/ocramius/proxy-manager/tests/TestConfiguration.php.dist new file mode 100644 index 0000000000000000000000000000000000000000..3d0507eb7550a039eb68d3153b13bae5102c9e1e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/TestConfiguration.php.dist @@ -0,0 +1,19 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +return array(); \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f641e6d7b978154e806e4a13709a55f823b91180 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md @@ -0,0 +1,9 @@ +## Integration tests for PHP language features of proxies + +Since proxies are quire complex code, this directory is dedicated +to integration tests that are supposed to cause fatal errors or +failures in general that are hard to handle in traditional +PHPUnit test cases. + +You may find a guide on how to write `.phpt` tests on the +[PHP QA website](http://qa.php.net/write-test.php). \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..b820fa1b6a0eada9af21fd1ab61ebf56b3f9cd7e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..313312a1ca16a9c9eb887082cc0394c53e892660 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..3f32a2484495fc630d6706498e269077618ce1c9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..b108ac2b7ea62465949a161b8f46e1da4d6a3dba --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..e277887f0ae746e01d2490d7451f9480ef824310 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..8d47a63cae71eb75d18ca47d019ba899ee21ed0b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..21ed252688dd3dfce48741c6f91cfd6b0869a51c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..31acfafa2cf7381d5221cf7dd42408ddebb79607 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..4b7b916acafa8ed4dfef242e1f8c5a0eedb8ac19 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt @@ -0,0 +1,26 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct isset check +--SKIPIF-- +<?php +if (PHP_VERSION_ID < 50400) { + echo 'skip PHP 5.4+ is needed to localize private properties'; +} +?> +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..436b76b92fc5498c5fba8f8517edc64e3fdec4d9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt @@ -0,0 +1,26 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct read +--SKIPIF-- +<?php +if (PHP_VERSION_ID < 50400) { + echo 'skip PHP 5.4+ is needed to localize private properties'; +} +?> +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..c296ef4f26a0826e5a462a116414212550fcbc84 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt @@ -0,0 +1,26 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct unset +--SKIPIF-- +<?php +if (PHP_VERSION_ID < 50400) { + echo 'skip PHP 5.4+ is needed to localize private properties'; +} +?> +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..bd8e115d7eb8346d653ae0ffc5517fb4d779dc63 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt @@ -0,0 +1,26 @@ +--TEST-- +Verifies that generated access interceptors disallow private property direct write +--SKIPIF-- +<?php +if (PHP_VERSION_ID < 50400) { + echo 'skip PHP 5.4+ is needed to localize private properties'; +} +?> +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..f5de69369e42dad39d567da9796f618b83489fa9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..d3519a4290502b70e36ec4a6134b23630e7e94a7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..cb20b6d595ca3a39fb57eb93f1963bcbe151673a --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..b4ab7bdd9db978039b2060ab5856a941e26f8c69 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated access interceptors disallow protected property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt new file mode 100644 index 0000000000000000000000000000000000000000..0a180b2e3a7e977671e29c6841c34cf9731b2a7e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt @@ -0,0 +1,34 @@ +--TEST-- +Verifies that access interceptor proxy file is generated +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$configuration->setProxiesTargetDir(__DIR__ . '/cache'); +$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); +$configuration->setGeneratorStrategy( + new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) +); + +$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); + +$proxy = $factory->createProxy(new Kitchen()); + +$filename = $fileLocator->getProxyFileName(get_class($proxy)); +var_dump(file_exists($filename)); + +$proxy = $factory->createProxy(new Kitchen()); + +var_dump(file_exists($filename)); +@unlink($filename); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md new file mode 100644 index 0000000000000000000000000000000000000000..dcb0d38109fb0e5e40da17f584ea1a3bf42766be --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md @@ -0,0 +1,3 @@ +## Integration tests for PHP language features of proxies + +This folder is used for the caches \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php new file mode 100644 index 0000000000000000000000000000000000000000..cab41588326b717dd3a79c9860fc988fc6935e75 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php @@ -0,0 +1,10 @@ +<?php + +use ProxyManager\Configuration; +use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; + +require_once __DIR__ . '/../Bootstrap.php'; + +$configuration = new Configuration(); + +$configuration->setGeneratorStrategy(new EvaluatingGeneratorStrategy()); diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..2f318c7453935e5671dad8037f8ce3fcc5b4ef5b --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt @@ -0,0 +1,25 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; + + public function & __get($name) + { + return $name; + } +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +echo $proxy->nonExisting; +?> +--EXPECTF-- +nonExisting \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..e815d0f2cbb4e008dfd2e4fd8c6d8aeff8db2738 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt @@ -0,0 +1,21 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->nonExisting = 'I do not exist'; +echo $proxy->nonExisting; +?> +--EXPECTF-- +I do not exist \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..73042abe09278dc4282ee8b5aaca7e059265be01 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->nonExisting; +?> +--EXPECTF-- +Notice: Undefined property: Kitchen::$nonExisting in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..05f741cfcad4144bd993c94f94c20517f0a4ba91 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow private property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..e1fd83bd3ff42efdd500bc07ed315c55cfbfb7fe --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow private property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..62b1bf1e67c5218448a9bd14c3778fd1c3f95533 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow private property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..e0840d73d37cf746f178fd40d26e174723d67e84 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow private property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..8fa848526e0b1dfcf10529c3c4d642935ded6e8e --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow protected property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..14633704e15fce95137807959138461a83cb3430 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow protected property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..a0a6643c6a7992f7239b1c0dd17bc35f3682c3c9 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow protected property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..46f81785d2a1d89a69f75c2698ff41f5a89ade01 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated lazy loading ghost objects disallow protected property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt new file mode 100644 index 0000000000000000000000000000000000000000..7a609482ff0c8f52bd19c98789b7d2b098d3d07f --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt @@ -0,0 +1,34 @@ +--TEST-- +Verifies that lazy loading ghost proxy file is generated +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$configuration->setProxiesTargetDir(__DIR__ . '/cache'); +$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); +$configuration->setGeneratorStrategy( + new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) +); + +$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +$filename = $fileLocator->getProxyFileName(get_class($proxy)); +var_dump(file_exists($filename)); + +$proxy = $factory->createProxy('Kitchen', function () {}); + +var_dump(file_exists($filename)); +@unlink($filename); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..14e79895d6680ff89f27159dd0624d4e58a97fe7 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow private property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..4660624b4e78502591816a9a622b280122dddb40 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow private property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..443785fae237047b945b6790c39a05bd248112a6 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow private property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..ad035ee83e22da16e72244f89484a96e47a8ec53 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow private property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..d33c0ba1975473f06996bc076f81548a3bc61bf2 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow protected property direct isset check +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets = 'candy'; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +var_dump(isset($proxy->sweets)); +?> +--EXPECT-- +bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt new file mode 100644 index 0000000000000000000000000000000000000000..cfd2690dcbd0618af0128128af66cf07af627871 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow protected property direct read +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +$proxy->sweets; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt new file mode 100644 index 0000000000000000000000000000000000000000..1fac6bb56a9401e65fe0e90b9c02391945636474 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow protected property direct unset +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +unset($proxy->sweets); +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt new file mode 100644 index 0000000000000000000000000000000000000000..bb89a31e6825a9236cb573dbe4cfd55dbce66835 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated lazy loading value holders disallow protected property direct write +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + protected $sweets; +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +$proxy->sweets = 'stolen'; +?> +--EXPECTF-- +Fatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt new file mode 100644 index 0000000000000000000000000000000000000000..7aed1d1b217e1af95d29f53c9597383fd1e894c5 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt @@ -0,0 +1,31 @@ +--TEST-- +Verifies that lazy loading value holder factory can generate proxy for PHP core classes. +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class PharMock extends Phar +{ + public function __construct() + { + } + + public function compress($message) + { + echo $message; + } +} + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$factory + ->createProxy('Phar', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new PharMock(); + }) + ->compress('Lazy Loaded!'); + +?> +--EXPECT-- +Lazy Loaded! \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt new file mode 100644 index 0000000000000000000000000000000000000000..06afe47bb8b7e46a739a49ffa5d0740d254d28ee --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt @@ -0,0 +1,40 @@ +--TEST-- +Verifies that lazy loading value holder proxy file is generated +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + private $sweets = 'candy'; +} + +$configuration->setProxiesTargetDir(__DIR__ . '/cache'); +$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); +$configuration->setGeneratorStrategy( + new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) +); + +$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +$filename = $fileLocator->getProxyFileName(get_class($proxy)); +var_dump(file_exists($filename)); + +$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { + $initializer = null; + $wrapped = new Kitchen(); +}); + +var_dump(file_exists($filename)); +@unlink($filename); + +?> +--EXPECT-- +bool(true) +bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt new file mode 100644 index 0000000000000000000000000000000000000000..2453ea568ebe4c31a803bdd08a3e5bb934639a11 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that generated null object disallow public function +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + public function foo() + { + return 'bar'; + } +} + +$factory = new \ProxyManager\Factory\NullObjectFactory($configuration); + +$proxy = $factory->createProxy('Kitchen'); + +var_dump($proxy->foo()); +?> +--EXPECT-- +NULL diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt new file mode 100644 index 0000000000000000000000000000000000000000..9da1a4153281be48217ac9f44416128f8fc3072c --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt @@ -0,0 +1,20 @@ +--TEST-- +Verifies that generated null object disallow public function +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +class Kitchen +{ + public $foo = 'bar'; +} + +$factory = new \ProxyManager\Factory\NullObjectFactory($configuration); + +$proxy = $factory->createProxy('Kitchen'); + +var_dump($proxy->foo); +?> +--EXPECT-- +NULL diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt new file mode 100644 index 0000000000000000000000000000000000000000..fc0cb9f7060815372dd5002fcbf549cd77e4a093 --- /dev/null +++ b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt @@ -0,0 +1,43 @@ +--TEST-- +Verifies that generated remote object can call public property +--FILE-- +<?php + +require_once __DIR__ . '/init.php'; + +use ProxyManager\Factory\RemoteObject\AdapterInterface; +use Zend\Json\Server\Client; + +interface FooServiceInterface +{ + public function foo(); +} + +class Foo implements FooServiceInterface +{ + public $foo = "baz"; + + public function foo() + { + return 'bar'; + } +} + +class CustomAdapter implements AdapterInterface +{ + public function call($wrappedClass, $method, array $params = array()) + { + return 'baz'; + } +} + +$factory = new \ProxyManager\Factory\RemoteObjectFactory(new CustomAdapter(), $configuration); +$proxy = $factory->createProxy('ProxyManagerTestAsset\RemoteProxy\FooServiceInterface'); + +var_dump($proxy->foo()); +var_dump($proxy->unknown()); +?> +--EXPECTF-- +string(3) "baz" + +Fatal error: Call to undefined method %s::unknown() in %s on line %d