Reedy has uploaded a new change for review. https://gerrit.wikimedia.org/r/316074
Change subject: Move pimple to composer dependancy ...................................................................... Move pimple to composer dependancy Bug: T1283 Change-Id: I416b6d0390f06ba642103798ec079a2403966fbb Depends-On: If12b169606686f1c8004c2e9ac3be30f4a41c52f --- M Flow.php M autoload.php M composer.json D vendor/Pimple/Container.php D vendor/Pimple/ServiceProviderInterface.php 5 files changed, 7 insertions(+), 330 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/74/316074/1 diff --git a/Flow.php b/Flow.php index 813f92c..6ed46e7 100644 --- a/Flow.php +++ b/Flow.php @@ -417,3 +417,7 @@ // Enable/Disable Opt-in beta feature $wgFlowEnableOptInBetaFeature = false; + +if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { + require_once __DIR__ . '/vendor/autoload.php'; +} diff --git a/autoload.php b/autoload.php index a0d632a..c04890a 100644 --- a/autoload.php +++ b/autoload.php @@ -402,6 +402,4 @@ 'Flow\\WorkflowLoader' => __DIR__ . '/includes/WorkflowLoader.php', 'Flow\\WorkflowLoaderFactory' => __DIR__ . '/includes/WorkflowLoaderFactory.php', 'MaintenanceDebugLogger' => __DIR__ . '/maintenance/MaintenanceDebugLogger.php', - 'Pimple\\Container' => __DIR__ . '/vendor/Pimple/Container.php', - 'Pimple\\ServiceProviderInterface' => __DIR__ . '/vendor/Pimple/ServiceProviderInterface.php', ); diff --git a/composer.json b/composer.json index e38111e..7826aa5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,9 @@ "name": "mediawiki/flow", "description": "Discussion and collaboration system extension for MediaWiki", "license": "GPL-2.0+", - "require": {}, + "require": { + "pimple/pimple": "2.1.1" + }, "require-dev": { "symfony/dom-crawler": "~2.5", "symfony/css-selector": "~2.5", diff --git a/vendor/Pimple/Container.php b/vendor/Pimple/Container.php deleted file mode 100644 index 26edefc..0000000 --- a/vendor/Pimple/Container.php +++ /dev/null @@ -1,281 +0,0 @@ -<?php - -/* - * This file is part of Pimple. - * - * Copyright (c) 2009 Fabien Potencier - * - * 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 Pimple; - -/** - * Container main class. - * - * @author Fabien Potencier - */ -class Container implements \ArrayAccess -{ - private $values = array(); - private $factories; - private $protected; - private $frozen = array(); - private $raw = array(); - private $keys = array(); - - /** - * Instantiate the container. - * - * Objects and parameters can be passed as argument to the constructor. - * - * @param array $values The parameters or objects. - */ - public function __construct(array $values = array()) - { - $this->factories = new \SplObjectStorage(); - $this->protected = new \SplObjectStorage(); - - foreach ($values as $key => $value) { - $this->offsetSet($key, $value); - } - } - - /** - * Sets a parameter or an object. - * - * Objects must be defined as Closures. - * - * Allowing any PHP callable leads to difficult to debug problems - * as function names (strings) are callable (creating a function with - * the same name as an existing parameter would break your container). - * - * @param string $id The unique identifier for the parameter or object - * @param mixed $value The value of the parameter or a closure to define an object - * @throws \RuntimeException Prevent override of a frozen service - */ - public function offsetSet($id, $value) - { - if (isset($this->frozen[$id])) { - throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id)); - } - - $this->values[$id] = $value; - $this->keys[$id] = true; - } - - /** - * Gets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or an object - * - * @throws \InvalidArgumentException if the identifier is not defined - */ - public function offsetGet($id) - { - if (!isset($this->keys[$id])) { - throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - if ( - isset($this->raw[$id]) - || !is_object($this->values[$id]) - || isset($this->protected[$this->values[$id]]) - || !method_exists($this->values[$id], '__invoke') - ) { - return $this->values[$id]; - } - - if (isset($this->factories[$this->values[$id]])) { - return $this->values[$id]($this); - } - - $raw = $this->values[$id]; - $val = $this->values[$id] = $raw($this); - $this->raw[$id] = $raw; - - $this->frozen[$id] = true; - - return $val; - } - - /** - * Checks if a parameter or an object is set. - * - * @param string $id The unique identifier for the parameter or object - * - * @return bool - */ - public function offsetExists($id) - { - return isset($this->keys[$id]); - } - - /** - * Unsets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - */ - public function offsetUnset($id) - { - if (isset($this->keys[$id])) { - if (is_object($this->values[$id])) { - unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]); - } - - unset($this->values[$id], $this->frozen[$id], $this->raw[$id], $this->keys[$id]); - } - } - - /** - * Marks a callable as being a factory service. - * - * @param callable $callable A service definition to be used as a factory - * - * @return callable The passed callable - * - * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object - */ - public function factory($callable) - { - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.'); - } - - $this->factories->attach($callable); - - return $callable; - } - - /** - * Protects a callable from being interpreted as a service. - * - * This is useful when you want to store a callable as a parameter. - * - * @param callable $callable A callable to protect from being evaluated - * - * @return callable The passed callable - * - * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object - */ - public function protect($callable) - { - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new \InvalidArgumentException('Callable is not a Closure or invokable object.'); - } - - $this->protected->attach($callable); - - return $callable; - } - - /** - * Gets a parameter or the closure defining an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or the closure defining an object - * - * @throws \InvalidArgumentException if the identifier is not defined - */ - public function raw($id) - { - if (!isset($this->keys[$id])) { - throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - if (isset($this->raw[$id])) { - return $this->raw[$id]; - } - - return $this->values[$id]; - } - - /** - * Extends an object definition. - * - * Useful when you want to extend an existing object definition, - * without necessarily loading that object. - * - * @param string $id The unique identifier for the object - * @param callable $callable A service definition to extend the original - * - * @return callable The wrapped callable - * - * @throws \InvalidArgumentException if the identifier is not defined or not a service definition - */ - public function extend($id, $callable) - { - if (!isset($this->keys[$id])) { - throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - if (!is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) { - throw new \InvalidArgumentException(sprintf('Identifier "%s" does not contain an object definition.', $id)); - } - - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new \InvalidArgumentException('Extension service definition is not a Closure or invokable object.'); - } - - $factory = $this->values[$id]; - - $extended = function ($c) use ($callable, $factory) { - return $callable($factory($c), $c); - }; - - if (isset($this->factories[$factory])) { - $this->factories->detach($factory); - $this->factories->attach($extended); - } - - return $this[$id] = $extended; - } - - /** - * Returns all defined value names. - * - * @return array An array of value names - */ - public function keys() - { - return array_keys($this->values); - } - - /** - * Registers a service provider. - * - * @param ServiceProviderInterface $provider A ServiceProviderInterface instance - * @param array $values An array of values that customizes the provider - * - * @return static - */ - public function register(ServiceProviderInterface $provider, array $values = array()) - { - $provider->register($this); - - foreach ($values as $key => $value) { - $this[$key] = $value; - } - - return $this; - } -} diff --git a/vendor/Pimple/ServiceProviderInterface.php b/vendor/Pimple/ServiceProviderInterface.php deleted file mode 100644 index 9b122bd..0000000 --- a/vendor/Pimple/ServiceProviderInterface.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -/* - * This file is part of Pimple. - * - * Copyright (c) 2009 Fabien Potencier - * - * 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 Pimple; - -/** - * Pimple service provider interface. - * - * @author Fabien Potencier - * @author Dominik Zogg - */ -interface ServiceProviderInterface -{ - /** - * Registers services on the given container. - * - * This method should only be used to configure services and parameters. - * It should not get services. - * - * @param Container $pimple An Container instance - */ - public function register(Container $pimple); -} -- To view, visit https://gerrit.wikimedia.org/r/316074 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I416b6d0390f06ba642103798ec079a2403966fbb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Reedy <re...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits