c48eee86c3
* 3.4: (22 commits) [appveyor] use PHP 7.1 to run composer [HttpKernel] Don't clean legacy containers that are still loaded [VarDumper] Fix HtmlDumper classes match Make the simple auth provider the same as in Symfony 2.7. [PhpUnitBridge] silence wget fix merge [Security] guardAuthenticationProvider::authenticate cannot return null according to interface specification [PhpUnitBridge] Fix #26994 [VarDumper] Remove decoration from actual output in tests [PropertyInfo] Minor cleanup and perf improvement [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [DI] Add check of internal type to ContainerBuilder::getReflectionClass [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` Add type hints fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage [HttpFoundation] Add functional tests for Response::sendHeaders() ...
105 lines
3.1 KiB
PHP
105 lines
3.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\PropertyInfo;
|
|
|
|
/**
|
|
* Default {@see PropertyInfoExtractorInterface} implementation.
|
|
*
|
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
*
|
|
* @final
|
|
*/
|
|
class PropertyInfoExtractor implements PropertyInfoExtractorInterface
|
|
{
|
|
private $listExtractors;
|
|
private $typeExtractors;
|
|
private $descriptionExtractors;
|
|
private $accessExtractors;
|
|
|
|
/**
|
|
* @param iterable|PropertyListExtractorInterface[] $listExtractors
|
|
* @param iterable|PropertyTypeExtractorInterface[] $typeExtractors
|
|
* @param iterable|PropertyDescriptionExtractorInterface[] $descriptionExtractors
|
|
* @param iterable|PropertyAccessExtractorInterface[] $accessExtractors
|
|
*/
|
|
public function __construct(iterable $listExtractors = array(), iterable $typeExtractors = array(), iterable $descriptionExtractors = array(), iterable $accessExtractors = array())
|
|
{
|
|
$this->listExtractors = $listExtractors;
|
|
$this->typeExtractors = $typeExtractors;
|
|
$this->descriptionExtractors = $descriptionExtractors;
|
|
$this->accessExtractors = $accessExtractors;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getProperties($class, array $context = array())
|
|
{
|
|
return $this->extract($this->listExtractors, 'getProperties', array($class, $context));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getShortDescription($class, $property, array $context = array())
|
|
{
|
|
return $this->extract($this->descriptionExtractors, 'getShortDescription', array($class, $property, $context));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getLongDescription($class, $property, array $context = array())
|
|
{
|
|
return $this->extract($this->descriptionExtractors, 'getLongDescription', array($class, $property, $context));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getTypes($class, $property, array $context = array())
|
|
{
|
|
return $this->extract($this->typeExtractors, 'getTypes', array($class, $property, $context));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function isReadable($class, $property, array $context = array())
|
|
{
|
|
return $this->extract($this->accessExtractors, 'isReadable', array($class, $property, $context));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function isWritable($class, $property, array $context = array())
|
|
{
|
|
return $this->extract($this->accessExtractors, 'isWritable', array($class, $property, $context));
|
|
}
|
|
|
|
/**
|
|
* Iterates over registered extractors and return the first value found.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
private function extract(iterable $extractors, string $method, array $arguments)
|
|
{
|
|
foreach ($extractors as $extractor) {
|
|
$value = \call_user_func_array(array($extractor, $method), $arguments);
|
|
if (null !== $value) {
|
|
return $value;
|
|
}
|
|
}
|
|
}
|
|
}
|