Ajout du FR
Ajout du FR + correction du "functions.php"
This commit is contained in:
32
vendor/zendframework/zend-code/src/Annotation/AnnotationCollection.php
vendored
Normal file
32
vendor/zendframework/zend-code/src/Annotation/AnnotationCollection.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation;
|
||||
|
||||
use ArrayObject;
|
||||
|
||||
class AnnotationCollection extends ArrayObject
|
||||
{
|
||||
/**
|
||||
* Checks if the collection has annotations for a class
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnnotation($class)
|
||||
{
|
||||
foreach ($this as $annotation) {
|
||||
if (get_class($annotation) == $class) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
21
vendor/zendframework/zend-code/src/Annotation/AnnotationInterface.php
vendored
Normal file
21
vendor/zendframework/zend-code/src/Annotation/AnnotationInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation;
|
||||
|
||||
interface AnnotationInterface
|
||||
{
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* @param string $content
|
||||
* @return void
|
||||
*/
|
||||
public function initialize($content);
|
||||
}
|
||||
109
vendor/zendframework/zend-code/src/Annotation/AnnotationManager.php
vendored
Normal file
109
vendor/zendframework/zend-code/src/Annotation/AnnotationManager.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation;
|
||||
|
||||
use Zend\Code\Annotation\Parser\ParserInterface;
|
||||
use Zend\EventManager\Event;
|
||||
use Zend\EventManager\EventManager;
|
||||
use Zend\EventManager\EventManagerAwareInterface;
|
||||
use Zend\EventManager\EventManagerInterface;
|
||||
|
||||
/**
|
||||
* Pluggable annotation manager
|
||||
*
|
||||
* Simply composes an EventManager. When createAnnotation() is called, it fires
|
||||
* off an event of the same name, passing it the resolved annotation class, the
|
||||
* annotation content, and the raw annotation string; the first listener to
|
||||
* return an object will halt execution of the event, and that object will be
|
||||
* returned as the annotation.
|
||||
*/
|
||||
class AnnotationManager implements EventManagerAwareInterface
|
||||
{
|
||||
const EVENT_CREATE_ANNOTATION = 'createAnnotation';
|
||||
|
||||
/**
|
||||
* @var EventManagerInterface
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* Set the event manager instance
|
||||
*
|
||||
* @param EventManagerInterface $events
|
||||
* @return AnnotationManager
|
||||
*/
|
||||
public function setEventManager(EventManagerInterface $events)
|
||||
{
|
||||
$events->setIdentifiers(array(
|
||||
__CLASS__,
|
||||
get_class($this),
|
||||
));
|
||||
$this->events = $events;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve event manager
|
||||
*
|
||||
* Lazy loads an instance if none registered.
|
||||
*
|
||||
* @return EventManagerInterface
|
||||
*/
|
||||
public function getEventManager()
|
||||
{
|
||||
if (null === $this->events) {
|
||||
$this->setEventManager(new EventManager());
|
||||
}
|
||||
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a parser to listen to the createAnnotation event
|
||||
*
|
||||
* @param ParserInterface $parser
|
||||
* @return AnnotationManager
|
||||
*/
|
||||
public function attach(ParserInterface $parser)
|
||||
{
|
||||
$this->getEventManager()
|
||||
->attach(self::EVENT_CREATE_ANNOTATION, array($parser, 'onCreateAnnotation'));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Annotation
|
||||
*
|
||||
* @param string[] $annotationData
|
||||
* @return false|\stdClass
|
||||
*/
|
||||
public function createAnnotation(array $annotationData)
|
||||
{
|
||||
$event = new Event();
|
||||
$event->setName(self::EVENT_CREATE_ANNOTATION);
|
||||
$event->setTarget($this);
|
||||
$event->setParams(array(
|
||||
'class' => $annotationData[0],
|
||||
'content' => $annotationData[1],
|
||||
'raw' => $annotationData[2],
|
||||
));
|
||||
|
||||
$eventManager = $this->getEventManager();
|
||||
$results = $eventManager->trigger($event, function ($r) {
|
||||
return (is_object($r));
|
||||
});
|
||||
|
||||
$annotation = $results->last();
|
||||
|
||||
return (is_object($annotation) ? $annotation : false);
|
||||
}
|
||||
}
|
||||
153
vendor/zendframework/zend-code/src/Annotation/Parser/DoctrineAnnotationParser.php
vendored
Normal file
153
vendor/zendframework/zend-code/src/Annotation/Parser/DoctrineAnnotationParser.php
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation\Parser;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\Annotations\DocParser;
|
||||
use Traversable;
|
||||
use Zend\Code\Exception;
|
||||
use Zend\EventManager\EventInterface;
|
||||
|
||||
/**
|
||||
* A parser for docblock annotations that utilizes the annotation parser from
|
||||
* Doctrine\Common.
|
||||
*
|
||||
* Consumes Doctrine\Common\Annotations\DocParser, and responds to events from
|
||||
* AnnotationManager. If the annotation examined is in the list of classes we
|
||||
* are interested in, the raw annotation is passed to the DocParser in order to
|
||||
* retrieve the annotation object instance. Otherwise, it is skipped.
|
||||
*/
|
||||
class DoctrineAnnotationParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* @var array Annotation classes we support on this iteration
|
||||
*/
|
||||
protected $allowedAnnotations = array();
|
||||
|
||||
/**
|
||||
* @var DocParser
|
||||
*/
|
||||
protected $docParser;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Hack to ensure an attempt to autoload an annotation class is made
|
||||
AnnotationRegistry::registerLoader(function ($class) {
|
||||
return (bool) class_exists($class);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DocParser instance
|
||||
*
|
||||
* @param DocParser $docParser
|
||||
* @return DoctrineAnnotationParser
|
||||
*/
|
||||
public function setDocParser(DocParser $docParser)
|
||||
{
|
||||
$this->docParser = $docParser;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the DocParser instance
|
||||
*
|
||||
* If none is registered, lazy-loads a new instance.
|
||||
*
|
||||
* @return DocParser
|
||||
*/
|
||||
public function getDocParser()
|
||||
{
|
||||
if (!$this->docParser instanceof DocParser) {
|
||||
$this->setDocParser(new DocParser());
|
||||
}
|
||||
|
||||
return $this->docParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle annotation creation
|
||||
*
|
||||
* @param EventInterface $e
|
||||
* @return false|\stdClass
|
||||
*/
|
||||
public function onCreateAnnotation(EventInterface $e)
|
||||
{
|
||||
$annotationClass = $e->getParam('class', false);
|
||||
if (!$annotationClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->allowedAnnotations[$annotationClass])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$annotationString = $e->getParam('raw', false);
|
||||
if (!$annotationString) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Annotation classes provided by the AnnotationScanner are already
|
||||
// resolved to fully-qualified class names. Adding the global namespace
|
||||
// prefix allows the Doctrine annotation parser to locate the annotation
|
||||
// class correctly.
|
||||
$annotationString = preg_replace('/^(@)/', '$1\\', $annotationString);
|
||||
|
||||
$parser = $this->getDocParser();
|
||||
$annotations = $parser->parse($annotationString);
|
||||
if (empty($annotations)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$annotation = array_shift($annotations);
|
||||
if (!is_object($annotation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify an allowed annotation class
|
||||
*
|
||||
* @param string $annotation
|
||||
* @return DoctrineAnnotationParser
|
||||
*/
|
||||
public function registerAnnotation($annotation)
|
||||
{
|
||||
$this->allowedAnnotations[$annotation] = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set many allowed annotations at once
|
||||
*
|
||||
* @param array|Traversable $annotations Array or traversable object of
|
||||
* annotation class names
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return DoctrineAnnotationParser
|
||||
*/
|
||||
public function registerAnnotations($annotations)
|
||||
{
|
||||
if (!is_array($annotations) && !$annotations instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s: expects an array or Traversable; received "%s"',
|
||||
__METHOD__,
|
||||
(is_object($annotations) ? get_class($annotations) : gettype($annotations))
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
$this->allowedAnnotations[$annotation] = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
224
vendor/zendframework/zend-code/src/Annotation/Parser/GenericAnnotationParser.php
vendored
Normal file
224
vendor/zendframework/zend-code/src/Annotation/Parser/GenericAnnotationParser.php
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation\Parser;
|
||||
|
||||
use Traversable;
|
||||
use Zend\Code\Annotation\AnnotationInterface;
|
||||
use Zend\Code\Exception;
|
||||
use Zend\EventManager\EventInterface;
|
||||
|
||||
/**
|
||||
* Generic annotation parser
|
||||
*
|
||||
* Expects registration of AnnotationInterface instances. Such instances
|
||||
* will be passed annotation content to their initialize() method, which
|
||||
* they are then responsible for parsing.
|
||||
*/
|
||||
class GenericAnnotationParser implements ParserInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $aliases = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $annotationNames = array();
|
||||
|
||||
/**
|
||||
* @var AnnotationInterface[]
|
||||
*/
|
||||
protected $annotations = array();
|
||||
|
||||
/**
|
||||
* Listen to onCreateAnnotation, and attempt to return an annotation object
|
||||
* instance.
|
||||
*
|
||||
* If the annotation class or alias is not registered, immediately returns
|
||||
* false. Otherwise, resolves the class, clones it, and, if any content is
|
||||
* present, calls {@link AnnotationInterface::initialize()} with the
|
||||
* content.
|
||||
*
|
||||
* @param EventInterface $e
|
||||
* @return false|AnnotationInterface
|
||||
*/
|
||||
public function onCreateAnnotation(EventInterface $e)
|
||||
{
|
||||
$class = $e->getParam('class', false);
|
||||
if (!$class || !$this->hasAnnotation($class)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$content = $e->getParam('content', '');
|
||||
$content = trim($content, '()');
|
||||
|
||||
if ($this->hasAlias($class)) {
|
||||
$class = $this->resolveAlias($class);
|
||||
}
|
||||
|
||||
$index = array_search($class, $this->annotationNames);
|
||||
$annotation = $this->annotations[$index];
|
||||
|
||||
$newAnnotation = clone $annotation;
|
||||
if ($content) {
|
||||
$newAnnotation->initialize($content);
|
||||
}
|
||||
|
||||
return $newAnnotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register annotations
|
||||
*
|
||||
* @param string|AnnotationInterface $annotation String class name of an
|
||||
* AnnotationInterface implementation, or actual instance
|
||||
* @return GenericAnnotationParser
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function registerAnnotation($annotation)
|
||||
{
|
||||
$class = false;
|
||||
if (is_string($annotation) && class_exists($annotation)) {
|
||||
$class = $annotation;
|
||||
$annotation = new $annotation();
|
||||
}
|
||||
|
||||
if (!$annotation instanceof AnnotationInterface) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s: expects an instance of %s\AnnotationInterface; received "%s"',
|
||||
__METHOD__,
|
||||
__NAMESPACE__,
|
||||
(is_object($annotation) ? get_class($annotation) : gettype($annotation))
|
||||
));
|
||||
}
|
||||
|
||||
$class = $class ?: get_class($annotation);
|
||||
|
||||
if (in_array($class, $this->annotationNames)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'An annotation for this class %s already exists',
|
||||
$class
|
||||
));
|
||||
}
|
||||
|
||||
$this->annotations[] = $annotation;
|
||||
$this->annotationNames[] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register many annotations at once
|
||||
*
|
||||
* @param array|Traversable $annotations
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return GenericAnnotationParser
|
||||
*/
|
||||
public function registerAnnotations($annotations)
|
||||
{
|
||||
if (!is_array($annotations) && !$annotations instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s: expects an array or Traversable; received "%s"',
|
||||
__METHOD__,
|
||||
(is_object($annotations) ? get_class($annotations) : gettype($annotations))
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
$this->registerAnnotation($annotation);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the manager has annotations for a class
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnnotation($class)
|
||||
{
|
||||
if (in_array($class, $this->annotationNames)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->hasAlias($class)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias an annotation name
|
||||
*
|
||||
* @param string $alias
|
||||
* @param string $class May be either a registered annotation name or another alias
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return GenericAnnotationParser
|
||||
*/
|
||||
public function setAlias($alias, $class)
|
||||
{
|
||||
if (!in_array($class, $this->annotationNames) && !$this->hasAlias($class)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s: Cannot alias "%s" to "%s", as class "%s" is not currently a registered annotation or alias',
|
||||
__METHOD__,
|
||||
$alias,
|
||||
$class,
|
||||
$class
|
||||
));
|
||||
}
|
||||
|
||||
$alias = $this->normalizeAlias($alias);
|
||||
$this->aliases[$alias] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize an alias name
|
||||
*
|
||||
* @param string $alias
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizeAlias($alias)
|
||||
{
|
||||
return strtolower(str_replace(array('-', '_', ' ', '\\', '/'), '', $alias));
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have an alias by the provided name?
|
||||
*
|
||||
* @param string $alias
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasAlias($alias)
|
||||
{
|
||||
$alias = $this->normalizeAlias($alias);
|
||||
|
||||
return (isset($this->aliases[$alias]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an alias to a class name
|
||||
*
|
||||
* @param string $alias
|
||||
* @return string
|
||||
*/
|
||||
protected function resolveAlias($alias)
|
||||
{
|
||||
do {
|
||||
$normalized = $this->normalizeAlias($alias);
|
||||
$class = $this->aliases[$normalized];
|
||||
} while ($this->hasAlias($class));
|
||||
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
39
vendor/zendframework/zend-code/src/Annotation/Parser/ParserInterface.php
vendored
Normal file
39
vendor/zendframework/zend-code/src/Annotation/Parser/ParserInterface.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Code\Annotation\Parser;
|
||||
|
||||
use Zend\EventManager\EventInterface;
|
||||
|
||||
interface ParserInterface
|
||||
{
|
||||
/**
|
||||
* Respond to the "createAnnotation" event
|
||||
*
|
||||
* @param EventInterface $e
|
||||
* @return false|\stdClass
|
||||
*/
|
||||
public function onCreateAnnotation(EventInterface $e);
|
||||
|
||||
/**
|
||||
* Register an annotation this parser will accept
|
||||
*
|
||||
* @param mixed $annotation
|
||||
* @return void
|
||||
*/
|
||||
public function registerAnnotation($annotation);
|
||||
|
||||
/**
|
||||
* Register multiple annotations this parser will accept
|
||||
*
|
||||
* @param array|\Traversable $annotations
|
||||
* @return void
|
||||
*/
|
||||
public function registerAnnotations($annotations);
|
||||
}
|
||||
Reference in New Issue
Block a user