prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
buted with this source code.
*/
namespace Symfony\Component\Cache\Tests\Adapter;
use Psr\Cache\InvalidArgumentException;
use Symfony\Component\Cache\CacheItem;
/**
* Common assertions for TagAware adapters.
*
* @method \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface createCachePool(int $defaultLifetime... | $i1 = $pool->getItem('i1');
$i2 = $pool->getItem('i2');
$i3 = $pool->getItem('i3');
$foo = $pool->getItem('foo');
$pool->save($i0->tag('bar'));
$pool->save($i1->tag('foo'));
$pool->save($i2->tag('foo')-> |
$this->expectException(InvalidArgumentException::class);
$item->tag(':');
}
public function testInvalidateTags()
{
$pool = $this->createCachePool();
$i0 = $pool->getItem('i0');
| {
"filepath": "src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php",
"language": "php",
"file_size": 5905,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Cache\Tests\DataCollector;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\NullAdapter;
use Symfony\Component\Cache\Adapter\TraceableAdapter;
use Symfony\Component\Cache\DataCollector\CacheDataCollector;
use Symfony\Component\HttpFoundat... | >assertSame(0, $statistics[self::INSTANCE_NAME]['reads'], 'reads');
$this->assertSame(0, $statistics[self::INSTANCE_NAME]['hits'], 'hits');
$this->assertSame(0, $statistics[self::INSTANCE_NAME]['misses'], 'misses');
$this->assertSam | t';
public function testEmptyDataCollector()
{
$statistics = $this->getCacheDataCollectorStatisticsFromEvents([]);
$this->assertSame(0, $statistics[self::INSTANCE_NAME]['calls'], 'calls');
$this- | {
"filepath": "src/Symfony/Component/Cache/Tests/DataCollector/CacheDataCollectorTest.php",
"language": "php",
"file_size": 7646,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\TypeResolver;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocPar... | Info\TypeContext\TypeContext;
use Symfony\Component\TypeInfo\TypeContext\TypeContextFactory;
/**
* Resolves type on reflection prioriziting PHP documentation.
*
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
*/
final class PhpDocAwareReflectionTy | rser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;
use Symfony\Component\TypeInfo\Exception\UnsupportedException;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\Type | {
"filepath": "src/Symfony/Component/TypeInfo/TypeResolver/PhpDocAwareReflectionTypeResolver.php",
"language": "php",
"file_size": 4438,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidArgumentException;
use Symfony\Component\... | /**
* @param list<T> $types
*/
public function __construct(Type ...$types)
{
if (\count($types) < 2) {
throw new InvalidArgumentException(\sprintf('"%s" expects at least 2 types.', self::class));
}
| Type<GenericType<ObjectType>>
*
* @implements CompositeTypeInterface<T>
*/
final class IntersectionType extends Type implements CompositeTypeInterface
{
/**
* @var list<T>
*/
private readonly array $types;
| {
"filepath": "src/Symfony/Component/TypeInfo/Type/IntersectionType.php",
"language": "php",
"file_size": 2514,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeIdentifier;
/**
* Represents the exact shape of an anonymous objec... | ok at the public, initialized
* properties returned by get_object_vars(); non-public properties, uninitialized
* typed properties and state exposed only through __get() or other magic
* accessors are not visible.
*
* @author Benjamin Franzke <ben@bnf. | ject shapes are always sealed: unlike ArrayShapeType, no
* extra-key/extra-value type is supported because the underlying
* phpstan-phpdoc-parser AST node has no such notion.
*
* Presence and value checks in accepts() both lo | {
"filepath": "src/Symfony/Component/TypeInfo/Type/ObjectShapeType.php",
"language": "php",
"file_size": 3236,
"cut_index": 614,
"middle_length": 229
} |
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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type;
/**
* Repre... | $name,
private readonly Type $bound,
) {
}
public function getName(): string
{
return $this->name;
}
/**
* @return T
*/
public function getBound(): Type
{
return $this->bound;
}
p | Type
*
* @implements WrappingTypeInterface<T>
*/
final class TemplateType extends Type implements WrappingTypeInterface
{
/**
* @param T $bound
*/
public function __construct(
private readonly string | {
"filepath": "src/Symfony/Component/TypeInfo/Type/TemplateType.php",
"language": "php",
"file_size": 1406,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type\CollectionType;
use Symfony\Compon... | $this->assertTrue(Type::collection(Type::object(\Iterator::class))->isIdentifiedBy(TypeIdentifier::OBJECT));
$this->assertTrue(Type::generic(Type::object(\Iterator::class), Type::string())->isIdentifiedBy(TypeIdentifier::OBJECT));
$this | tersection(Type::object(\Iterator::class), Type::object(\Stringable::class))->isIdentifiedBy(TypeIdentifier::OBJECT));
$this->assertTrue(Type::union(Type::int(), Type::string())->isIdentifiedBy(TypeIdentifier::INT));
| {
"filepath": "src/Symfony/Component/TypeInfo/Tests/TypeTest.php",
"language": "php",
"file_size": 3921,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\Tests\TypeResolver;
use PHPUnit\Framework\TestCase;
use Symfony\Component\TypeInfo\Exception\UnsupportedException;
use Symfony\Component\TypeInfo\... | \ReflectionTypeResolver;
class ReflectionParameterTypeResolverTest extends TestCase
{
private ReflectionParameterTypeResolver $resolver;
protected function setUp(): void
{
$this->resolver = new ReflectionParameterTypeResolver(new Refl | leTrait;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeContext\TypeContextFactory;
use Symfony\Component\TypeInfo\TypeResolver\ReflectionParameterTypeResolver;
use Symfony\Component\TypeInfo\TypeResolver | {
"filepath": "src/Symfony/Component/TypeInfo/Tests/TypeResolver/ReflectionParameterTypeResolverTest.php",
"language": "php",
"file_size": 4083,
"cut_index": 614,
"middle_length": 229
} |
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\TypeInfo\TypeResolver;
use Symfony\Component\TypeInfo\Exception\UnsupportedExc... | c function __construct(
private readonly ReflectionTypeResolver $reflectionTypeResolver,
private readonly TypeContextFactory $typeContextFactory,
) {
}
public function resolve(mixed $subject, ?TypeContext $typeContext = null): | given parameter reflection.
*
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*/
final class ReflectionParameterTypeResolver implements TypeResolverInterface
{
publi | {
"filepath": "src/Symfony/Component/TypeInfo/TypeResolver/ReflectionParameterTypeResolver.php",
"language": "php",
"file_size": 1914,
"cut_index": 537,
"middle_length": 229
} |
se PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFloatNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNullNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode;
use PHPStan\PhpDocParser\... | ype\NullableTypeNode;
use PHPStan\PhpDocParser\Ast\Type\ObjectShapeNode;
use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PHPStan\PhpDocParser\Lexer\Lexer;
use | \PhpDocParser\Ast\Type\ConstTypeNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
use PHPStan\PhpDocParser\Ast\T | {
"filepath": "src/Symfony/Component/TypeInfo/TypeResolver/StringTypeResolver.php",
"language": "php",
"file_size": 15677,
"cut_index": 921,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\TypeResolver;
use Symfony\Component\TypeInfo\Exception\UnsupportedException;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\Ty... | resolve a {@see Type} on a $subject.
* If the resolver cannot resolve the type, it will throw a {@see UnsupportedException}.
*
* @throws UnsupportedException
*/
public function resolve(mixed $subject, ?TypeContext $typeContext = nul | rface TypeResolverInterface
{
/**
* Try to | {
"filepath": "src/Symfony/Component/TypeInfo/TypeResolver/TypeResolverInterface.php",
"language": "php",
"file_size": 926,
"cut_index": 606,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidArgumentException;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeIdentifier;
/**
* Represents a key/value collection type.
*
* @author Mathias Arlaud <mathias.arlau... | ericType $type,
private readonly bool $isList = false,
) {
if ($type instanceof BuiltinType && TypeIdentifier::ARRAY !== $type->getTypeIdentifier() && TypeIdentifier::ITERABLE !== $type->getTypeIdentifier()) {
throw new Inva | plements WrappingTypeInterface<T>
*/
class CollectionType extends Type implements WrappingTypeInterface
{
/**
* @param T $type
*/
public function __construct(
private readonly BuiltinType|ObjectType|Gen | {
"filepath": "src/Symfony/Component/TypeInfo/Type/CollectionType.php",
"language": "php",
"file_size": 7151,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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\Cache\Tests\Adapter;
use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\Cache\Adapter\Abstrac... | if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) {
self::markTestSkipped('REDIS_SENTINEL_HOSTS env var is not defined.');
}
if (!$service = getenv('REDIS_SENTINEL_SERVICE')) {
self::markTestSkipped('REDIS_SENTINEL_SERV | ractRedisAdapterTestCase
{
public static function setUpBeforeClass(): void
{
if (!class_exists(\RedisSentinel::class)) {
self::markTestSkipped('The RedisSentinel class is required.');
}
| {
"filepath": "src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php",
"language": "php",
"file_size": 2174,
"cut_index": 563,
"middle_length": 229
} |
fo\Type\BuiltinType;
use Symfony\Component\TypeInfo\Type\CollectionType;
use Symfony\Component\TypeInfo\Type\EnumType;
use Symfony\Component\TypeInfo\Type\GenericType;
use Symfony\Component\TypeInfo\Type\IntersectionType;
use Symfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectShapeT... | * @param T|U $identifier
*
* @return BuiltinType<T>
*/
public static function builtin(TypeIdentifier|string $identifier): BuiltinType
{
/** @var T $identifier */
$identifier = \is_string($identifier) ? TypeIdentifi | sily.
*
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*/
trait TypeFactoryTrait
{
/**
* @template T of TypeIdentifier
* @template U value-of<T>
*
| {
"filepath": "src/Symfony/Component/TypeInfo/TypeFactoryTrait.php",
"language": "php",
"file_size": 13963,
"cut_index": 921,
"middle_length": 229
} |
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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidArgumentExcepti... | nstruct(
private readonly Type $type,
) {
if ($type->isNullable()) {
throw new InvalidArgumentException(\sprintf('Cannot create a "%s" with "%s" because it is already nullable.', self::class, $type));
}
if ( | Type<T|BuiltinType<TypeIdentifier::NULL>>
*
* @implements WrappingTypeInterface<T>
*/
final class NullableType extends UnionType implements WrappingTypeInterface
{
/**
* @param T $type
*/
public function __co | {
"filepath": "src/Symfony/Component/TypeInfo/Type/NullableType.php",
"language": "php",
"file_size": 1722,
"cut_index": 537,
"middle_length": 229
} |
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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\Type... | ntifier::OBJECT;
}
/**
* @return T
*/
public function getClassName(): string
{
return $this->className;
}
public function isIdentifiedBy(TypeIdentifier|string ...$identifiers): bool
{
foreach ($identi | ds Type
{
/**
* @param T $className
*/
public function __construct(
private readonly string $className,
) {
}
public function getTypeIdentifier(): TypeIdentifier
{
return TypeIde | {
"filepath": "src/Symfony/Component/TypeInfo/Type/ObjectType.php",
"language": "php",
"file_size": 1725,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (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\TypeInfo\Tests\TypeResolver;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCa... |
class PhpDocAwareReflectionTypeResolverTest extends TestCase
{
#[DataProvider('readPhpDocDataProvider')]
public function testReadPhpDoc(Type $expected, \Reflector $reflector)
{
$resolver = new PhpDocAwareReflectionTypeResolver(TypeReso | Context\TypeContextFactory;
use Symfony\Component\TypeInfo\TypeResolver\PhpDocAwareReflectionTypeResolver;
use Symfony\Component\TypeInfo\TypeResolver\StringTypeResolver;
use Symfony\Component\TypeInfo\TypeResolver\TypeResolver;
| {
"filepath": "src/Symfony/Component/TypeInfo/Tests/TypeResolver/PhpDocAwareReflectionTypeResolverTest.php",
"language": "php",
"file_size": 2575,
"cut_index": 563,
"middle_length": 229
} |
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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidAr... | * @param U $backingType
*/
public function __construct(
string $className,
private readonly BuiltinType $backingType,
) {
if (TypeIdentifier::INT !== $backingType->getTypeIdentifier() && TypeIdentifier::STRING !== | of class-string<\BackedEnum>
* @template U of BuiltinType<TypeIdentifier::INT>|BuiltinType<TypeIdentifier::STRING>
*
* @extends EnumType<T>
*/
final class BackedEnumType extends EnumType
{
/**
* @param T $className
| {
"filepath": "src/Symfony/Component/TypeInfo/Type/BackedEnumType.php",
"language": "php",
"file_size": 1368,
"cut_index": 524,
"middle_length": 229
} |
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\TypeInfo;
/**
* Identifier of a PHP native type.
*
* @author M... | ce';
case STRING = 'string';
case TRUE = 'true';
case NEVER = 'never';
case VOID = 'void';
/**
* @return list<string>
*/
public static function values(): array
{
return array_column(self::cases(), 'value');
| BLE = 'callable';
case FALSE = 'false';
case FLOAT = 'float';
case INT = 'int';
case ITERABLE = 'iterable';
case MIXED = 'mixed';
case NULL = 'null';
case OBJECT = 'object';
case RESOURCE = 'resour | {
"filepath": "src/Symfony/Component/TypeInfo/TypeIdentifier.php",
"language": "php",
"file_size": 1440,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidArgumentException;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeI... | pes)
{
if (\count($types) < 2) {
throw new InvalidArgumentException(\sprintf('"%s" expects at least 2 types.', self::class));
}
foreach ($types as $type) {
if ($type instanceof self) {
th | */
class UnionType extends Type implements CompositeTypeInterface
{
/**
* @var list<T>
*/
private readonly array $types;
/**
* @param list<T> $types
*/
public function __construct(Type ...$ty | {
"filepath": "src/Symfony/Component/TypeInfo/Type/UnionType.php",
"language": "php",
"file_size": 3838,
"cut_index": 614,
"middle_length": 229
} |
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\TypeInfo\TypeResolver;
use Symfony\Component\TypeInfo\Exception\UnsupportedExc... | function __construct(
private readonly ReflectionTypeResolver $reflectionTypeResolver,
private readonly TypeContextFactory $typeContextFactory,
) {
}
public function resolve(mixed $subject, ?TypeContext $typeContext = null): Ty | given property reflection.
*
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*/
final class ReflectionPropertyTypeResolver implements TypeResolverInterface
{
public | {
"filepath": "src/Symfony/Component/TypeInfo/TypeResolver/ReflectionPropertyTypeResolver.php",
"language": "php",
"file_size": 1703,
"cut_index": 537,
"middle_length": 229
} |
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\Cache\Tests\Adapter;
use PHPUnit\Framework\Attributes\Group;
use ... | ')) {
self::markTestSkipped('REDIS_SENTINEL_HOSTS env var is not defined.');
}
if (!$service = getenv('REDIS_SENTINEL_SERVICE')) {
self::markTestSkipped('REDIS_SENTINEL_SERVICE env var is not defined.');
}
| static function setUpBeforeClass(): void
{
if (!class_exists(Sentinel::class)) {
self::markTestSkipped('The Relay\Sentinel class is required.');
}
if (!$hosts = getenv('REDIS_SENTINEL_HOSTS | {
"filepath": "src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php",
"language": "php",
"file_size": 1305,
"cut_index": 524,
"middle_length": 229
} |
ummyBackedEnum;
use Symfony\Component\TypeInfo\Tests\Fixtures\DummyEnum;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type\ArrayShapeType;
use Symfony\Component\TypeInfo\Type\BackedEnumType;
use Symfony\Component\TypeInfo\Type\BuiltinType;
use Symfony\Component\TypeInfo\Type\CollectionType;
use S... | o\TypeIdentifier;
class TypeFactoryTest extends TestCase
{
public function testCreateBuiltin()
{
$this->assertEquals(new BuiltinType(TypeIdentifier::INT), Type::builtin(TypeIdentifier::INT));
$this->assertEquals(new BuiltinType(Typ | ;
use Symfony\Component\TypeInfo\Type\ObjectShapeType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\TypeInfo\Type\TemplateType;
use Symfony\Component\TypeInfo\Type\UnionType;
use Symfony\Component\TypeInf | {
"filepath": "src/Symfony/Component/TypeInfo/Tests/TypeFactoryTest.php",
"language": "php",
"file_size": 14488,
"cut_index": 921,
"middle_length": 229
} |
ge.
*
* (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\TypeInfo\Type;
use Symfony\Component\TypeInfo\Exception\InvalidArgumentException;
use Symfony\Component\... | ype extends Type implements WrappingTypeInterface
{
/**
* @var list<Type>
*/
private readonly array $variableTypes;
/**
* @param T $type
*/
public function __construct(
private readonly BuiltinType|ObjectType $t | om>
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*
* @template T of BuiltinType<TypeIdentifier::ARRAY>|BuiltinType<TypeIdentifier::ITERABLE>|ObjectType
*
* @implements WrappingTypeInterface<T>
*/
final class GenericT | {
"filepath": "src/Symfony/Component/TypeInfo/Type/GenericType.php",
"language": "php",
"file_size": 2231,
"cut_index": 563,
"middle_length": 229
} |
* 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\EventDispatcher\Tests\Fixtures;
use Symfony\Component\EventDispa... | public function onCustomEvent(CustomEvent $event): void
{
}
public function onFoo(): void
{
}
public function onBarEvent(): void
{
}
#[AsEventListener(event: 'baz')]
public function onBazEvent(): void
{
} | 'onBarEvent')]
final class TaggedMultiListener
{
| {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/Fixtures/TaggedMultiListener.php",
"language": "php",
"file_size": 834,
"cut_index": 523,
"middle_length": 52
} |
/*
* 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\ExpressionLanguage\Tests;
use PHPUnit\Framework\TestCase;
u... | xpressionFunction::fromPhp('fn_does_not_exist');
}
public function testFunctionNamespaced()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('An expression function name must be defined | estCase
{
public function testFunctionDoesNotExist()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('PHP function "fn_does_not_exist" does not exist.');
E | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php",
"language": "php",
"file_size": 1233,
"cut_index": 518,
"middle_length": 229
} |
Symfony\Component\ExpressionLanguage\Tests\Fixtures\TestProvider;
class ExpressionLanguageTest extends TestCase
{
public function testCachedParse()
{
$cacheMock = $this->createMock(CacheItemPoolInterface::class);
$cacheItemMock = $this->createMock(CacheItemInterface::class);
$savedParse... | $savedParsedExpression) {
return $savedParsedExpression;
})
;
$cacheItemMock
->expects($this->exactly(1))
->method('set')
->with($this->isInstanceOf(ParsedExpression::class))
| >with('1%20%2B%201%2F%2F')
->willReturn($cacheItemMock)
;
$cacheItemMock
->expects($this->exactly(2))
->method('get')
->willReturnCallback(static function () use (& | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php",
"language": "php",
"file_size": 19831,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ExpressionLanguage\Lexer;
use Symfony\Component\ExpressionLanguage\SyntaxError;
use Symfony\Component\ExpressionLanguage\Token;
us... | nStream($tokens, $expression), $this->lexer->tokenize($expression));
}
public function testTokenizeMultilineComment()
{
$expression = <<<EXPRESSION
/**
* This is 2^16, even if we could have
* used | ;
}
#[DataProvider('getTokenizeData')]
public function testTokenize($tokens, $expression)
{
$tokens[] = new Token('end of expression', null, \strlen($expression) + 1);
$this->assertEquals(new Toke | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php",
"language": "php",
"file_size": 8792,
"cut_index": 716,
"middle_length": 229
} |
* 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\ExpressionLanguage\Tests;
use PHPUnit\Framework\TestCase;
use S... |
$expression = new ParsedExpression('25', new ConstantNode('25'));
$serializedExpression = serialize($expression);
$unserializedExpression = unserialize($serializedExpression);
$this->assertEquals($expression, $unserialize | zation()
{ | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/ParsedExpressionTest.php",
"language": "php",
"file_size": 814,
"cut_index": 522,
"middle_length": 14
} |
);
$lexer = new Lexer();
$parser = new Parser([]);
$parser->parse($lexer->tokenize('foo'));
}
public function testParseWithZeroInNames()
{
$this->expectException(SyntaxError::class);
$this->expectExceptionMessage('Variable "foo" is not valid around position 1 for exp... | oes not exist around position 1 for expression `foo()`.');
$parser->parse($stream);
}
public function testParseUnknownFunction()
{
$parser = new Parser([]);
$tokenized = (new Lexer())->tokenize('foo()');
$this | hUnknownFunctionThrows()
{
$parser = new Parser([]);
$stream = (new Lexer())->tokenize('foo()');
$this->expectException(SyntaxError::class);
$this->expectExceptionMessage('The function "foo" d | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php",
"language": "php",
"file_size": 17697,
"cut_index": 1331,
"middle_length": 229
} |
n 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\ExpressionLanguage\Tests\Fixtures;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\Expre... | => $input, fn (array $values, $input) => $input),
ExpressionFunction::fromPhp('strtoupper'),
ExpressionFunction::fromPhp('\strtolower'),
ExpressionFunction::fromPhp('Symfony\Component\ExpressionLanguage\Tests\Fixtures | new ExpressionFunction('identity', fn ($input) | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php",
"language": "php",
"file_size": 991,
"cut_index": 582,
"middle_length": 52
} |
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\ExpressionLanguage\Tests\Node;
use PHPUnit\Framework\Attributes\D... | ;
#[DataProvider('getCompileData')]
public function testCompile($expected, $node, $functions = [])
{
$compiler = new Compiler($functions);
$node->compile($compiler);
$this->assertSame($expected, $compiler->getSource()); | public function testEvaluate($expected, $node, $variables = [], $functions = [])
{
$this->assertSame($expected, $node->evaluate($functions, $variables));
}
abstract public static function getEvaluateData() | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTestCase.php",
"language": "php",
"file_size": 1273,
"cut_index": 524,
"middle_length": 229
} |
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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguag... | ode()],
];
}
public static function getDumpData(): \Generator
{
yield from [
['"a", "b"', static::getArrayNode()],
];
}
protected static function createArrayNode(): ArrayNode
{
return ne | return [
['"a", "b"', static::getArrayN | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/ArgumentsNodeTest.php",
"language": "php",
"file_size": 864,
"cut_index": 529,
"middle_length": 52
} |
ge.
*
* (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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
use Symfony\Comp... | uals($this->createArrayNode(), $unserializedNode);
}
public static function getEvaluateData(): array
{
return [
[['b' => 'a', 'b'], static::getArrayNode()],
];
}
public static function getCompileData(): arr | $node->addElement(new ConstantNode('foo'));
$serializedNode = serialize($node);
$unserializedNode = unserialize($serializedNode);
$this->assertEquals($node, $unserializedNode);
$this->assertNotEq | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/ArrayNodeTest.php",
"language": "php",
"file_size": 2090,
"cut_index": 563,
"middle_length": 229
} |
nent\ExpressionLanguage\Node\ArrayNode;
use Symfony\Component\ExpressionLanguage\Node\BinaryNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\NameNode;
use Symfony\Component\ExpressionLanguage\SyntaxError;
class BinaryNodeTest extends AbstractNodeTestCase
{... | naryNode('xor', new ConstantNode(true), new ConstantNode(true))],
[false, new BinaryNode('and', new ConstantNode(true), new ConstantNode(false))],
[false, new BinaryNode('&&', new ConstantNode(true), new ConstantNode(false))],
| );
return [
[true, new BinaryNode('or', new ConstantNode(true), new ConstantNode(false))],
[true, new BinaryNode('||', new ConstantNode(true), new ConstantNode(false))],
[false, new Bi | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php",
"language": "php",
"file_size": 15672,
"cut_index": 921,
"middle_length": 229
} |
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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLa... | ode(2))],
];
}
public static function getCompileData(): array
{
return [
['((true) ? (1) : (2))', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
['((false) ? (1) | array
{
return [
[1, new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
[2, new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantN | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/ConditionalNodeTest.php",
"language": "php",
"file_size": 1455,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
class Consta... | de([1, 'b' => 'a'])],
];
}
public static function getCompileData(): array
{
return [
// Booleans
['false', new ConstantNode(false)],
['true', new ConstantNode(true)],
// Null
| ntNode(true)],
[null, new ConstantNode(null)],
[3, new ConstantNode(3)],
[3.3, new ConstantNode(3.3)],
['foo', new ConstantNode('foo')],
[[1, 'b' => 'a'], new ConstantNo | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/ConstantNodeTest.php",
"language": "php",
"file_size": 2903,
"cut_index": 563,
"middle_length": 229
} |
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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLa... | atic function getCompileData(): array
{
return [
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]],
];
}
public static function getDumpData(): array
|
public static function getEvaluateData(): array
{
return [
['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => static::getCallables()]],
];
}
public st | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php",
"language": "php",
"file_size": 1368,
"cut_index": 524,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\ArgumentsNode;
use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
use Symfony\Component\ExpressionLanguage\Node\Ge... | e('b'), self::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
| n [
['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), self::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]],
['a', new GetAttrNode(new NameNode('foo'), new ConstantNod | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php",
"language": "php",
"file_size": 6362,
"cut_index": 716,
"middle_length": 229
} |
/*
* 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\ExpressionLanguage\Tests\Node;
use Symfony\Component\Expre... | static function getCompileData(): array
{
return [
['$foo', new NameNode('foo')],
];
}
public static function getDumpData(): array
{
return [
['foo', new NameNode('foo')],
];
}
}
| '), ['foo' => 'bar']],
];
}
public | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/NameNodeTest.php",
"language": "php",
"file_size": 825,
"cut_index": 517,
"middle_length": 52
} |
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\ExpressionLanguage\Tests\Node;
use PHPUnit\Framework\TestCase;
use Symfony\Com... | tring) $node
);
}
public function testSerialization()
{
$node = new Node(['foo' => 'bar'], ['bar' => 'foo']);
$serializedNode = serialize($node);
$unserializedNode = unserialize($serializedNode);
$this | c function testToString()
{
$node = new Node([new ConstantNode('foo')]);
$this->assertEquals(<<<'EOF'
Node(
ConstantNode(value: 'foo')
)
EOF,
(s | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/NodeTest.php",
"language": "php",
"file_size": 1860,
"cut_index": 537,
"middle_length": 229
} |
he 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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\NullCoalesc... | function getCompileData(): array
{
return [
['$foo ?? null', new NullCoalescedNameNode('foo')],
];
}
public static function getDumpData(): array
{
return [
['foo ?? null', new NullCoalescedN | ode('foo'), []],
];
}
public static | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/NullCoalescedNameNodeTest.php",
"language": "php",
"file_size": 891,
"cut_index": 547,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
use Symfony\Component\ExpressionLanguage\SyntaxError;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
class BinaryNode extends Node
{
private const OPE... | Node $right)
{
parent::__construct(
['left' => $left, 'right' => $right],
['operator' => $operator]
);
}
public function compile(Compiler $compiler): void
{
$operator = $this->attributes['ope | ,
'not in' => '!\\in_array',
'contains' => 'str_contains',
'starts with' => 'str_starts_with',
'ends with' => 'str_ends_with',
];
public function __construct(string $operator, Node $left, | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php",
"language": "php",
"file_size": 6277,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Fabien Poten... | ->attributes['value']);
}
public function evaluate(array $functions, array $values): mixed
{
return $this->attributes['value'];
}
public function toArray(): array
{
$array = [];
$value = $this->attributes[' | c readonly bool $isNullSafe = false,
) {
parent::__construct(
[],
['value' => $value]
);
}
public function compile(Compiler $compiler): void
{
$compiler->repr($this | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php",
"language": "php",
"file_size": 2037,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
class GetAttrNode extends Node
{
public const PROPERTY_CALL = 1;
public const METHOD_CALL = 2;
... | pe, bool $isNullSafe = false)
{
$isNullSafe = self::ARRAY_CALL === $type && $isNullSafe;
parent::__construct(
['node' => $node, 'attribute' => $attribute, 'arguments' => $arguments],
['type' => $type, 'is_null_c | * For self::PROPERTY_CALL and self::METHOD_CALL, null-safety is driven by ConstantNode::$isNullSafe.
*/
public function __construct(Node $node, Node $attribute, ArrayNode $arguments, int $ty | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php",
"language": "php",
"file_size": 8038,
"cut_index": 716,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
... | $compiler->raw('$'.$this->attributes['name']);
}
public function evaluate(array $functions, array $values): mixed
{
return $values[$this->attributes['name']];
}
public function toArray(): array
{
return [$this->a | ction compile(Compiler $compiler): void
{
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/NameNode.php",
"language": "php",
"file_size": 942,
"cut_index": 606,
"middle_length": 52
} |
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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/... | (')
->compile($this->nodes['expr2'])
->raw('))')
;
}
public function evaluate(array $functions, array $values): mixed
{
if ($this->nodes['expr1'] instanceof GetAttrNode) {
$this->addNullCoale | construct(['expr1' => $expr1, 'expr2' => $expr2]);
}
public function compile(Compiler $compiler): void
{
$compiler
->raw('((')
->compile($this->nodes['expr1'])
->raw(') ?? | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/NullCoalesceNode.php",
"language": "php",
"file_size": 1690,
"cut_index": 537,
"middle_length": 229
} |
/*
* 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.
*/
if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the com... | Collisions of character operators:
// - an operator that begins with a character must have a space or a parenthesis before or starting at the beginning of a string
// - an operator that ends with a character must be followed by a whitespace or a pa | ontains', 'starts with', 'ends with', 'matches', '**', '<<', '>>'];
$operators = array_combine($operators, array_map('strlen', $operators));
arsort($operators);
$regex = [];
foreach ($operators as $operator => $length) {
// | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php",
"language": "php",
"file_size": 1228,
"cut_index": 518,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Test class for Event.
*/
class GenericE... | * Tests Event->getArgs().
*/
public function testGetArguments()
{
// test getting all
$this->assertSame(['name' => 'Event'], $this->event->getArguments());
}
public function testSetArguments()
{
$result | ->event = new GenericEvent($this->subject, ['name' => 'Event']);
}
public function testConstruct()
{
$this->assertEquals($this->event, new GenericEvent($this->subject, ['name' => 'Event']));
}
/**
| {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php",
"language": "php",
"file_size": 3197,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher\Tests\Debug;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\Debug\Wra... | w WrappedListener($listener, null, new Stopwatch(), new EventDispatcher());
$this->assertStringMatchesFormat($expected, $wrappedListener->getPretty());
}
public static function provideListenersToDescribe()
{
return [
| onent\Stopwatch\StopwatchEvent;
class WrappedListenerTest extends TestCase
{
#[DataProvider('provideListenersToDescribe')]
public function testListenerDescription($listener, $expected)
{
$wrappedListener = ne | {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php",
"language": "php",
"file_size": 3231,
"cut_index": 614,
"middle_length": 229
} |
\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
use Symfony\Component\EventDispatcher\DependencyInjection\Register... | UnionTypeListener;
class RegisterListenersPassTest extends TestCase
{
/**
* Tests that event subscribers not implementing EventSubscriberInterface
* trigger an exception.
*/
public function testEventSubscriberWithoutInterface()
| tures\DummyEvent;
use Symfony\Component\EventDispatcher\Tests\Fixtures\TaggedInvokableListener;
use Symfony\Component\EventDispatcher\Tests\Fixtures\TaggedMultiListener;
use Symfony\Component\EventDispatcher\Tests\Fixtures\Tagged | {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php",
"language": "php",
"file_size": 26355,
"cut_index": 1331,
"middle_length": 229
} |
ntDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Contracts\Service\ResetInt... | array $wrappedListeners = [];
private array $orphanedEvents = [];
private array $dispatchDepth = [];
private array $calledListenerInfos = [];
private array $calledOriginalListeners = [];
private string $currentRequestHash = '';
pu | aceableEventDispatcher implements EventDispatcherInterface, ResetInterface
{
/**
* @var \SplObjectStorage<WrappedListener, array{string, string}>|null
*/
private ?\SplObjectStorage $callStack = null;
private | {
"filepath": "src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php",
"language": "php",
"file_size": 13940,
"cut_index": 921,
"middle_length": 229
} |
ge.
*
* (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\EventDispatcher\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInte... | $hotPathEvents
* @param list<string> $noPreloadEvents
*/
public function __construct(
private array $eventAliases = [],
private array $hotPathEvents = [],
private array $noPreloadEvents = [],
) {
| lexander M. Turek <me@derrabus.de>
* @author Nicolas Grekas <p@tchwork.com>
*/
class AddEventAliasesPass implements CompilerPassInterface
{
/**
* @param array<string, string> $eventAliases
* @param list<string> | {
"filepath": "src/Symfony/Component/EventDispatcher/DependencyInjection/AddEventAliasesPass.php",
"language": "php",
"file_size": 2140,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage;
use Symfony\Contracts\Service\ResetInterface;
/**
* Compiles a node to PHP code.
... | string
{
return $this->source;
}
/**
* @return $this
*/
public function reset(): static
{
$this->source = '';
return $this;
}
/**
* Compiles a node.
*
* @return $this
*/
| tions,
) {
}
public function getFunction(string $name): array
{
return $this->functions[$name];
}
/**
* Gets the current PHP code after compilation.
*/
public function getSource(): | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Compiler.php",
"language": "php",
"file_size": 2808,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage;
/**
* Represents a function that can be used in an expression.
*
* A function is defined by two PHP callables. The callables are use... | es as a first argument and the function
* arguments as remaining arguments).
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ExpressionFunction
{
private \Closure $compiler;
private \Closure $evaluator;
/**
* @param string | s the function
* arguments as arguments).
*
* The "evaluator" function is used for expression evaluation and must return
* the value of the function call based on the values defined for the
* expression (it receives the valu | {
"filepath": "src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php",
"language": "php",
"file_size": 3145,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage;
/**
* Lexes an expression.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Lexer
{
/**
* Tokenizes an expressio... | continue;
}
if (preg_match('/
(?(DEFINE)(?P<LNUM>[0-9]+(_[0-9]+)*))
(?:\.(?&LNUM)|(?&LNUM)(?:\.(?!\.)(?&LNUM)?)?)(?:[eE][+-]?(?&LNUM))?/Ax',
$expression, $match, 0, $cursor)
| ion);
$cursor = 0;
$tokens = [];
$brackets = [];
$end = \strlen($expression);
while ($cursor < $end) {
if (' ' == $expression[$cursor]) {
++$cursor;
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Lexer.php",
"language": "php",
"file_size": 4818,
"cut_index": 614,
"middle_length": 229
} |
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\ExpressionLanguage;
use Symfony\Component\ExpressionLanguage\Node... | attacker-controlled bytes here at
* your peril.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SerializedParsedExpression extends ParsedExpression
{
/**
* @param string $expression An expression
* @param string $nodes Th | serialize their own ParsedExpression
* instances and to keep the resulting bytes under their control. This class
* does NOT validate the unserialize() allow-list and will instantiate any
* class referenced by the payload. Pass | {
"filepath": "src/Symfony/Component/ExpressionLanguage/SerializedParsedExpression.php",
"language": "php",
"file_size": 1296,
"cut_index": 524,
"middle_length": 229
} |
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\ExpressionLanguage;
/**
* Represents a token.
*
* @author Fabi... | ource
*/
public function __construct(
public string $type,
public string|int|float|null $value,
public ?int $cursor,
) {
}
/**
* Returns a string representation of the token.
*/
public function __ | nst STRING_TYPE = 'string';
public const OPERATOR_TYPE = 'operator';
public const PUNCTUATION_TYPE = 'punctuation';
/**
* @param self::*_TYPE $type
* @param int|null $cursor The cursor position in the s | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Token.php",
"language": "php",
"file_size": 1377,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage;
/**
* Represents a token stream.
*
* @author Fabien Potencier <fabien@symfony.com... | /**
* Sets the pointer to the next token and returns the old one.
*/
public function next(): void
{
++$this->position;
if (!isset($this->tokens[$this->position])) {
throw new SyntaxError('Unexpected end of ex | ) {
$this->current = $tokens[0];
}
/**
* Returns a string representation of the token stream.
*/
public function __toString(): string
{
return implode("\n", $this->tokens);
}
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/TokenStream.php",
"language": "php",
"file_size": 2021,
"cut_index": 563,
"middle_length": 229
} |
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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage... | ->compile($this->nodes['expr1'])
->raw(') ? (')
->compile($this->nodes['expr2'])
->raw(') : (')
->compile($this->nodes['expr3'])
->raw('))')
;
}
public function evaluate( |
{
parent::__construct(
['expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3]
);
}
public function compile(Compiler $compiler): void
{
$compiler
->raw('((')
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php",
"language": "php",
"file_size": 1444,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* Represents a node in... | }
public function __toString(): string
{
$attributes = [];
foreach ($this->attributes as $name => $value) {
$attributes[] = \sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
}
| y of nodes
* @param array $attributes An array of attributes
*/
public function __construct(array $nodes = [], array $attributes = [])
{
$this->nodes = $nodes;
$this->attributes = $attributes;
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/Node.php",
"language": "php",
"file_size": 2789,
"cut_index": 563,
"middle_length": 229
} |
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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/... |
}
public function compile(Compiler $compiler): void
{
$compiler
->raw('(')
->raw(self::OPERATORS[$this->attributes['operator']])
->compile($this->nodes['node'])
->raw(')')
;
| '+',
'-' => '-',
'~' => '~',
];
public function __construct(string $operator, Node $node)
{
parent::__construct(
['node' => $node],
['operator' => $operator]
); | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php",
"language": "php",
"file_size": 1513,
"cut_index": 537,
"middle_length": 229
} |
{
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
$tdispatcher->addListener('foo', $listener = static function () {});
$listeners = $dispatcher->getListeners('foo');
$this->assertCount(1, $listeners);
$... | );
$this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo'));
}
public function testHasListeners()
{
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatc | testGetListeners()
{
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
$tdispatcher->addListener('foo', $listener = static function () {} | {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php",
"language": "php",
"file_size": 18673,
"cut_index": 1331,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher\Debug;
use Psr\EventDispatcher\StoppableEventInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Compone... | vate ClassStub|string $stub;
private static bool $hasClassStub;
public function __construct(
callable|array $listener,
?string $name,
private Stopwatch $stopwatch,
private ?EventDispatcherInterface $dispatcher = nul | t $listener;
private ?\Closure $optimizedListener;
private string $name;
private bool $called = false;
private bool $stoppedPropagation = false;
private string $pretty;
private string $callableRef;
pri | {
"filepath": "src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php",
"language": "php",
"file_size": 4599,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\ExpressionLanguage;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
// Help opcache.preload discover always-needed symbols
class_exists(ParsedExpression::class);
/**
* Allows to compile and evaluate expressions wri... | e = null, iterable $providers = [])
{
$this->cache = $cache ?? new ArrayAdapter();
$this->registerFunctions();
foreach ($providers as $provider) {
$this->registerProvider($provider);
}
}
/**
* C | $parser;
private Compiler $compiler;
protected array $functions = [];
/**
* @param iterable<ExpressionFunctionProviderInterface> $providers
*/
public function __construct(?CacheItemPoolInterface $cach | {
"filepath": "src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php",
"language": "php",
"file_size": 5681,
"cut_index": 716,
"middle_length": 229
} |
rivate array $binaryOperators;
private array $names;
private int $flags = 0;
public function __construct(
private array $functions,
) {
$this->unaryOperators = [
'not' => ['precedence' => 50],
'!' => ['precedence' => 50],
'-' => ['precedence' => 500],... | associativity' => self::OPERATOR_LEFT],
'&&' => ['precedence' => 15, 'associativity' => self::OPERATOR_LEFT],
'|' => ['precedence' => 16, 'associativity' => self::OPERATOR_LEFT],
'^' => ['precedence' => 17, 'associativit | elf::OPERATOR_LEFT],
'||' => ['precedence' => 10, 'associativity' => self::OPERATOR_LEFT],
'xor' => ['precedence' => 12, 'associativity' => self::OPERATOR_LEFT],
'and' => ['precedence' => 15, ' | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Parser.php",
"language": "php",
"file_size": 18926,
"cut_index": 1331,
"middle_length": 229
} |
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\ExpressionLanguage;
class SyntaxError extends \LogicException
{
... | roposals) {
$minScore = \INF;
foreach ($proposals as $proposal) {
$distance = levenshtein($subject, $proposal);
if ($distance < $minScore) {
$guess = $proposal;
| on %d', rtrim($message, '.'), $cursor);
if ($expression) {
$message = \sprintf('%s for expression `%s`', $message, $expression);
}
$message .= '.';
if (null !== $subject && null !== $p | {
"filepath": "src/Symfony/Component/ExpressionLanguage/SyntaxError.php",
"language": "php",
"file_size": 1257,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Fabien Poten... | unction compile(Compiler $compiler): void
{
$compiler->raw('[');
$this->compileArguments($compiler);
$compiler->raw(']');
}
public function evaluate(array $functions, array $values): array
{
$result = [];
| ction addElement(Node $value, ?Node $key = null): void
{
$key ??= new ConstantNode(++$this->index);
array_push($this->nodes, $key, $value);
}
/**
* Compiles the node to PHP.
*/
public f | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/ArrayNode.php",
"language": "php",
"file_size": 2761,
"cut_index": 563,
"middle_length": 229
} |
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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/... | >nodes as $node) {
$arguments[] = $compiler->subcompile($node);
}
$function = $compiler->getFunction($this->attributes['name']);
$compiler->raw($function['compiler'](...$arguments));
}
public function evaluate | _construct(
['arguments' => $arguments],
['name' => $name]
);
}
public function compile(Compiler $compiler): void
{
$arguments = [];
foreach ($this->nodes['arguments']- | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php",
"language": "php",
"file_size": 1651,
"cut_index": 537,
"middle_length": 229
} |
* 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\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguag... | public function toArray(): array
{
$array = [];
foreach ($this->getKeyValuePairs() as $pair) {
$array[] = $pair['value'];
$array[] = ', ';
}
array_pop($array);
return $array;
}
} | $this->compileArguments($compiler, false);
}
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/ArgumentsNode.php",
"language": "php",
"file_size": 832,
"cut_index": 523,
"middle_length": 52
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Adam Kiss <hello@adamkiss.com>
*
* @internal
*/
clas... | $compiler->raw('$'.$this->attributes['name'].' ?? null');
}
public function evaluate(array $functions, array $values): null
{
return null;
}
public function toArray(): array
{
return [$this->attributes['nam | ic function compile(Compiler $compiler): void
{
| {
"filepath": "src/Symfony/Component/ExpressionLanguage/Node/NullCoalescedNameNode.php",
"language": "php",
"file_size": 939,
"cut_index": 606,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDi... | face::class);
$dispatcher = new ImmutableEventDispatcher($innerDispatcher);
$event = new Event();
$resultEvent = new Event();
$innerDispatcher->expects($this->once())
->method('dispatch')
->with($ev |
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ImmutableEventDispatcherTest extends TestCase
{
public function testDispatchDelegates()
{
$innerDispatcher = $this->createMock(EventDispatcherInter | {
"filepath": "src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php",
"language": "php",
"file_size": 3303,
"cut_index": 614,
"middle_length": 229
} |
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\ExpressionLanguage\Tests\Node;
use Symfony\Component\ExpressionLanguage\Node\C... | ew ConstantNode(true))],
[-6, new UnaryNode('~', new ConstantNode(5))],
];
}
public static function getCompileData(): array
{
return [
['(-1)', new UnaryNode('-', new ConstantNode(1))],
['(+3 | rn [
[-1, new UnaryNode('-', new ConstantNode(1))],
[3, new UnaryNode('+', new ConstantNode(3))],
[false, new UnaryNode('!', new ConstantNode(true))],
[false, new UnaryNode('not', n | {
"filepath": "src/Symfony/Component/ExpressionLanguage/Tests/Node/UnaryNodeTest.php",
"language": "php",
"file_size": 1715,
"cut_index": 537,
"middle_length": 229
} |
$baseHref ?: $uri;
$this->cachedNamespaces = new \ArrayObject();
$this->add($node);
}
/**
* Returns the current URI.
*/
public function getUri(): ?string
{
return $this->uri;
}
/**
* Returns base href.
*/
public function getBaseHref(): ?string
... |
*
* @param \DOMNodeList<\DOMNode>|\DOMNode|\DOMNode[]|string|null $node
*/
public function add(\DOMNodeList|\DOMNode|array|string|null $node): void
{
if ($node instanceof \DOMNodeList) {
$this->addNodeList($node) | $this->cachedNamespaces = new \ArrayObject();
}
/**
* Adds a node to the current list of nodes.
*
* This method uses the appropriate specialized add*() method based
* on the type of the argument. | {
"filepath": "src/Symfony/Component/DomCrawler/Crawler.php",
"language": "php",
"file_size": 38991,
"cut_index": 2151,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DomCrawler;
use Symfony\Component\DomCrawler\Field\FormField;
/**
* This is an internal class that must not be used directly.
*
* @internal
*/
class F... | shift($segments);
if ('' === $path) {
$target = &$target[];
} else {
$target = &$target[$path];
}
}
$target = $field;
}
/**
* Removes a field based on the ful | $segments = $this->getSegments($field->getName());
$target = &$this->fields;
while ($segments) {
if (!\is_array($target)) {
$target = [];
}
$path = array_ | {
"filepath": "src/Symfony/Component/DomCrawler/FormFieldRegistry.php",
"language": "php",
"file_size": 4975,
"cut_index": 614,
"middle_length": 229
} |
he 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\DomCrawler;
/**
* Image represents an HTML image (an HTML img tag).
*/
class Image ext... | >node->getAttribute('src');
}
protected function setNode(\DOMElement $node): void
{
if ('img' !== $node->nodeName) {
throw new \LogicException(\sprintf('Unable to visualize a "%s" tag.', $node->nodeName));
}
| tion getRawUri(): string
{
return $this- | {
"filepath": "src/Symfony/Component/DomCrawler/Image.php",
"language": "php",
"file_size": 886,
"cut_index": 547,
"middle_length": 52
} |
or radio inputs.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ChoiceFormField extends FormField
{
private string $type;
private bool $multiple;
private array $options;
private bool $validationDisabled = false;
/**
* Returns true if the field should be included in the submitte... | d option is disabled.
*/
public function isDisabled(): bool
{
if ('checkbox' === $this->type) {
return parent::isDisabled();
}
if (parent::isDisabled() && 'select' === $this->type) {
return true | lue for unchecked checkboxes
if (\in_array($this->type, ['checkbox', 'radio'], true) && null === $this->value) {
return false;
}
return true;
}
/**
* Check if the current selecte | {
"filepath": "src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php",
"language": "php",
"file_size": 9615,
"cut_index": 921,
"middle_length": 229
} |
ge.
*
* (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\DomCrawler\Field;
/**
* FormField is the abstract class for all form fields.
*
* @author Fabien Poten... | e = $node->getAttribute('name');
$this->xpath = new \DOMXPath($node->ownerDocument);
$this->initialize();
}
/**
* Returns the label tag associated to the field or null if none.
*/
public function getLabel(): ?\DOMEle | h $xpath;
protected bool $disabled = false;
/**
* @param \DOMElement $node The node associated with this field
*/
public function __construct(
protected \DOMElement $node,
) {
$this->nam | {
"filepath": "src/Symfony/Component/DomCrawler/Field/FormField.php",
"language": "php",
"file_size": 2390,
"cut_index": 563,
"middle_length": 229
} |
n 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\DomCrawler\Field;
/**
* TextareaFormField represents a textarea form field (an HTML textarea tag).
*
* @author Fabien Po... | if ('textarea' !== $this->node->nodeName) {
throw new \LogicException(\sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName));
}
$this->value = '';
foreach ($thi | /
protected function initialize(): void
{
| {
"filepath": "src/Symfony/Component/DomCrawler/Field/TextareaFormField.php",
"language": "php",
"file_size": 986,
"cut_index": 582,
"middle_length": 52
} |
awler->addHtmlContent($this->getDoctype().'<html><div class="foo"></html>', 'UTF-8');
}
public function testAddHtmlContent()
{
$crawler = $this->createCrawler();
$crawler->addHtmlContent($this->getDoctype().'<html><div class="foo"></html>', 'UTF-8');
$this->assertEquals('foo', $cra... | Path('//base')->attr('href'), '->addHtmlContent() adds nodes from an HTML string');
$this->assertEquals('http://symfony.com/contact', $crawler->filterXPath('//a')->link()->getUri(), '->addHtmlContent() adds nodes from an HTML string');
}
# | teCrawler();
$crawler->addHtmlContent($this->getDoctype().'<html><head><base href="http://symfony.com"></head><a href="/contact"></a></html>', 'UTF-8');
$this->assertEquals('http://symfony.com', $crawler->filterX | {
"filepath": "src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php",
"language": "php",
"file_size": 67861,
"cut_index": 3790,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DomCrawler;
/**
* Any HTML element that can link to an URI.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class AbstractUriElement
{
... | on __construct(
\DOMElement $node,
protected ?string $currentUri = null,
?string $method = 'GET',
) {
$this->setNode($node);
$this->method = $method ? strtoupper($method) : null;
$elementUriIsRelative = | ere the link is embedded (or the base href)
* @param string|null $method The method to use for the link (GET by default)
*
* @throws \InvalidArgumentException if the node is not a link
*/
public functi | {
"filepath": "src/Symfony/Component/DomCrawler/AbstractUriElement.php",
"language": "php",
"file_size": 3119,
"cut_index": 614,
"middle_length": 229
} |
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\DomCrawler;
/**
* Link represents an HTML link (an HTML a, area or li... | OMElement $node): void
{
if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) {
throw new \LogicException(\sprintf('Unable to navigate from a "%s" tag.', $node->nodeName));
}
$thi | te('href');
}
protected function setNode(\D | {
"filepath": "src/Symfony/Component/DomCrawler/Link.php",
"language": "php",
"file_size": 862,
"cut_index": 529,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DomCrawler\Field;
/**
* FileFormField represents a file form field (an HTML file input tag).
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class... | rorCode(int $error): void
{
if (!\in_array($error, [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION], true)) {
throw new \I | _SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION)
*
* @throws \InvalidArgumentException When error code doesn't exist
*/
public function setEr | {
"filepath": "src/Symfony/Component/DomCrawler/Field/FileFormField.php",
"language": "php",
"file_size": 3257,
"cut_index": 614,
"middle_length": 229
} |
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\DomCrawler\Field;
/**
* InputFormField represents an input form ... | id
{
if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) {
throw new \LogicException(\sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName));
| encier <fabien@symfony.com>
*/
class InputFormField extends FormField
{
/**
* Initializes the form field.
*
* @throws \LogicException When node type is incorrect
*/
protected function initialize(): vo | {
"filepath": "src/Symfony/Component/DomCrawler/Field/InputFormField.php",
"language": "php",
"file_size": 1418,
"cut_index": 524,
"middle_length": 229
} |
cyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDis... | ublic function setHotPathEvents(array $hotPathEvents): static
{
trigger_deprecation('symfony/event-dispatcher', '8.1', 'The "%s()" method is deprecated, register an "%s" compiler pass with the hot-path events instead.', __METHOD__, AddEventAlia | ents CompilerPassInterface
{
private array $hotPathEvents = [];
private array $noPreloadEvents = [];
/**
* @return $this
*
* @deprecated since Symfony 8.1, use AddEventAliasesPass instead
*/
p | {
"filepath": "src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php",
"language": "php",
"file_size": 10321,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DomCrawler;
/**
* The UriResolver class takes an URI (relative, absolute, fragment, etc.)
* and turns it into an absolute URI against another given base ... | resolve(string $uri, ?string $baseUri): string
{
$uri = trim($uri);
// absolute URL?
if (null !== parse_url(\strlen($uri) !== strcspn($uri, '?#') ? $uri : $uri.'#', \PHP_URL_SCHEME)) {
return $uri;
}
| * For example if $uri=/foo/bar and $baseUri=https://symfony.com it will
* return https://symfony.com/foo/bar
*
* If the $uri is not absolute you must pass an absolute $baseUri
*/
public static function | {
"filepath": "src/Symfony/Component/DomCrawler/UriResolver.php",
"language": "php",
"file_size": 3674,
"cut_index": 614,
"middle_length": 229
} |
try {
new Form($nodes->item(1), 'http://example.com');
$this->fail('__construct() throws a \\LogicException if the input type is not submit, button, or image');
} catch (\LogicException $e) {
$this->assertTrue(true, '__construct() throws a \\LogicException if the input type i... | stor');
}
}
/**
* __construct() should throw a \LogicException if the form attribute is invalid.
*/
#[DataProvider('constructorThrowsExceptionIfNoRelatedFormProvider')]
public function testConstructorThrowsExceptionIfNoRe | s->fail('__construct() throws a \\LogicException if the node has no form ancestor');
} catch (\LogicException $e) {
$this->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ance | {
"filepath": "src/Symfony/Component/DomCrawler/Tests/FormTest.php",
"language": "php",
"file_size": 46469,
"cut_index": 2151,
"middle_length": 229
} |
an HTML form.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Form extends Link implements \ArrayAccess
{
private \DOMElement $button;
private FormFieldRegistry $fields;
/**
* @param \DOMElement $node A \DOMElement instance
* @param string|null $currentUri The URI of the page ... | ?string $currentUri = null,
?string $method = null,
private ?string $baseHref = null,
) {
parent::__construct($node, $currentUri, $method);
$this->initialize();
}
/**
* Gets the form node associated with | he URI of the <base> used for relative links, but not for empty action
*
* @throws \LogicException if the node is not a button inside a form tag
*/
public function __construct(
\DOMElement $node,
| {
"filepath": "src/Symfony/Component/DomCrawler/Form.php",
"language": "php",
"file_size": 15254,
"cut_index": 921,
"middle_length": 229
} |
/*
* 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\DomCrawler\Test\Constraint;
use PHPUnit\Framework\Constrain... | aram Crawler $crawler
*/
protected function matches($crawler): bool
{
$crawler = $crawler->filter($this->selector);
if (!\count($crawler)) {
return false;
}
return $this->expectedText === trim($craw | vate string $expectedText,
) {
}
public function toString(): string
{
return \sprintf('has a node matching selector "%s" with content "%s"', $this->selector, $this->expectedText);
}
/**
* @p | {
"filepath": "src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextSame.php",
"language": "php",
"file_size": 1204,
"cut_index": 518,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Exception;
/**
* Exception class for when a resource cannot be loaded or imported.
*
* @author Ryan Weaver <ryan@thatsquality.com>
*/
class Load... | */
public function __construct(mixed $resource, ?string $sourceResource = null, int $code = 0, ?\Throwable $previous = null, ?string $type = null)
{
if (!\is_string($resource)) {
try {
$resource = json_encod | source importing the new resource
* @param int $code The error code
* @param \Throwable|null $previous A previous exception
* @param string|null $type The type of resource
| {
"filepath": "src/Symfony/Component/Config/Exception/LoaderLoadException.php",
"language": "php",
"file_size": 4031,
"cut_index": 614,
"middle_length": 229
} |
use Symfony\Component\Filesystem\Filesystem;
/**
* XMLUtils is a bunch of utility methods to XML operations.
*
* This class contains static methods only and is not meant to be instantiated.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Martin Hasoň <martin.hason@gmail.com>
* @author Ole Rößner <o... | hen parsing of XML file returns error
* @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself
* @throws \RuntimeException When DOM extension is missing
*/
public | * @param string $content An XML string
* @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation
*
* @throws XmlParsingException W | {
"filepath": "src/Symfony/Component/Config/Util/XmlUtils.php",
"language": "php",
"file_size": 9436,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Config\Resource;
/**
* ClassExistenceResource represents a class existence.
* Freshness is only evaluated against resource existence.
*
* The resource must be a fully-qualified class name.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final... | /
public function __construct(
private string $resource,
?bool $exists = null,
) {
if (null !== $exists) {
$this->exists = [$exists, null];
}
}
public function __toString(): string
{
| edClass = null;
private static array $existsCache = [];
/**
* @param string $resource The fully-qualified class name
* @param bool|null $exists Boolean when the existence check has already been done
* | {
"filepath": "src/Symfony/Component/Config/Resource/ClassExistenceResource.php",
"language": "php",
"file_size": 7058,
"cut_index": 716,
"middle_length": 229
} |
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\Config\Resource;
/**
* ComposerResource tracks the PHP version and Composer d... |
}
public function __toString(): string
{
return __CLASS__;
}
public function isFresh(int $timestamp): bool
{
self::refresh();
return array_values(self::$runtimeVendors) === array_values($this->vendors);
| ay $runtimeVendors;
public function __construct()
{
self::refresh();
$this->vendors = self::$runtimeVendors;
}
public function getVendors(): array
{
return array_keys($this->vendors); | {
"filepath": "src/Symfony/Component/Config/Resource/ComposerResource.php",
"language": "php",
"file_size": 1688,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (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\Config\Resource;
/**
* DirectoryResource represents a resources stored in a subdirectory tree.
*
* @a... |
private ?string $pattern = null,
) {
$resolvedResource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
if (false === $resolvedResource || !is_dir($resolvedResource)) {
throw new \InvalidArgum | $resource The file path to the resource
* @param string|null $pattern A pattern to restrict monitored files
*
* @throws \InvalidArgumentException
*/
public function __construct(
string $resource, | {
"filepath": "src/Symfony/Component/Config/Resource/DirectoryResource.php",
"language": "php",
"file_size": 2876,
"cut_index": 563,
"middle_length": 229
} |
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\Config\Resource;
/**
* FileExistenceResource represents a resour... | unction __construct(
private string $resource,
) {
$this->exists = file_exists($resource);
}
public function __toString(): string
{
return 'existence.'.$this->resource;
}
public function getResource(): stri | henri.bruyand@gmail.com>
*
* @final
*/
class FileExistenceResource implements SelfCheckingResourceInterface
{
private bool $exists;
/**
* @param string $resource The file path to the resource
*/
public f | {
"filepath": "src/Symfony/Component/Config/Resource/FileExistenceResource.php",
"language": "php",
"file_size": 1348,
"cut_index": 524,
"middle_length": 229
} |
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\Config\Resource;
/**
* FileResource represents a resource stored on the files... | rce = realpath($resource) ?: (file_exists($resource) ? $resource : false);
if (false === $resolvedResource) {
throw new \InvalidArgumentException(\sprintf('The file "%s" does not exist.', $resource));
}
$this->resource | rivate string $resource;
/**
* @param string $resource The file path to the resource
*
* @throws \InvalidArgumentException
*/
public function __construct(string $resource)
{
$resolvedResou | {
"filepath": "src/Symfony/Component/Config/Resource/FileResource.php",
"language": "php",
"file_size": 1591,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Config\Resource;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\Glob;
/**
* GlobResource represents a set of resources stored on the filesystem.
*
* Only existence/removal is tracked (not mtimes.)
*
* @author Nicolas Grekas <p@tchwo... | ve Whether directories should be scanned recursively or not
*
* @throws \InvalidArgumentException
*/
public function __construct(
string $prefix,
private string $pattern,
private bool $recursive,
private b | ;
private string $hash;
private array $excludedPrefixes;
private int $globBrace;
/**
* @param string $prefix A directory prefix
* @param string $pattern A glob pattern
* @param bool $recursi | {
"filepath": "src/Symfony/Component/Config/Resource/GlobResource.php",
"language": "php",
"file_size": 9049,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Config\Resource;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormTypeExtensionInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @final
*/... | dedVendors;
}
public function isFresh(int $timestamp): bool
{
if (!isset($this->hash)) {
$this->hash = $this->computeHash();
$this->loadFiles($this->classReflector);
}
foreach ($this->files as $ | ing $hash;
public function __construct(
private \ReflectionClass $classReflector,
array $excludedVendors = [],
) {
$this->className = $classReflector->name;
$this->excludedVendors = $exclu | {
"filepath": "src/Symfony/Component/Config/Resource/ReflectionClassResource.php",
"language": "php",
"file_size": 7410,
"cut_index": 716,
"middle_length": 229
} |
n 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\Config\Resource;
/**
* ResourceInterface is the interface that must be implemented by all Resource classes.
*
* @author ... | by means
* of array_unique(). The string returned need not have a particular meaning, but has
* to be identical for different ResourceInterface instances referring to the same
* resource; and it should be unlikely to collide with that of ot | ry to allow for resource de-duplication, for example | {
"filepath": "src/Symfony/Component/Config/Resource/ResourceInterface.php",
"language": "php",
"file_size": 984,
"cut_index": 582,
"middle_length": 52
} |
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\Config\Resource;
use Symfony\Component\Config\ResourceCheckerInte... | tions. For example, when using the full stack framework, the router
// and the container have their own cache. But they may check the very same
// resources
private static array $cache = [];
public function supports(ResourceInterface $meta | validating them.
*
* @author Matthias Pigulla <mp@webfactory.de>
*/
class SelfCheckingResourceChecker implements ResourceCheckerInterface
{
// Common shared cache, because this checker can be used in different
// situa | {
"filepath": "src/Symfony/Component/Config/Resource/SelfCheckingResourceChecker.php",
"language": "php",
"file_size": 1374,
"cut_index": 524,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.