Merge branch '4.4'
* 4.4: Import return annotations from vendors [ErrorHandler] Handle return types in DebugClassLoader cs fix
This commit is contained in:
commit
f08cf09785
@ -39,6 +39,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
|
||||
{
|
||||
@ -59,6 +61,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return object[][]
|
||||
*/
|
||||
public function getListeners($event = null)
|
||||
{
|
||||
@ -81,6 +85,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasListeners($event)
|
||||
{
|
||||
@ -89,6 +95,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addEventListener($events, $listener)
|
||||
{
|
||||
@ -109,6 +117,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeEventListener($events, $listener)
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ class DbalLogger implements SQLLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startQuery($sql, array $params = null, array $types = null)
|
||||
{
|
||||
@ -48,6 +50,8 @@ class DbalLogger implements SQLLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function stopQuery()
|
||||
{
|
||||
|
@ -29,6 +29,8 @@ abstract class ManagerRegistry extends AbstractManagerRegistry
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function getService($name)
|
||||
{
|
||||
@ -37,6 +39,8 @@ abstract class ManagerRegistry extends AbstractManagerRegistry
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function resetService($name)
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ class StringWrapperType extends StringType
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
@ -27,6 +27,8 @@ class DoctrineFooType extends Type
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@ -35,6 +37,8 @@ class DoctrineFooType extends Type
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
@ -76,6 +80,8 @@ class DoctrineFooType extends Type
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresSQLCommentHint(AbstractPlatform $platform)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Handler;
|
||||
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Handler\AbstractHandler;
|
||||
use Monolog\Logger;
|
||||
use Symfony\Bridge\Monolog\Formatter\VarDumperFormatter;
|
||||
@ -77,6 +78,8 @@ class ServerLogHandler extends AbstractHandler
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*/
|
||||
protected function getDefaultFormatter()
|
||||
{
|
||||
|
@ -63,6 +63,8 @@ class SwiftMailerHandler extends BaseSwiftMailerHandler
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
|
@ -29,6 +29,8 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
|
||||
{
|
||||
|
@ -31,6 +31,8 @@ class AssetExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -40,6 +40,8 @@ class CodeExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\Template;
|
||||
use Twig\TokenParser\TokenParserInterface;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
@ -35,6 +36,9 @@ class DumpExtension extends AbstractExtension
|
||||
$this->dumper = $dumper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
@ -42,6 +46,9 @@ class DumpExtension extends AbstractExtension
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TokenParserInterface[]
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return [new DumpTokenParser()];
|
||||
|
@ -24,6 +24,8 @@ class ExpressionExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TokenParser\TokenParserInterface;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
use Twig\TwigTest;
|
||||
@ -29,6 +30,8 @@ class FormExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TokenParserInterface[]
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
@ -40,6 +43,8 @@ class FormExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
@ -60,6 +65,8 @@ class FormExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
@ -71,6 +78,8 @@ class FormExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigTest[]
|
||||
*/
|
||||
public function getTests()
|
||||
{
|
||||
|
@ -32,6 +32,8 @@ class HttpFoundationExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -22,6 +22,9 @@ use Twig\TwigFunction;
|
||||
*/
|
||||
class HttpKernelExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
|
@ -31,6 +31,8 @@ class LogoutUrlExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ class RoutingExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -50,6 +50,8 @@ class SecurityExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Extension;
|
||||
use Symfony\Bridge\Twig\TokenParser\StopwatchTokenParser;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TokenParser\TokenParserInterface;
|
||||
|
||||
/**
|
||||
* Twig extension for the stopwatch helper.
|
||||
@ -36,6 +37,9 @@ class StopwatchExtension extends AbstractExtension
|
||||
return $this->stopwatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TokenParserInterface[]
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return [
|
||||
|
@ -57,6 +57,8 @@ class TranslationExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters(): array
|
||||
{
|
||||
@ -83,6 +85,8 @@ class TranslationExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return NodeVisitorInterface[]
|
||||
*/
|
||||
public function getNodeVisitors(): array
|
||||
{
|
||||
|
@ -33,6 +33,8 @@ class WebLinkExtension extends AbstractExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -31,6 +31,9 @@ class WorkflowExtension extends AbstractExtension
|
||||
$this->workflowRegistry = $workflowRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
|
@ -25,6 +25,8 @@ class YamlExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
|
@ -39,6 +39,8 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node
|
||||
*/
|
||||
protected function doEnterNode(Node $node, Environment $env)
|
||||
{
|
||||
@ -91,6 +93,8 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node|null
|
||||
*/
|
||||
protected function doLeaveNode(Node $node, Environment $env)
|
||||
{
|
||||
|
@ -49,6 +49,8 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node
|
||||
*/
|
||||
protected function doEnterNode(Node $node, Environment $env)
|
||||
{
|
||||
@ -89,6 +91,8 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node|null
|
||||
*/
|
||||
protected function doLeaveNode(Node $node, Environment $env)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Twig\TokenParser;
|
||||
|
||||
use Symfony\Bridge\Twig\Node\DumpNode;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
|
||||
@ -30,6 +31,8 @@ class DumpTokenParser extends AbstractTokenParser
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node
|
||||
*/
|
||||
public function parse(Token $token)
|
||||
{
|
||||
@ -44,6 +47,8 @@ class DumpTokenParser extends AbstractTokenParser
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\TokenParser;
|
||||
|
||||
use Symfony\Bridge\Twig\Node\StopwatchNode;
|
||||
use Twig\Node\Expression\AssignNameExpression;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
|
||||
@ -30,6 +31,9 @@ class StopwatchTokenParser extends AbstractTokenParser
|
||||
$this->stopwatchIsAvailable = $stopwatchIsAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node
|
||||
*/
|
||||
public function parse(Token $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
@ -56,6 +60,9 @@ class StopwatchTokenParser extends AbstractTokenParser
|
||||
return $token->test('endstopwatch');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return 'stopwatch';
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Twig\TokenParser;
|
||||
|
||||
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
|
||||
@ -24,6 +25,8 @@ class TransDefaultDomainTokenParser extends AbstractTokenParser
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node
|
||||
*/
|
||||
public function parse(Token $token)
|
||||
{
|
||||
@ -36,6 +39,8 @@ class TransDefaultDomainTokenParser extends AbstractTokenParser
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Bridge\Twig\Node\TransNode;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\Expression\AbstractExpression;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\TextNode;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
@ -28,6 +29,8 @@ class TransTokenParser extends AbstractTokenParser
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return Node
|
||||
*/
|
||||
public function parse(Token $token)
|
||||
{
|
||||
@ -86,6 +89,8 @@ class TransTokenParser extends AbstractTokenParser
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
|
@ -364,12 +364,12 @@ abstract class AbstractController implements ServiceSubscriberInterface
|
||||
}
|
||||
|
||||
if (null === $token = $this->container->get('security.token_storage')->getToken()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!\is_object($user = $token->getUser())) {
|
||||
// e.g. anonymous authentication
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
@ -62,6 +62,8 @@ class WebProfilerExtension extends ProfilerExtension
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
|
@ -510,7 +510,7 @@ abstract class AbstractBrowser
|
||||
protected function createCrawlerFromContent(string $uri, string $content, string $type)
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$crawler = new Crawler(null, $uri);
|
||||
|
@ -136,6 +136,8 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -151,6 +151,8 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@ -213,6 +215,8 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Overloaded in order to deal with tags for adjusted doDelete() signature.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
|
@ -37,6 +37,8 @@ interface AdapterInterface extends CacheItemPoolInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '');
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -120,6 +122,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -133,6 +137,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -145,6 +151,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -176,6 +184,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -184,6 +194,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@ -192,6 +204,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
|
@ -178,6 +178,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -192,6 +194,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -211,6 +215,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -226,6 +232,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -241,6 +249,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -256,6 +266,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -271,6 +283,8 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -67,6 +67,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -75,6 +77,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -83,6 +87,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -91,6 +97,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -99,6 +107,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -107,6 +117,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -115,6 +127,8 @@ class NullAdapter implements AdapterInterface, CacheInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -169,6 +169,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -184,6 +186,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -199,6 +203,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -229,6 +235,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -241,6 +249,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -253,6 +263,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@ -261,6 +273,8 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
|
@ -139,6 +139,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -147,6 +149,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -159,6 +163,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -167,6 +173,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -181,6 +189,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -189,6 +199,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -197,6 +209,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -151,6 +151,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -213,6 +215,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -235,6 +239,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -243,6 +249,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -257,6 +265,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -270,6 +280,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -283,6 +295,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -89,6 +89,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -102,6 +104,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -115,6 +119,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -128,6 +134,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
@ -167,6 +175,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -184,6 +194,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -198,6 +210,8 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
|
@ -60,6 +60,8 @@ final class CacheItem implements ItemInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function set($value)
|
||||
{
|
||||
@ -70,6 +72,8 @@ final class CacheItem implements ItemInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function expiresAt($expiration)
|
||||
{
|
||||
@ -86,6 +90,8 @@ final class CacheItem implements ItemInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function expiresAfter($time)
|
||||
{
|
||||
|
@ -58,6 +58,8 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
@ -66,6 +68,8 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
@ -80,6 +84,8 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
@ -88,6 +94,8 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
@ -96,6 +104,8 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
|
@ -85,6 +85,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
@ -108,6 +110,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
@ -122,6 +126,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
@ -130,6 +136,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return iterable
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
{
|
||||
@ -178,6 +186,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
@ -229,6 +239,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
@ -249,6 +261,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
||||
@ -28,6 +29,9 @@ class ProxyAdapterTest extends AdapterTestCase
|
||||
'testPrune' => 'ProxyAdapter just proxies',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return CacheItemPoolInterface
|
||||
*/
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null)
|
||||
{
|
||||
if ('testGetMetadata' === $testMethod) {
|
||||
|
@ -13,6 +13,9 @@ class ArrayCache extends CacheProvider
|
||||
return $this->doContains($id) ? $this->data[$id][0] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
if (!isset($this->data[$id])) {
|
||||
@ -24,6 +27,9 @@ class ArrayCache extends CacheProvider
|
||||
return !$expiry || microtime(true) < $expiry || !$this->doDelete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$this->data[$id] = [$data, $lifeTime ? microtime(true) + $lifeTime : false];
|
||||
@ -31,6 +37,9 @@ class ArrayCache extends CacheProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
unset($this->data[$id]);
|
||||
@ -38,6 +47,9 @@ class ArrayCache extends CacheProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->data = [];
|
||||
@ -45,6 +57,9 @@ class ArrayCache extends CacheProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
|
@ -29,46 +29,73 @@ class ExternalAdapter implements CacheItemPoolInterface
|
||||
$this->cache = new ArrayAdapter($defaultLifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CacheItemInterface
|
||||
*/
|
||||
public function getItem($key)
|
||||
{
|
||||
return $this->cache->getItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable
|
||||
*/
|
||||
public function getItems(array $keys = [])
|
||||
{
|
||||
return $this->cache->getItems($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
return $this->cache->hasItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
return $this->cache->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
return $this->cache->deleteItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
return $this->cache->deleteItems($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
return $this->cache->save($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
return $this->cache->saveDeferred($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
return $this->cache->commit();
|
||||
|
@ -93,6 +93,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
{
|
||||
@ -113,6 +115,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear(string $prefix = '')
|
||||
{
|
||||
@ -141,6 +145,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
{
|
||||
@ -149,6 +155,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
{
|
||||
@ -236,6 +244,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
{
|
||||
@ -249,6 +259,8 @@ trait AbstractAdapterTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
{
|
||||
|
@ -61,6 +61,8 @@ class ConsoleLogger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
|
@ -27,9 +27,47 @@ use PHPUnit\Framework\MockObject\Matcher\StatelessInvocation;
|
||||
*/
|
||||
class DebugClassLoader
|
||||
{
|
||||
private const SPECIAL_RETURN_TYPES = [
|
||||
'mixed' => 'mixed',
|
||||
'void' => 'void',
|
||||
'null' => 'null',
|
||||
'resource' => 'resource',
|
||||
'static' => 'object',
|
||||
'$this' => 'object',
|
||||
'boolean' => 'bool',
|
||||
'true' => 'bool',
|
||||
'false' => 'bool',
|
||||
'integer' => 'int',
|
||||
'array' => 'array',
|
||||
'bool' => 'bool',
|
||||
'callable' => 'callable',
|
||||
'float' => 'float',
|
||||
'int' => 'integer',
|
||||
'iterable' => 'iterable',
|
||||
'object' => 'object',
|
||||
'string' => 'string',
|
||||
'self' => 'self',
|
||||
'parent' => 'parent',
|
||||
];
|
||||
|
||||
private const BUILTIN_RETURN_TYPES = [
|
||||
'void' => true,
|
||||
'array' => true,
|
||||
'bool' => true,
|
||||
'callable' => true,
|
||||
'float' => true,
|
||||
'int' => true,
|
||||
'iterable' => true,
|
||||
'object' => true,
|
||||
'string' => true,
|
||||
'self' => true,
|
||||
'parent' => true,
|
||||
];
|
||||
|
||||
private $classLoader;
|
||||
private $isFinder;
|
||||
private $loaded = [];
|
||||
private $compatPatch;
|
||||
private static $caseCheck;
|
||||
private static $checkedClasses = [];
|
||||
private static $final = [];
|
||||
@ -40,11 +78,14 @@ class DebugClassLoader
|
||||
private static $annotatedParameters = [];
|
||||
private static $darwinCache = ['/' => ['/', []]];
|
||||
private static $method = [];
|
||||
private static $returnTypes = [];
|
||||
private static $methodTraits = [];
|
||||
|
||||
public function __construct(callable $classLoader)
|
||||
{
|
||||
$this->classLoader = $classLoader;
|
||||
$this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
|
||||
$this->compatPatch = getenv('SYMFONY_PATCH_TYPE_DECLARATIONS_COMPAT') ?: null;
|
||||
|
||||
if (!isset(self::$caseCheck)) {
|
||||
$file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
|
||||
@ -218,11 +259,11 @@ class DebugClassLoader
|
||||
$deprecations = [];
|
||||
|
||||
// Don't trigger deprecations for classes in the same vendor
|
||||
if (2 > $len = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) {
|
||||
$len = 0;
|
||||
$ns = '';
|
||||
if (2 > $vendorLen = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) {
|
||||
$vendorLen = 0;
|
||||
$vendor = '';
|
||||
} else {
|
||||
$ns = str_replace('_', '\\', substr($class, 0, $len));
|
||||
$vendor = str_replace('_', '\\', substr($class, 0, $vendorLen));
|
||||
}
|
||||
|
||||
// Detect annotations on the class
|
||||
@ -252,7 +293,7 @@ class DebugClassLoader
|
||||
}
|
||||
}
|
||||
|
||||
$parent = get_parent_class($class);
|
||||
$parent = get_parent_class($class) ?: null;
|
||||
$parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent);
|
||||
if ($parent) {
|
||||
$parentAndOwnInterfaces[$parent] = $parent;
|
||||
@ -271,13 +312,13 @@ class DebugClassLoader
|
||||
if (!isset(self::$checkedClasses[$use])) {
|
||||
$this->checkClass($use);
|
||||
}
|
||||
if (isset(self::$deprecated[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) {
|
||||
if (isset(self::$deprecated[$use]) && strncmp($vendor, str_replace('_', '\\', $use), $vendorLen) && !isset(self::$deprecated[$class])) {
|
||||
$type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait');
|
||||
$verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');
|
||||
|
||||
$deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]);
|
||||
}
|
||||
if (isset(self::$internal[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len)) {
|
||||
if (isset(self::$internal[$use]) && strncmp($vendor, str_replace('_', '\\', $use), $vendorLen)) {
|
||||
$deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class);
|
||||
}
|
||||
if (isset(self::$method[$use])) {
|
||||
@ -305,15 +346,24 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
if (trait_exists($class)) {
|
||||
$file = $refl->getFileName();
|
||||
|
||||
foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) {
|
||||
if ($method->getFileName() === $file) {
|
||||
self::$methodTraits[$file][$method->getStartLine()] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
return $deprecations;
|
||||
}
|
||||
|
||||
// Inherit @final, @internal and @param annotations for methods
|
||||
// Inherit @final, @internal, @param and @return annotations for methods
|
||||
self::$finalMethods[$class] = [];
|
||||
self::$internalMethods[$class] = [];
|
||||
self::$annotatedParameters[$class] = [];
|
||||
self::$returnTypes[$class] = [];
|
||||
foreach ($parentAndOwnInterfaces as $use) {
|
||||
foreach (['finalMethods', 'internalMethods', 'annotatedParameters'] as $property) {
|
||||
foreach (['finalMethods', 'internalMethods', 'annotatedParameters', 'returnTypes'] as $property) {
|
||||
if (isset(self::${$property}[$use])) {
|
||||
self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use];
|
||||
}
|
||||
@ -325,6 +375,16 @@ class DebugClassLoader
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === $ns = self::$methodTraits[$method->getFileName()][$method->getStartLine()] ?? null) {
|
||||
$ns = $vendor;
|
||||
$len = $vendorLen;
|
||||
} elseif (2 > $len = 1 + (strpos($ns, '\\') ?: strpos($ns, '_'))) {
|
||||
$len = 0;
|
||||
$ns = '';
|
||||
} else {
|
||||
$ns = str_replace('_', '\\', substr($ns, 0, $len));
|
||||
}
|
||||
|
||||
if ($parent && isset(self::$finalMethods[$parent][$method->name])) {
|
||||
list($declaringClass, $message) = self::$finalMethods[$parent][$method->name];
|
||||
$deprecations[] = sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
|
||||
@ -353,10 +413,34 @@ class DebugClassLoader
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(self::$returnTypes[$class][$method->name]) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +(\S+)/', $doc))) {
|
||||
list($normalizedType, $returnType, $declaringClass, $declaringFile) = self::$returnTypes[$class][$method->name];
|
||||
|
||||
if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) {
|
||||
self::fixReturnStatements($method, $normalizedType);
|
||||
}
|
||||
|
||||
if (strncmp($ns, $declaringClass, $len)) {
|
||||
if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) {
|
||||
self::patchMethod($method, $returnType, $declaringFile);
|
||||
}
|
||||
|
||||
$deprecations[] = sprintf('Method "%s::%s()" will return "%s" as of its next major version. Doing the same in child class "%s" will be required when upgrading.', $declaringClass, $method->name, $normalizedType, $class);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$doc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$method->hasReturnType() && false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +(\S+)/', $doc, $matches)) {
|
||||
$this->setReturnType($matches[1], $method, $parent);
|
||||
|
||||
if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) {
|
||||
self::fixReturnStatements($method, self::$returnTypes[$class][$method->name][0] ?? '?');
|
||||
}
|
||||
}
|
||||
|
||||
$finalOrInternal = false;
|
||||
|
||||
foreach (['final', 'internal'] as $annotation) {
|
||||
@ -382,7 +466,7 @@ class DebugClassLoader
|
||||
foreach ($matches as list(, $parameterType, $parameterName)) {
|
||||
if (!isset($definedParameters[$parameterName])) {
|
||||
$parameterType = trim($parameterType);
|
||||
self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its parent class "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, $method->class);
|
||||
self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its parent class "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -496,11 +580,9 @@ class DebugClassLoader
|
||||
/**
|
||||
* `class_implements` includes interfaces from the parents so we have to manually exclude them.
|
||||
*
|
||||
* @param string|false $parent
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function getOwnInterfaces(string $class, $parent): array
|
||||
private function getOwnInterfaces(string $class, ?string $parent): array
|
||||
{
|
||||
$ownInterfaces = class_implements($class, false);
|
||||
|
||||
@ -518,4 +600,234 @@ class DebugClassLoader
|
||||
|
||||
return $ownInterfaces;
|
||||
}
|
||||
|
||||
private function setReturnType(string $types, \ReflectionMethod $method, ?string $parent): void
|
||||
{
|
||||
$nullable = false;
|
||||
$typesMap = [];
|
||||
foreach (explode('|', $types) as $t) {
|
||||
$typesMap[$this->normalizeType($t, $method->class, $parent)] = $t;
|
||||
}
|
||||
|
||||
if (isset($typesMap['array']) && (isset($typesMap['Traversable']) || isset($typesMap['\Traversable']))) {
|
||||
$typesMap['iterable'] = 'array' !== $typesMap['array'] ? $typesMap['array'] : 'iterable';
|
||||
unset($typesMap['array'], $typesMap['Traversable'], $typesMap['\Traversable']);
|
||||
}
|
||||
|
||||
if (isset($typesMap['array']) && isset($typesMap['iterable'])) {
|
||||
if ('[]' === substr($typesMap['array'], -2)) {
|
||||
$typesMap['iterable'] = $typesMap['array'];
|
||||
}
|
||||
unset($typesMap['array']);
|
||||
}
|
||||
|
||||
$normalizedType = key($typesMap);
|
||||
$returnType = current($typesMap);
|
||||
|
||||
foreach ($typesMap as $n => $t) {
|
||||
if ('null' === $n) {
|
||||
$nullable = true;
|
||||
} elseif ('null' === $normalizedType) {
|
||||
$normalizedType = $t;
|
||||
$returnType = $t;
|
||||
} elseif ($n !== $normalizedType) {
|
||||
// ignore multi-types return declarations
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ('void' === $normalizedType) {
|
||||
$nullable = false;
|
||||
} elseif (!isset(self::BUILTIN_RETURN_TYPES[$normalizedType]) && isset(self::SPECIAL_RETURN_TYPES[$normalizedType])) {
|
||||
// ignore other special return types
|
||||
return;
|
||||
}
|
||||
|
||||
if ($nullable) {
|
||||
$normalizedType = '?'.$normalizedType;
|
||||
$returnType .= '|null';
|
||||
}
|
||||
|
||||
self::$returnTypes[$method->class][$method->name] = [$normalizedType, $returnType, $method->class, $method->getFileName()];
|
||||
}
|
||||
|
||||
private function normalizeType(string $type, string $class, ?string $parent): string
|
||||
{
|
||||
if (isset(self::SPECIAL_RETURN_TYPES[$lcType = strtolower($type)])) {
|
||||
if ('parent' === $lcType = self::SPECIAL_RETURN_TYPES[$lcType]) {
|
||||
$lcType = null !== $parent ? '\\'.$parent : 'parent';
|
||||
} elseif ('self' === $lcType) {
|
||||
$lcType = '\\'.$class;
|
||||
}
|
||||
|
||||
return $lcType;
|
||||
}
|
||||
|
||||
if ('[]' === substr($type, -2)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
if (preg_match('/^(array|iterable|callable) *[<(]/', $lcType, $m)) {
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
// We could resolve "use" statements to return the FQDN
|
||||
// but this would be too expensive for a runtime checker
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to add @return annotations to the Symfony code-base where it triggers a self-deprecations.
|
||||
*/
|
||||
private static function patchMethod(\ReflectionMethod $method, string $returnType, string $declaringFile)
|
||||
{
|
||||
static $patchedMethods = [];
|
||||
static $useStatements = [];
|
||||
|
||||
if (!file_exists($file = $method->getFileName()) || isset($patchedMethods[$file][$startLine = $method->getStartLine()])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$patchedMethods[$file][$startLine] = true;
|
||||
$patchedMethods[$file][0] = $patchedMethods[$file][0] ?? 0;
|
||||
$startLine += $patchedMethods[$file][0] - 2;
|
||||
$returnType = explode('|', $returnType);
|
||||
$code = file($file);
|
||||
|
||||
foreach ($returnType as $i => $type) {
|
||||
if (preg_match('/((?:\[\])+)$/', $type, $m)) {
|
||||
$type = substr($type, 0, -\strlen($m[1]));
|
||||
$format = '%s'.$m[1];
|
||||
} elseif (preg_match('/^(array|iterable)<([^,>]++)>$/', $type, $m)) {
|
||||
$type = $m[2];
|
||||
$format = $m[1].'<%s>';
|
||||
} else {
|
||||
$format = null;
|
||||
}
|
||||
|
||||
if (isset(self::SPECIAL_RETURN_TYPES[$type]) || ('\\' === $type[0] && !$p = strrpos($type, '\\', 1))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($namespace, $useOffset, $useMap) = $useStatements[$file] ?? $useStatements[$file] = self::getUseStatements($file);
|
||||
|
||||
if ('\\' !== $type[0]) {
|
||||
list($declaringNamespace, , $declaringUseMap) = $useStatements[$declaringFile] ?? $useStatements[$declaringFile] = self::getUseStatements($declaringFile);
|
||||
|
||||
$p = strpos($type, '\\', 1);
|
||||
$alias = $p ? substr($type, 0, $p) : $type;
|
||||
|
||||
if (isset($declaringUseMap[$alias])) {
|
||||
$type = '\\'.$declaringUseMap[$alias].($p ? substr($type, $p) : '');
|
||||
} else {
|
||||
$type = '\\'.$declaringNamespace.$type;
|
||||
}
|
||||
|
||||
$p = strrpos($type, '\\', 1);
|
||||
}
|
||||
|
||||
$alias = substr($type, 1 + $p);
|
||||
$type = substr($type, 1);
|
||||
|
||||
if (!isset($useMap[$alias]) && (class_exists($c = $namespace.$alias) || interface_exists($c) || trait_exists($c))) {
|
||||
$useMap[$alias] = $c;
|
||||
}
|
||||
|
||||
if (!isset($useMap[$alias])) {
|
||||
$useStatements[$file][2][$alias] = $type;
|
||||
$code[$useOffset] = "use $type;\n".$code[$useOffset];
|
||||
++$patchedMethods[$file][0];
|
||||
} elseif ($useMap[$alias] !== $type) {
|
||||
$alias .= 'FIXME';
|
||||
$useStatements[$file][2][$alias] = $type;
|
||||
$code[$useOffset] = "use $type as $alias;\n".$code[$useOffset];
|
||||
++$patchedMethods[$file][0];
|
||||
}
|
||||
|
||||
$returnType[$i] = null !== $format ? sprintf($format, $alias) : $alias;
|
||||
}
|
||||
|
||||
$returnType = implode('|', $returnType);
|
||||
|
||||
if ($method->getDocComment()) {
|
||||
$code[$startLine] = " * @return $returnType\n".$code[$startLine];
|
||||
} else {
|
||||
$code[$startLine] .= <<<EOTXT
|
||||
/**
|
||||
* @return $returnType
|
||||
*/
|
||||
|
||||
EOTXT;
|
||||
}
|
||||
|
||||
$patchedMethods[$file][0] += substr_count($code[$startLine], "\n") - 1;
|
||||
file_put_contents($file, $code);
|
||||
}
|
||||
|
||||
private static function getUseStatements(string $file): array
|
||||
{
|
||||
$namespace = '';
|
||||
$useMap = [];
|
||||
$useOffset = 0;
|
||||
|
||||
if (!file_exists($file)) {
|
||||
return [$namespace, $useOffset, $useMap];
|
||||
}
|
||||
|
||||
$file = file($file);
|
||||
|
||||
for ($i = 0; $i < \count($file); ++$i) {
|
||||
if (preg_match('/^(class|interface|trait|abstract) /', $file[$i])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 === strpos($file[$i], 'namespace ')) {
|
||||
$namespace = substr($file[$i], \strlen('namespace '), -2).'\\';
|
||||
$useOffset = $i + 2;
|
||||
}
|
||||
|
||||
if (0 === strpos($file[$i], 'use ')) {
|
||||
$useOffset = $i;
|
||||
|
||||
for (; 0 === strpos($file[$i], 'use '); ++$i) {
|
||||
$u = explode(' as ', substr($file[$i], 4, -2), 2);
|
||||
|
||||
if (1 === \count($u)) {
|
||||
$p = strrpos($u[0], '\\');
|
||||
$useMap[substr($u[0], false !== $p ? 1 + $p : 0)] = $u[0];
|
||||
} else {
|
||||
$useMap[$u[1]] = $u[0];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [$namespace, $useOffset, $useMap];
|
||||
}
|
||||
|
||||
private static function fixReturnStatements(\ReflectionMethod $method, string $returnType)
|
||||
{
|
||||
if (!file_exists($file = $method->getFileName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fixedCode = $code = file($file);
|
||||
$end = $method->getEndLine();
|
||||
for ($i = $method->getStartLine(); $i < $end; ++$i) {
|
||||
if ('void' === $returnType) {
|
||||
$fixedCode[$i] = str_replace(' return null;', ' return;', $code[$i]);
|
||||
} elseif ('mixed' === $returnType || '?' === $returnType[0]) {
|
||||
$fixedCode[$i] = str_replace(' return;', ' return null;', $code[$i]);
|
||||
} else {
|
||||
$fixedCode[$i] = str_replace(' return;', " return $returnType!?;", $code[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($fixedCode !== $code) {
|
||||
file_put_contents($file, $fixedCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
$notFoundSuffix = '\' not found';
|
||||
$notFoundSuffixLen = \strlen($notFoundSuffix);
|
||||
if ($notFoundSuffixLen > $messageLen) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (['class', 'interface', 'trait'] as $typeName) {
|
||||
|
@ -30,17 +30,17 @@ class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
$notFoundSuffix = '()';
|
||||
$notFoundSuffixLen = \strlen($notFoundSuffix);
|
||||
if ($notFoundSuffixLen > $messageLen) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$prefix = 'Call to undefined function ';
|
||||
$prefixLen = \strlen($prefix);
|
||||
if (0 !== strpos($error['message'], $prefix)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
|
||||
|
@ -28,7 +28,7 @@ class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
{
|
||||
preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
|
||||
if (!$matches) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$className = $matches[1];
|
||||
|
@ -353,6 +353,40 @@ class DebugClassLoaderTest extends TestCase
|
||||
{
|
||||
$this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\DefinitionInEvaluatedCode', true));
|
||||
}
|
||||
|
||||
public function testReturnType()
|
||||
{
|
||||
$deprecations = [];
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
|
||||
$e = error_reporting(E_USER_DEPRECATED);
|
||||
|
||||
class_exists('Test\\'.__NAMESPACE__.'\\ReturnType', true);
|
||||
|
||||
error_reporting($e);
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertSame([
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeGrandParent::returnTypeGrandParent()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParentInterface::returnTypeParentInterface()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeInterface::returnTypeInterface()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNonNullableReturnableType()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNonNullableReturnableTypeWithNull()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNullableReturnableType()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNullableReturnableTypeWithNull()" will return "?bool" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneOtherType()" will return "\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneOtherTypeWithNull()" will return "?\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::manyIterables()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::nullableReturnableTypeNormalization()" will return "object" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::nonNullableReturnableTypeNormalization()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::commonNonObjectReturnedTypeNormalization()" will return "object" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::bracketsNormalization()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::booleanNormalization()" will return "bool" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::callableNormalization1()" will return "callable" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::callableNormalization2()" will return "callable" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::otherTypeNormalization()" will return "\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::arrayWithLessThanSignNormalization()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.',
|
||||
], $deprecations);
|
||||
}
|
||||
}
|
||||
|
||||
class ClassLoader
|
||||
@ -435,6 +469,10 @@ class ClassLoader
|
||||
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualMagicCall' === $class) {
|
||||
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsVirtualMagicCall extends \\'.__NAMESPACE__.'\Fixtures\VirtualClassMagicCall implements \\'.__NAMESPACE__.'\Fixtures\VirtualInterface {
|
||||
}');
|
||||
} elseif ('Test\\'.__NAMESPACE__.'\ReturnType' === $class) {
|
||||
return $fixtureDir.\DIRECTORY_SEPARATOR.'ReturnType.php';
|
||||
} elseif ('Test\\'.__NAMESPACE__.'\Fixtures\OutsideInterface' === $class) {
|
||||
return $fixtureDir.\DIRECTORY_SEPARATOR.'OutsideInterface.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Symfony\Component\ErrorHandler\Tests\Fixtures;
|
||||
|
||||
interface OutsideInterface
|
||||
{
|
||||
/**
|
||||
* @return string - should not be reported as it's in a non-Symfony namespace
|
||||
*/
|
||||
public function outsideMethod();
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Symfony\Component\ErrorHandler\Tests;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent;
|
||||
use Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeInterface;
|
||||
|
||||
class ReturnType extends ReturnTypeParent implements ReturnTypeInterface, Fixtures\OutsideInterface
|
||||
{
|
||||
public function returnTypeGrandParent() { }
|
||||
public function returnTypeParentInterface() { }
|
||||
public function returnTypeInterface() { }
|
||||
public function realReturnTypeMustBeThere(): string { }
|
||||
public function realReturnTypeIsAlreadyThere(): float { }
|
||||
public function realReturnTypeIsAlreadyThereWithNull(): ?iterable { }
|
||||
public function oneCommonNonObjectReturnedType() { }
|
||||
public function oneCommonNonObjectReturnedTypeWithNull() { }
|
||||
public function oneNonNullableReturnableType() { }
|
||||
public function oneNonNullableReturnableTypeWithNull() { }
|
||||
public function oneNullableReturnableType() { }
|
||||
public function oneNullableReturnableTypeWithNull() { }
|
||||
public function oneOtherType() { }
|
||||
public function oneOtherTypeWithNull() { }
|
||||
public function twoNullableReturnableTypes() { }
|
||||
public function twoNullEdgeCase() { }
|
||||
public function threeReturnTypes() { }
|
||||
/**
|
||||
* @return anything - should not trigger
|
||||
*/
|
||||
public function throughDoc() { }
|
||||
/**
|
||||
* @return parent - same as parent
|
||||
*/
|
||||
public function optOutThroughDoc() { }
|
||||
public function manyIterables() { }
|
||||
public function nullableReturnableTypeNormalization() { }
|
||||
public function nonNullableReturnableTypeNormalization() { }
|
||||
public function commonNonObjectReturnedTypeNormalization() { }
|
||||
public function bracketsNormalization() { }
|
||||
public function booleanNormalization() { }
|
||||
public function callableNormalization1() { }
|
||||
public function callableNormalization2() { }
|
||||
public function otherTypeNormalization() { }
|
||||
public function arrayWithLessThanSignNormalization() { }
|
||||
public function outsideMethod() { }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\Tests\Fixtures;
|
||||
|
||||
abstract class ReturnTypeGrandParent
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function returnTypeGrandParent()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\Tests\Fixtures;
|
||||
|
||||
interface ReturnTypeInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function returnTypeInterface();
|
||||
}
|
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\Tests\Fixtures;
|
||||
|
||||
abstract class ReturnTypeParent extends ReturnTypeGrandParent implements ReturnTypeParentInterface
|
||||
{
|
||||
/**
|
||||
* No return declared here
|
||||
*/
|
||||
public function returnTypeGrandParent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function realReturnTypeMustBeThere(): string;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function realReturnTypeIsAlreadyThere()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable|null
|
||||
*/
|
||||
abstract public function realReturnTypeIsAlreadyThereWithNull();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function oneCommonNonObjectReturnedType()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource|null
|
||||
*/
|
||||
public function oneCommonNonObjectReturnedTypeWithNull()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function oneNonNullableReturnableType()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void|null
|
||||
*/
|
||||
public function oneNonNullableReturnableTypeWithNull()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array The array
|
||||
*/
|
||||
public function oneNullableReturnableType()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|null
|
||||
*/
|
||||
public function oneNullableReturnableTypeWithNull()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator
|
||||
*/
|
||||
public function oneOtherType()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator|null
|
||||
*/
|
||||
public function oneOtherTypeWithNull()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|self
|
||||
*/
|
||||
public function twoNullableReturnableTypes()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|null
|
||||
*/
|
||||
public function twoNullEdgeCase()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public function threeReturnTypes()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function throughDoc()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function optOutThroughDoc()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator[]|\DirectoryIterator[]
|
||||
*/
|
||||
public function manyIterables()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Something before.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function nullableReturnableTypeNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @annotation before
|
||||
* @return VOID
|
||||
*/
|
||||
public function nonNullableReturnableTypeNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function commonNonObjectReturnedTypeNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator[]
|
||||
*/
|
||||
public function bracketsNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function booleanNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return callable(\Throwable $reason, mixed $value)
|
||||
*/
|
||||
public function callableNormalization1()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return callable ($a, $b)
|
||||
*/
|
||||
public function callableNormalization2()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator
|
||||
*/
|
||||
public function otherTypeNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public function arrayWithLessThanSignNormalization()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function notExtended()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ErrorHandler\Tests\Fixtures;
|
||||
|
||||
interface ReturnTypeParentInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function returnTypeParentInterface();
|
||||
}
|
@ -65,6 +65,8 @@ class Logger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
|
@ -41,46 +41,73 @@ class Logger implements LoggerInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
$this->logs[$level][] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function emergency($message, array $context = [])
|
||||
{
|
||||
$this->log('emergency', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function alert($message, array $context = [])
|
||||
{
|
||||
$this->log('alert', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function critical($message, array $context = [])
|
||||
{
|
||||
$this->log('critical', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function error($message, array $context = [])
|
||||
{
|
||||
$this->log('error', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function warning($message, array $context = [])
|
||||
{
|
||||
$this->log('warning', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function notice($message, array $context = [])
|
||||
{
|
||||
$this->log('notice', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function info($message, array $context = [])
|
||||
{
|
||||
$this->log('info', $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function debug($message, array $context = [])
|
||||
{
|
||||
$this->log('debug', $message, $context);
|
||||
|
@ -84,13 +84,13 @@ class TimezoneDataGenerator extends AbstractDataGenerator
|
||||
// Don't generate aliases, as they are resolved during runtime
|
||||
// Unless an alias is needed as fallback for de-duplication purposes
|
||||
if (isset($this->localeAliases[$displayLocale]) && !$this->generatingFallback) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$localeBundle = $reader->read($tempDir, $displayLocale);
|
||||
|
||||
if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = [
|
||||
@ -115,7 +115,7 @@ class TimezoneDataGenerator extends AbstractDataGenerator
|
||||
$data['Meta'] = array_diff($data['Meta'], $fallback['Meta']);
|
||||
}
|
||||
if (!$data['Names'] && !$data['Meta']) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->zoneIds = array_merge($this->zoneIds, array_keys($data['Names']));
|
||||
|
@ -61,6 +61,8 @@ class GenericLinkProvider implements EvolvableLinkProviderInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withLink(LinkInterface $link)
|
||||
{
|
||||
@ -72,6 +74,8 @@ class GenericLinkProvider implements EvolvableLinkProviderInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withoutLink(LinkInterface $link)
|
||||
{
|
||||
|
@ -92,6 +92,8 @@ class Link implements EvolvableLinkInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withHref($href)
|
||||
{
|
||||
@ -104,6 +106,8 @@ class Link implements EvolvableLinkInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withRel($rel)
|
||||
{
|
||||
@ -115,6 +119,8 @@ class Link implements EvolvableLinkInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withoutRel($rel)
|
||||
{
|
||||
@ -126,6 +132,8 @@ class Link implements EvolvableLinkInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withAttribute($attribute, $value)
|
||||
{
|
||||
@ -137,6 +145,8 @@ class Link implements EvolvableLinkInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withoutAttribute($attribute)
|
||||
{
|
||||
|
@ -36,6 +36,8 @@ trait ServiceLocatorTrait
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($id)
|
||||
{
|
||||
|
Reference in New Issue
Block a user