diff --git a/vendor/slim/slim/CONTRIBUTING.md b/vendor/slim/slim/CONTRIBUTING.md new file mode 100644 index 0000000000..9bbb6b17ca --- /dev/null +++ b/vendor/slim/slim/CONTRIBUTING.md @@ -0,0 +1,20 @@ +# How to Contribute + +## Pull Requests + +1. Fork the Slim Framework repository +2. Create a new branch for each feature or improvement +3. Send a pull request from each feature branch to the **develop** branch + +It is very important to separate new features or improvements into separate feature branches, and to send a +pull request for each branch. This allows me to review and pull in new features or improvements individually. + +## Style Guide + +All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). + +## Unit Testing + +All pull requests must be accompanied by passing unit tests and complete code coverage. The Slim Framework uses phpunit for testing. + +[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/) diff --git a/vendor/slim/slim/Slim/Helper/Set.php b/vendor/slim/slim/Slim/Helper/Set.php new file mode 100644 index 0000000000..e30a389157 --- /dev/null +++ b/vendor/slim/slim/Slim/Helper/Set.php @@ -0,0 +1,246 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.4.0 + * @package Slim + * + * MIT LICENSE + * + * 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. + */ +namespace Slim\Helper; + +class Set implements \ArrayAccess, \Countable, \IteratorAggregate +{ + /** + * Key-value array of arbitrary data + * @var array + */ + protected $data = array(); + + /** + * Constructor + * @param array $items Pre-populate set with this key-value array + */ + public function __construct($items = array()) + { + $this->replace($items); + } + + /** + * Normalize data key + * + * Used to transform data key into the necessary + * key format for this set. Used in subclasses + * like \Slim\Http\Headers. + * + * @param string $key The data key + * @return mixed The transformed/normalized data key + */ + protected function normalizeKey($key) + { + return $key; + } + + /** + * Set data key to value + * @param string $key The data key + * @param mixed $value The data value + */ + public function set($key, $value) + { + $this->data[$this->normalizeKey($key)] = $value; + } + + /** + * Get data value with key + * @param string $key The data key + * @param mixed $default The value to return if data key does not exist + * @return mixed The data value, or the default value + */ + public function get($key, $default = null) + { + if ($this->has($key)) { + $isInvokable = is_object($this->data[$this->normalizeKey($key)]) && method_exists($this->data[$this->normalizeKey($key)], '__invoke'); + + return $isInvokable ? $this->data[$this->normalizeKey($key)]($this) : $this->data[$this->normalizeKey($key)]; + } + + return $default; + } + + /** + * Add data to set + * @param array $items Key-value array of data to append to this set + */ + public function replace($items) + { + foreach ($items as $key => $value) { + $this->set($key, $value); // Ensure keys are normalized + } + } + + /** + * Fetch set data + * @return array This set's key-value data array + */ + public function all() + { + return $this->data; + } + + /** + * Fetch set data keys + * @return array This set's key-value data array keys + */ + public function keys() + { + return array_keys($this->data); + } + + /** + * Does this set contain a key? + * @param string $key The data key + * @return boolean + */ + public function has($key) + { + return array_key_exists($this->normalizeKey($key), $this->data); + } + + /** + * Remove value with key from this set + * @param string $key The data key + */ + public function remove($key) + { + unset($this->data[$this->normalizeKey($key)]); + } + + /** + * Property Overloading + */ + + public function __get($key) + { + return $this->get($key); + } + + public function __set($key, $value) + { + $this->set($key, $value); + } + + public function __isset($key) + { + return $this->has($key); + } + + public function __unset($key) + { + return $this->remove($key); + } + + /** + * Clear all values + */ + public function clear() + { + $this->data = array(); + } + + /** + * Array Access + */ + + public function offsetExists($offset) + { + return $this->has($offset); + } + + public function offsetGet($offset) + { + return $this->get($offset); + } + + public function offsetSet($offset, $value) + { + $this->set($offset, $value); + } + + public function offsetUnset($offset) + { + $this->remove($offset); + } + + /** + * Countable + */ + + public function count() + { + return count($this->data); + } + + /** + * IteratorAggregate + */ + + public function getIterator() + { + return new \ArrayIterator($this->data); + } + + /** + * Ensure a value or object will remain globally unique + * @param string $key The value or object name + * @param Closure The closure that defines the object + * @return mixed + */ + public function singleton($key, $value) + { + $this->set($key, function ($c) use ($value) { + static $object; + + if (null === $object) { + $object = $value($c); + } + + return $object; + }); + } + + /** + * Protect closure from being directly invoked + * @param Closure $callable A closure to keep from being invoked and evaluated + * @return Closure + */ + public function protect(\Closure $callable) + { + return function () use ($callable) { + return $callable; + }; + } +} diff --git a/vendor/slim/slim/Slim/Http/Cookies.php b/vendor/slim/slim/Slim/Http/Cookies.php new file mode 100644 index 0000000000..0d035b3a4c --- /dev/null +++ b/vendor/slim/slim/Slim/Http/Cookies.php @@ -0,0 +1,91 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.4.0 + * @package Slim + * + * MIT LICENSE + * + * 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. + */ +namespace Slim\Http; + +class Cookies extends \Slim\Helper\Set +{ + /** + * Default cookie settings + * @var array + */ + protected $defaults = array( + 'value' => '', + 'domain' => null, + 'path' => null, + 'expires' => null, + 'secure' => false, + 'httponly' => false + ); + + /** + * Set cookie + * + * The second argument may be a single scalar value, in which case + * it will be merged with the default settings and considered the `value` + * of the merged result. + * + * The second argument may also be an array containing any or all of + * the keys shown in the default settings above. This array will be + * merged with the defaults shown above. + * + * @param string $key Cookie name + * @param mixed $value Cookie settings + */ + public function set($key, $value) + { + if (is_array($value)) { + $cookieSettings = array_replace($this->defaults, $value); + } else { + $cookieSettings = array_replace($this->defaults, array('value' => $value)); + } + parent::set($key, $cookieSettings); + } + + /** + * Remove cookie + * + * Unlike \Slim\Helper\Set, this will actually *set* a cookie with + * an expiration date in the past. This expiration date will force + * the client-side cache to remove its cookie with the given name + * and settings. + * + * @param string $key Cookie name + * @param array $settings Optional cookie settings + */ + public function remove($key, $settings = array()) + { + $settings['value'] = ''; + $settings['expires'] = time() - 86400; + $this->set($key, array_replace($this->defaults, $settings)); + } +} diff --git a/vendor/slim/slim/tests/Helper/SetTest.php b/vendor/slim/slim/tests/Helper/SetTest.php new file mode 100644 index 0000000000..66165aba21 --- /dev/null +++ b/vendor/slim/slim/tests/Helper/SetTest.php @@ -0,0 +1,241 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.4.0 + * + * MIT LICENSE + * + * 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. + */ + +class SetTest extends PHPUnit_Framework_TestCase +{ + protected $bag; + protected $property; + + public function setUp() + { + $this->bag = new \Slim\Helper\Set(); + $this->property = new \ReflectionProperty($this->bag, 'data'); + $this->property->setAccessible(true); + } + + public function testSet() + { + $this->bag->set('foo', 'bar'); + $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); + $bag = $this->property->getValue($this->bag); + $this->assertEquals('bar', $bag['foo']); + } + + public function testGet() + { + $this->property->setValue($this->bag, array('foo' => 'bar')); + $this->assertEquals('bar', $this->bag->get('foo')); + } + + public function testGetNotExists() + { + $this->property->setValue($this->bag, array('foo' => 'bar')); + $this->assertEquals('default', $this->bag->get('abc', 'default')); + } + + public function testAdd() + { + $this->bag->replace(array( + 'abc' => '123', + 'foo' => 'bar' + )); + $this->assertArrayHasKey('abc', $this->property->getValue($this->bag)); + $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); + $bag = $this->property->getValue($this->bag); + $this->assertEquals('123', $bag['abc']); + $this->assertEquals('bar', $bag['foo']); + } + + public function testAll() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertEquals($data, $this->bag->all()); + } + + public function testKeys() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertEquals(array('abc', 'foo'), $this->bag->keys()); + } + + public function testRemove() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->bag->remove('foo'); + $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag)); + } + + public function testClear() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->bag->clear(); + $this->assertEquals(array(), $this->property->getValue($this->bag)); + } + + public function testArrayAccessGet() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertEquals('bar', $this->bag['foo']); + } + + public function testArrayAccessSet() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->bag['foo'] = 'changed'; + $bag = $this->property->getValue($this->bag); + $this->assertEquals('changed', $bag['foo']); + } + + public function testArrayAccessExists() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertTrue(isset($this->bag['foo'])); + $this->assertFalse(isset($this->bag['bar'])); + } + + public function testArrayAccessUnset() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + unset($this->bag['foo']); + $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag)); + } + + public function testCount() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertEquals(2, count($this->bag)); + } + + public function testGetIterator() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + $this->assertInstanceOf('\ArrayIterator', $this->bag->getIterator()); + } + + public function testPropertyOverloadGet() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + + $this->assertEquals('123', $this->bag->abc); + $this->assertEquals('bar', $this->bag->foo); + } + + public function testPropertyOverloadSet() + { + $this->bag->foo = 'bar'; + $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); + $this->assertEquals('bar', $this->bag->foo); + } + + public function testPropertyOverloadingIsset() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + + $this->assertTrue(isset($this->bag->abc)); + $this->assertTrue(isset($this->bag->foo)); + $this->assertFalse(isset($this->bag->foobar)); + } + + public function testPropertyOverloadingUnset() + { + $data = array( + 'abc' => '123', + 'foo' => 'bar' + ); + $this->property->setValue($this->bag, $data); + + $this->assertTrue(isset($this->bag->abc)); + unset($this->bag->abc); + $this->assertFalse(isset($this->bag->abc)); + $this->assertArrayNotHasKey('abc', $this->property->getValue($this->bag)); + $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); + } + + public function testProtect() + { + $callable = function () { + return 'foo'; + }; + $result = $this->bag->protect($callable); + + $this->assertInstanceOf('\Closure', $result); + $this->assertSame($callable, $result()); + } +} diff --git a/vendor/slim/slim/tests/Http/CookiesTest.php b/vendor/slim/slim/tests/Http/CookiesTest.php new file mode 100644 index 0000000000..e73d44f385 --- /dev/null +++ b/vendor/slim/slim/tests/Http/CookiesTest.php @@ -0,0 +1,92 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.4.0 + * + * MIT LICENSE + * + * 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. + */ +class CookiesTest extends PHPUnit_Framework_TestCase +{ + public function testSetWithStringValue() + { + $c = new \Slim\Http\Cookies(); + $c->set('foo', 'bar'); + $this->assertAttributeEquals( + array( + 'foo' => array( + 'value' => 'bar', + 'expires' => null, + 'domain' => null, + 'path' => null, + 'secure' => false, + 'httponly' => false + ) + ), + 'data', + $c + ); + } + + public function testSetWithArrayValue() + { + $now = time(); + $c = new \Slim\Http\Cookies(); + $c->set('foo', array( + 'value' => 'bar', + 'expires' => $now + 86400, + 'domain' => '.example.com', + 'path' => '/', + 'secure' => true, + 'httponly' => true + )); + $this->assertAttributeEquals( + array( + 'foo' => array( + 'value' => 'bar', + 'expires' => $now + 86400, + 'domain' => '.example.com', + 'path' => '/', + 'secure' => true, + 'httponly' => true + ) + ), + 'data', + $c + ); + } + + public function testRemove() + { + $c = new \Slim\Http\Cookies(); + $c->remove('foo'); + $prop = new \ReflectionProperty($c, 'data'); + $prop->setAccessible(true); + $cValue = $prop->getValue($c); + $this->assertEquals('', $cValue['foo']['value']); + $this->assertLessThan(time(), $cValue['foo']['expires']); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php new file mode 100644 index 0000000000..0d91202029 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputAwareInterface; + +/** + * An implementation of InputAwareInterface for Helpers. + * + * @author Wouter J + */ +abstract class InputAwareHelper extends Helper implements InputAwareInterface +{ + protected $input; + + /** + * {@inheritDoc} + */ + public function setInput(InputInterface $input) + { + $this->input = $input; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php new file mode 100644 index 0000000000..d0f11e986a --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * InputAwareInterface should be implemented by classes that depends on the + * Console Input. + * + * @author Wouter J + */ +interface InputAwareInterface +{ + /** + * Sets the Console Input. + * + * @param InputInterface + */ + public function setInput(InputInterface $input); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php new file mode 100644 index 0000000000..5682fc2404 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +/** + * @author Jean-François Simon + */ +class BufferedOutput extends Output +{ + /** + * @var string + */ + private $buffer = ''; + + /** + * Empties buffer and returns its content. + * + * @return string + */ + public function fetch() + { + $content = $this->buffer; + $this->buffer = ''; + + return $content; + } + + /** + * {@inheritdoc} + */ + protected function doWrite($message, $newline) + { + $this->buffer .= $message; + + if ($newline) { + $this->buffer .= "\n"; + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php new file mode 100644 index 0000000000..52b619e821 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php @@ -0,0 +1,11 @@ +setName('bar:buc'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php new file mode 100644 index 0000000000..a1c60827a5 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php @@ -0,0 +1,10 @@ +setName('foobar:foo') + ->setDescription('The foobar:foo command') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + } +}