diff --git a/composer.json b/composer.json index b7e9683..6074602 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "license": "GPL-2.0+", "require": { "sdboyer/gliph": "0.1.*", + "sdboyer/frozone": "1.0.*", "symfony/class-loader": "2.4.*", "symfony/dependency-injection": "2.4.*", "symfony/event-dispatcher": "2.4.*", diff --git a/composer.lock b/composer.lock index 226faba..a655de0 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "0733d59446085cb815b72923c37e0fd6", + "hash": "efdf1be8e0fa28407216024ff3ae06e7", "packages": [ { "name": "doctrine/annotations", @@ -1121,6 +1121,54 @@ "time": "2012-12-21 11:40:51" }, { + "name": "sdboyer/frozone", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sdboyer/frozone.git", + "reference": "76cfb53007017d2c7b0218404fe39188a0380533" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sdboyer/frozone/zipball/76cfb53007017d2c7b0218404fe39188a0380533", + "reference": "76cfb53007017d2c7b0218404fe39188a0380533", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "satooshi/php-coveralls": "0.6.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "Frozone": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sam Boyer", + "email": "tech@samboyer.org" + } + ], + "description": "Freeze and lock objects. Also makes you 23% more like Samuel L. Jackson.", + "homepage": "http://github.com/sdboyer/frozone", + "keywords": [ + "frozone", + "library", + "php", + "state", + "theincredibles" + ], + "time": "2014-02-06 17:59:52" + }, + { "name": "sdboyer/gliph", "version": "0.1.4", "source": { diff --git a/core/lib/Drupal/Component/ObjectState/FreezableInterface.php b/core/lib/Drupal/Component/ObjectState/FreezableInterface.php deleted file mode 100644 index 60d11f9..0000000 --- a/core/lib/Drupal/Component/ObjectState/FreezableInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -_tfrozen = TRUE; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function isFrozen() { - return $this->_tfrozen; - } - - /** - * Checks if the asset collection is frozen, throws an exception if it is. - * - * @param string $method - * The name of the method that was originally called. - * - * @throws FrozenObjectException - */ - protected function attemptWrite($method) { - if ($this->isFrozen()) { - throw new FrozenObjectException(sprintf('State-changing method %s::%s called on a frozen object instance.', __CLASS__, $method)); - } - } -} \ No newline at end of file diff --git a/core/lib/Drupal/Component/ObjectState/FrozenObjectException.php b/core/lib/Drupal/Component/ObjectState/FrozenObjectException.php deleted file mode 100644 index 85f0154..0000000 --- a/core/lib/Drupal/Component/ObjectState/FrozenObjectException.php +++ /dev/null @@ -1,14 +0,0 @@ -isLocked()) { - throw new LockedObjectException('The collector instance is locked. A new collection cannot be attached to a locked collector.'); - } + $this->attemptWrite(); $this->collection = $collection; } @@ -161,9 +161,7 @@ public function setCollection(AssetCollectionInterface $collection) { * {@inheritdoc} */ public function clearCollection() { - if ($this->isLocked()) { - throw new LockedObjectException('The collector instance is locked. Collections cannot be cleared on a locked collector.'); - } + $this->attemptWrite(); $this->collection = NULL; } @@ -177,48 +175,8 @@ public function hasCollection() { /** * {@inheritdoc} */ - public function lock($key) { - if ($this->isLocked()) { - throw new LockedObjectException('Collector is already locked.', E_WARNING); - } - - $this->locked = TRUE; - $this->lockKey = $key; - return TRUE; - } - - /** - * {@inheritdoc} - */ - public function unlock($key) { - if (!$this->isLocked()) { - throw new LockedObjectException('Collector is not locked', E_WARNING); - } - - if ($this->lockKey !== $key) { - throw new LockedObjectException('Attempted to unlock Collector with incorrect key.', E_WARNING); - } - - $this->locked = FALSE; - $this->lockKey = NULL; - return TRUE; - } - - /** - * {@inheritdoc} - */ - public function isLocked() { - return $this->locked; - } - - /** - * {@inheritdoc} - */ public function setMetadataFactory(MetadataFactoryInterface $factory) { - if ($this->isLocked()) { - throw new LockedObjectException('The collector instance is locked. Asset defaults cannot be modified on a locked collector.'); - } - + $this->attemptWrite(); $this->metadataFactory = $factory; } @@ -241,10 +199,7 @@ public function getMetadataDefaults($asset_type, $source_type, $data) { * {@inheritdoc} */ public function restoreDefaults() { - if ($this->isLocked()) { - throw new LockedObjectException('The collector instance is locked. Asset defaults cannot be modified on a locked collector.'); - } - + $this->attemptWrite(); $this->metadataFactory = new DefaultAssetMetadataFactory(); } diff --git a/core/lib/Drupal/Core/Asset/Factory/AssetCollectorInterface.php b/core/lib/Drupal/Core/Asset/Factory/AssetCollectorInterface.php index 5664f51..14d8bdd 100644 --- a/core/lib/Drupal/Core/Asset/Factory/AssetCollectorInterface.php +++ b/core/lib/Drupal/Core/Asset/Factory/AssetCollectorInterface.php @@ -12,6 +12,7 @@ use Drupal\Core\Asset\AssetInterface; use Drupal\Core\Asset\Collection\AssetCollectionInterface; use Drupal\Core\Asset\Metadata\MetadataFactoryInterface; +use Frozone\Lockable; /** * Interface for asset collectors, which help to create and collect assets. @@ -24,7 +25,7 @@ * injected into code whose only responsibility should be to append new items * to the collection. */ -interface AssetCollectorInterface { +interface AssetCollectorInterface extends Lockable { /** * Adds an asset to the contained collection. @@ -134,48 +135,6 @@ public function clearCollection(); public function hasCollection(); /** - * Locks this collector, using the provided key. - * - * The collector can only be unlocked by providing the same key. Key - * comparison is done using the identity operator (===), so avoid using an - * object as a key if there is any chance the collector will be serialized. - * - * @param mixed $key - * The key used to lock the collector. - * - * @return AssetCollectorInterface - * The current asset collector. - * - * @throws LockedObjectException - * Thrown if the collector is already locked. - */ - public function lock($key); - - /** - * Attempts to unlock the collector with the provided key. - * - * Key comparison is done using the identity operator (===). - * - * @param mixed $key - * The key with which to unlock the collector. - * - * @return AssetCollectorInterface - * The current asset collector. - * - * @throws LockedObjectException - * Thrown if the incorrect key is provided, or if the collector is not - * locked. - */ - public function unlock($key); - - /** - * Indicates whether this collector is currently locked. - * - * @return bool - */ - public function isLocked(); - - /** * Sets the metadata factory to use for generating asset metadata. * * @param MetadataFactoryInterface $factory @@ -225,5 +184,4 @@ public function getMetadataDefaults($asset_type, $source_type, $data); * Thrown if the incorrect key is provided. */ public function restoreDefaults(); - } diff --git a/core/tests/Drupal/Tests/Core/Asset/Collection/AssetCollectionTest.php b/core/tests/Drupal/Tests/Core/Asset/Collection/AssetCollectionTest.php index 5a33bf4..53cc346 100644 --- a/core/tests/Drupal/Tests/Core/Asset/Collection/AssetCollectionTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/Collection/AssetCollectionTest.php @@ -8,7 +8,7 @@ use Drupal\Core\Asset\Collection\AssetCollection; use Drupal\Core\Asset\Collection\BasicCollectionInterface; -use Drupal\Component\ObjectState\FrozenObjectException; +use Frozone\FrozenObjectException; use Drupal\Tests\Core\Asset\AssetUnitTest; /** diff --git a/core/tests/Drupal/Tests/Core/Asset/Collection/AssetLibraryTest.php b/core/tests/Drupal/Tests/Core/Asset/Collection/AssetLibraryTest.php index a39010a..c5b314a 100644 --- a/core/tests/Drupal/Tests/Core/Asset/Collection/AssetLibraryTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/Collection/AssetLibraryTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\Core\Asset\Collection; use Drupal\Core\Asset\Collection\AssetLibrary; -use Drupal\Component\ObjectState\FrozenObjectException; +use Frozone\FrozenObjectException; use Drupal\Tests\Core\Asset\AssetUnitTest; /** diff --git a/core/tests/Drupal/Tests/Core/Asset/Factory/AssetCollectorTest.php b/core/tests/Drupal/Tests/Core/Asset/Factory/AssetCollectorTest.php index 8c01166..d019113 100644 --- a/core/tests/Drupal/Tests/Core/Asset/Factory/AssetCollectorTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/Factory/AssetCollectorTest.php @@ -129,42 +129,8 @@ public function testClearCollection() { $this->assertFalse($this->collector->hasCollection()); } - public function testLock() { - $this->assertTrue($this->collector->lock($this), 'Collector locked successfully.'); - $this->assertTrue($this->collector->isLocked(), 'Collector accurately reports that it is locked via isLocked() method.'); - } - - public function testUnlock() { - $this->collector->lock($this); - $this->assertTrue($this->collector->unlock($this), 'Collector unlocked successfully when appropriate key was provided.'); - $this->assertFalse($this->collector->isLocked(), 'Collector correctly reported unlocked state via isLocked() method after unlocking.'); - } - - /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException - */ - public function testUnlockFailsWithoutCorrectSecret() { - $this->collector->lock('foo'); - $this->collector->unlock('bar'); - } - - /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException - */ - public function testUnlockFailsIfNotLocked() { - $this->collector->unlock('foo'); - } - - /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException - */ - public function testLockFailsIfLocked() { - $this->collector->lock('foo'); - $this->collector->lock('error'); - } - /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException + * @expectedException \Frozone\LockedObjectException */ public function testLockingPreventsSettingDefaults() { $this->collector->lock($this); @@ -172,7 +138,7 @@ public function testLockingPreventsSettingDefaults() { } /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException + * @expectedException \Frozone\LockedObjectException */ public function testLockingPreventsRestoringDefaults() { $this->collector->lock($this); @@ -180,7 +146,7 @@ public function testLockingPreventsRestoringDefaults() { } /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException + * @expectedException \Frozone\LockedObjectException */ public function testLockingPreventsClearingCollection() { $this->collector->lock($this); @@ -188,7 +154,7 @@ public function testLockingPreventsClearingCollection() { } /** - * @expectedException \Drupal\Core\Asset\Exception\LockedObjectException + * @expectedException \Frozone\LockedObjectException */ public function testLockingPreventsSettingCollection() { $this->collector->lock($this); diff --git a/core/vendor/autoload.php b/core/vendor/autoload.php index 5052aab..e6332a8 100644 --- a/core/vendor/autoload.php +++ b/core/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit92462a247bf83504e990c5f706f228cc::getLoader(); +return ComposerAutoloaderInitf83cf541ef042aaab36968955cf4d38c::getLoader(); diff --git a/core/vendor/composer/ClassLoader.php b/core/vendor/composer/ClassLoader.php index f438e31..47ae2ee 100644 --- a/core/vendor/composer/ClassLoader.php +++ b/core/vendor/composer/ClassLoader.php @@ -266,7 +266,7 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - include $file; + includeFile($file); return true; } @@ -352,3 +352,13 @@ public function findFile($class) return $this->classMap[$class] = false; } } + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/core/vendor/composer/autoload_namespaces.php b/core/vendor/composer/autoload_namespaces.php index 83fb6ed..6eb4634 100644 --- a/core/vendor/composer/autoload_namespaces.php +++ b/core/vendor/composer/autoload_namespaces.php @@ -30,6 +30,7 @@ 'Guzzle\\Http' => array($vendorDir . '/guzzle/http'), 'Guzzle\\Common' => array($vendorDir . '/guzzle/common'), 'Gliph' => array($vendorDir . '/sdboyer/gliph/src'), + 'Frozone' => array($vendorDir . '/sdboyer/frozone/src'), 'EasyRdf_' => array($vendorDir . '/easyrdf/easyrdf/lib'), 'Drupal\\Driver' => array($baseDir . '/drivers/lib'), 'Drupal\\Core' => array($baseDir . '/core/lib'), diff --git a/core/vendor/composer/autoload_real.php b/core/vendor/composer/autoload_real.php index fea362d..eb2024c 100644 --- a/core/vendor/composer/autoload_real.php +++ b/core/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit92462a247bf83504e990c5f706f228cc +class ComposerAutoloaderInitf83cf541ef042aaab36968955cf4d38c { private static $loader; @@ -19,9 +19,9 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit92462a247bf83504e990c5f706f228cc', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf83cf541ef042aaab36968955cf4d38c', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit92462a247bf83504e990c5f706f228cc', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf83cf541ef042aaab36968955cf4d38c', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); @@ -49,9 +49,14 @@ public static function getLoader() $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - require $file; + composerRequiref83cf541ef042aaab36968955cf4d38c($file); } return $loader; } } + +function composerRequiref83cf541ef042aaab36968955cf4d38c($file) +{ + require $file; +} diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 81d0e48..94be027 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -2197,5 +2197,55 @@ "rdfa", "sparql" ] + }, + { + "name": "sdboyer/frozone", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/sdboyer/frozone.git", + "reference": "76cfb53007017d2c7b0218404fe39188a0380533" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sdboyer/frozone/zipball/76cfb53007017d2c7b0218404fe39188a0380533", + "reference": "76cfb53007017d2c7b0218404fe39188a0380533", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "satooshi/php-coveralls": "0.6.*" + }, + "time": "2014-02-06 17:59:52", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Frozone": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sam Boyer", + "email": "tech@samboyer.org" + } + ], + "description": "Freeze and lock objects. Also makes you 23% more like Samuel L. Jackson.", + "homepage": "http://github.com/sdboyer/frozone", + "keywords": [ + "frozone", + "library", + "php", + "state", + "theincredibles" + ] } ] diff --git a/core/vendor/sdboyer/frozone/LICENSE b/core/vendor/sdboyer/frozone/LICENSE new file mode 100644 index 0000000..0fd36c7 --- /dev/null +++ b/core/vendor/sdboyer/frozone/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) Sam Boyer + +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. diff --git a/core/vendor/sdboyer/frozone/README.md b/core/vendor/sdboyer/frozone/README.md new file mode 100644 index 0000000..52d4243 --- /dev/null +++ b/core/vendor/sdboyer/frozone/README.md @@ -0,0 +1,114 @@ +# Frozone + +![Frozone stops writes like a boss](frozone.jpg) +[![Build Status](https://travis-ci.org/sdboyer/frozone.png?branch=master)](https://travis-ci.org/sdboyer/frozone) +[![Coverage Status](https://coveralls.io/repos/sdboyer/frozone/badge.png)](https://coveralls.io/r/sdboyer/frozone) +[![Latest Stable Version](https://poser.pugx.org/sdboyer/frozone/v/stable.png)](https://packagist.org/packages/sdboyer/frozone) + +Managing state sucks. Frozone is a simple set of interfaces and traits (so, PHP >=5.4) that implement some patterns to make it easier. It facilitates two cases: + +* **Freezing**, in which an object with mutable state is irrevocably locked such that that state cannot be further mutated (from the outside). +* **Locking** in which an object with mutable state is locked with a key, and that state cannot be mutated until the same key is provided to unlock. + +## Freezing + +Freezing is a one-way operation, initiated by calling the ```freeze()``` method. + +```php + +use Frozone\Freezable; +use Frozone\FreezableTrait; + +class Counter implements Freezable { + use FreezableTrait; + + protected $callcount = 0; + + public function incrementAndEcho() { + $this->attemptWrite(); + // or $this->attemptWriteWithMethod(__METHOD__); + // or $this->attemptWriteWithMessage('What the exception will say if it's frozen'); + + // now, your method's state-changing logic. + echo ++$this->callcount; + } + + public function justEcho() { + echo $this->callcount; + } +} + +$counter = new Counter(); +$counter->isFrozen(); // return FALSE +$counter->incrementAndEcho(); // prints '1' + +$counter->freeze(); +$counter->isFrozen(); // return TRUE + +$counter->justEcho(); // prints '1' +$counter->incrementAndEcho(); // throws FrozenObjectException + +``` + +## Locking + +Locking is a reversible operation, initiated by calling the ```lock()``` method with a key, and reversed by calling ```unlock()``` with the same key. + +It is useful if you need to send a mutable object around to other code, but want to restrict mutations for as long as the object is in that context. + +```php + +use Frozone\Lockable; +use Frozone\LockableTrait; + +class Counter implements Lockable { + use FreezableTrait; + + protected $callcount = 0; + + public function incrementAndEcho() { + $this->attemptWrite(); + // or $this->attemptWriteWithMethod(__METHOD__); + // or $this->attemptWriteWithMessage('What the exception will say if it's frozen'); + + // now, your method's state-changing logic. + echo ++$this->callcount; + } + + public function justEcho() { + echo $this->callcount; + } +} + +$counter = new Counter(); +$counter->isLocked(); // return FALSE +$counter->incrementAndEcho(); // prints '1' + +$key = mt_rand(1, 10000); // Use a key appropriate for your use case +$counter->lock($key); +$counter->isLocked(); // return TRUE + +$counter->justEcho(); // prints '1' +$counter->incrementAndEcho(); // throws LockedObjectException +$counter->unlock('foo'); // throws LockedObjectException; wrong key +$counter->lock('foo'); // throws LockedObjectException; already locked + +$counter->unlock($key); +$counter->isLocked(); // return FALSE +$counter->incrementAndEcho(); // prints '2' + +``` + +## FAQ + +**Reflection can change PHP object state, regardless of visibility. Doesn't that make this pointless?** + +On a purely functional level, it absolutely does. + +On an API design level, even if it's possible for calling code to override the protections provided by Frozone, if your object shouldn't be mutated in a specific context/after a certain point, it's still preferable to provide clear feedback to client code that that's the contract you're providing. + +**Is object state really worth managing in PHP?** + +In a lot of older PHP applications, no. Being that in the vast majority of PHP applications' execution environments, state is built from scratch on each request, object state tends to have a lot less meaning. But, as more and more modern PHP applications emerge, certain types of state are being effectively encapsulated in objects. In those cases, it's worth managing. + + diff --git a/core/vendor/sdboyer/frozone/composer.json b/core/vendor/sdboyer/frozone/composer.json new file mode 100644 index 0000000..a7443fb --- /dev/null +++ b/core/vendor/sdboyer/frozone/composer.json @@ -0,0 +1,24 @@ +{ + "name": "sdboyer/frozone", + "description": "Freeze and lock objects. Also makes you 23% more like Samuel L. Jackson.", + "license": "MIT", + "keywords": ["frozone", "state", "php", "library", "theincredibles"], + "homepage": "http://github.com/sdboyer/frozone", + "type": "library", + "authors": [ + { + "name": "Sam Boyer", + "email": "tech@samboyer.org" + } + ], + "require": { + "php": ">=5.4" + }, + "require-dev": { + "satooshi/php-coveralls": "0.6.*", + "phpunit/phpunit": "3.7.*" + }, + "autoload": { + "psr-0": { "Frozone": "src/" } + } +} diff --git a/core/vendor/sdboyer/frozone/composer.lock b/core/vendor/sdboyer/frozone/composer.lock new file mode 100644 index 0000000..0138cd9 --- /dev/null +++ b/core/vendor/sdboyer/frozone/composer.lock @@ -0,0 +1,886 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "c492e7b3012f809d0beba8e80c5bc9da", + "packages": [ + + ], + "packages-dev": [ + { + "name": "guzzle/guzzle", + "version": "v3.8.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4de0618a01b34aa1c8c33a3f13f396dcd3882eba", + "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": ">=2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "*", + "monolog/monolog": "1.*", + "phpunit/phpunit": "3.7.*", + "psr/log": "1.0.*", + "symfony/class-loader": "*", + "zendframework/zend-cache": "<2.3", + "zendframework/zend-log": "<2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.8-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2014-01-28 22:29:15" + }, + { + "name": "phpunit/php-code-coverage", + "version": "1.2.15", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "6ba4ed2895d538a039d5d5866edc4ec0424c7852" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ba4ed2895d538a039d5d5866edc4ec0424c7852", + "reference": "6ba4ed2895d538a039d5d5866edc4ec0424c7852", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": ">=1.3.0@stable", + "phpunit/php-text-template": ">=1.2.0@stable", + "phpunit/php-token-stream": ">=1.1.3@stable" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-02-03 07:44:47" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2013-09-13 04:58:23" + }, + { + "name": "phpunit/phpunit", + "version": "3.7.30", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2f33258fa5a0c330515b7deba2bc040fa5c3953b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f33258fa5a0c330515b7deba2bc040fa5c3953b", + "reference": "2f33258fa5a0c330515b7deba2bc040fa5c3953b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~1.2.1", + "phpunit/php-file-iterator": ">=1.3.1", + "phpunit/php-text-template": ">=1.1.1", + "phpunit/php-timer": ">=1.0.4", + "phpunit/phpunit-mock-objects": "~1.2.0", + "symfony/yaml": "~2.0" + }, + "require-dev": { + "pear-pear/pear": "1.9.4" + }, + "suggest": { + "ext-json": "*", + "ext-simplexml": "*", + "ext-tokenizer": "*", + "phpunit/php-invoker": ">=1.1.0,<1.2.0" + }, + "bin": [ + "composer/bin/phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-01-31 08:54:33" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-text-template": ">=1.1.1@stable" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2013-01-13 10:24:48" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, + { + "name": "symfony/config", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", + "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com", + "time": "2014-01-01 08:14:50" + }, + { + "name": "symfony/console", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", + "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com", + "time": "2014-01-01 08:14:50" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.4.1", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~2.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2013-12-28 08:12:03" + }, + { + "name": "symfony/filesystem", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", + "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2013-12-31 13:43:26" + }, + { + "name": "symfony/stopwatch", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Stopwatch", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c8e21e1380c7eef6197a8165620da8457b7c69a5", + "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "http://symfony.com", + "time": "2013-12-12 16:06:47" + }, + { + "name": "symfony/yaml", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0", + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2013-12-28 08:12:03" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.4" + }, + "platform-dev": [ + + ] +} diff --git a/core/vendor/sdboyer/frozone/src/Frozone/Freezable.php b/core/vendor/sdboyer/frozone/src/Frozone/Freezable.php new file mode 100644 index 0000000..f1b3e92 --- /dev/null +++ b/core/vendor/sdboyer/frozone/src/Frozone/Freezable.php @@ -0,0 +1,26 @@ +attemptWrite*() methods. + */ +trait FreezableTrait /* implements Freezable */ { + + /** + * State flag indicating whether or not this object is frozen. + * + * Named oddly to help avoid naming collisions. + * + * @var bool + */ + protected $_tfrozen = FALSE; + + public function freeze() { + $this->_tfrozen = TRUE; + } + + public function isFrozen() { + return $this->_tfrozen; + } + + /** + * Checks if the object is frozen and throws an exception if it is. + * + * @throws FrozenObjectException + */ + protected function attemptWrite() { + if ($this->isFrozen()) { + throw new FrozenObjectException(sprintf('State-changing method called on frozen instance of %s.', __CLASS__)); + } + } + + /** + * Checks if the object is frozen and throws an exception if it is. + * + * @param string $method + * The name of the method that was originally called. Your code should + * pass __METHOD__ to this. + * + * @throws FrozenObjectException + */ + protected function attemptWriteWithMethod($method) { + if ($this->isFrozen()) { + throw new FrozenObjectException(sprintf('State-changing method %s::%s called on a frozen object instance.', __CLASS__, $method)); + } + } + + /** + * Checks if the object is frozen and throws an exception if it is. + * + * @param string $msg + * The message to use in the exception, if one is thrown. + * + * @throws FrozenObjectException + */ + protected function attemptWriteWithMessage($msg) { + if ($this->isFrozen()) { + throw new FrozenObjectException($msg); + } + } +} diff --git a/core/vendor/sdboyer/frozone/src/Frozone/FrozenObjectException.php b/core/vendor/sdboyer/frozone/src/Frozone/FrozenObjectException.php new file mode 100644 index 0000000..8f34fdb --- /dev/null +++ b/core/vendor/sdboyer/frozone/src/Frozone/FrozenObjectException.php @@ -0,0 +1,9 @@ +attemptWrite*() methods. + */ +trait LockableTrait /* implements Lockable */ { + + /** + * Flag indicating whether or not the object is locked. + * + * Named weirdly to ensure no naming conflicts. + * + * @var bool + */ + protected $_tlocked = FALSE; + + /** + * The data key with which the lock was set. + * + * An identical value (===) must be provided to unlock the object. + * + * There are no type restrictions. + * + * Named weirdly to ensure no naming conflicts. + * + * @var mixed + */ + protected $_tlockKey; + + public function lock($key) { + $this->attemptWrite(__METHOD__); + + $this->_tlocked = TRUE; + $this->_tlockKey = $key; + return TRUE; + } + + public function unlock($key) { + if (!$this->isLocked()) { + throw new LockedObjectException('Object is not locked', E_WARNING); + } + + if ($this->_tlockKey !== $key) { + throw new LockedObjectException('Attempted to unlock object with incorrect key.', E_WARNING); + } + + $this->_tlocked = FALSE; + $this->_tlockKey = NULL; + return TRUE; + } + + public function isLocked() { + return $this->_tlocked; + } + + /** + * Checks if the object is locked and throws an exception if it is. + * + * @throws LockedObjectException + */ + protected function attemptWrite() { + if ($this->isLocked()) { + throw new LockedObjectException(sprintf('State-changing method called on locked instance of %s.', __CLASS__)); + } + } + + /** + * Checks if the object is locked and throws an exception if it is. + * + * @param string $method + * The name of the method that was originally called. Your code should + * pass __METHOD__ to this. + * + * @throws LockedObjectException + */ + protected function attemptWriteWithMethod($method) { + if ($this->isLocked()) { + throw new LockedObjectException(sprintf('State-changing method %s::%s called on a locked object instance.', __CLASS__, $method)); + } + } + + /** + * Checks if the object is locked and throws an exception if it is. + * + * @param string $msg + * The message to use in the exception, if one is thrown. + * + * @throws LockedObjectException + */ + protected function attemptWriteWithMessage($msg) { + if ($this->isLocked()) { + throw new LockedObjectException($msg); + } + } +} diff --git a/core/vendor/sdboyer/frozone/src/Frozone/LockedObjectException.php b/core/vendor/sdboyer/frozone/src/Frozone/LockedObjectException.php new file mode 100644 index 0000000..e713f47 --- /dev/null +++ b/core/vendor/sdboyer/frozone/src/Frozone/LockedObjectException.php @@ -0,0 +1,10 @@ +