prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
'int' => 2,
'false' => false,
'true' => true,
'int_one' => 1,
'string_one' => '1',
];
// Check that true and false are appropriately handled
$this->assertSame($csv = <<<'CSV'
string,int,false,true,int_one,string_one
fo... | eQuotesAndSlashes()
{
$this->assertSame($csv = <<<'CSV'
0,1,2,3,4,5
,"""","foo""","\""",\,foo\
CSV,
$this->encoder->encode($data = ['', '"', 'foo"', '\\"', '\\', 'foo\\'], 'csv')
);
| se' => '0',
'true' => '1',
'int_one' => '1',
'string_one' => '1',
], $this->encoder->decode($csv, 'csv', [CsvEncoder::AS_COLLECTION_KEY => false]));
}
public function testDoubl | {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php",
"language": "php",
"file_size": 20251,
"cut_index": 1331,
"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\Serializer\Tests\Encoder;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;... | is->decode->supportsDecoding(JsonEncoder::FORMAT));
$this->assertFalse($this->decode->supportsDecoding('foobar'));
}
#[DataProvider('decodeProvider')]
public function testDecode($toDecode, $expected, $context)
{
$this->asse | deTest extends TestCase
{
private JsonDecode $decode;
protected function setUp(): void
{
$this->decode = new JsonDecode();
}
public function testSupportsDecoding()
{
$this->assertTrue($th | {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php",
"language": "php",
"file_size": 2293,
"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\Serializer\Tests\Encoder;
use PHPUnit\Framework\Attributes\DataProvider;
use P... | $this->assertTrue($this->encode->supportsEncoding(JsonEncoder::FORMAT));
$this->assertFalse($this->encode->supportsEncoding('foobar'));
}
#[DataProvider('encodeProvider')]
public function testEncode($toEncode, $expected, $context) | Exception;
class JsonEncodeTest extends TestCase
{
private JsonEncode $encode;
protected function setUp(): void
{
$this->encode = new JsonEncode();
}
public function testSupportsEncoding()
{
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php",
"language": "php",
"file_size": 1659,
"cut_index": 537,
"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\Serializer\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Exception\... | Encoder()]);
}
public function testEncodeScalar()
{
$obj = new \stdClass();
$obj->foo = 'foo';
$expected = '{"foo":"foo"}';
$this->assertEquals($expected, $this->encoder->encode($obj, 'json'));
}
publ | ncoder $encoder;
private Serializer $serializer;
protected function setUp(): void
{
$this->encoder = new JsonEncoder();
$this->serializer = new Serializer([new CustomNormalizer()], ['json' => new Json | {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php",
"language": "php",
"file_size": 4024,
"cut_index": 614,
"middle_length": 229
} |
#[DataProvider('validEncodeProvider')]
public function testEncode(string $expected, mixed $data, array $context = [])
{
$this->assertSame($expected, $this->encoder->encode($data, 'xml', $context));
}
/**
* @return iterable<array{0: string, 1: mixed, 2?: array}>
*/
public static fu... | ayObject(['foo' => 'bar']),
];
yield 'encode empty array object' => [
'<?xml version="1.0"?>'."\n".'<response/>'."\n",
new \ArrayObject(),
];
$obj = new ScalarDummy();
$obj->xmlFoo = [
| .'<response>foo</response>'."\n",
$obj,
];
yield 'encode array object' => [
'<?xml version="1.0"?>'."\n"
.'<response><foo>bar</foo></response>'."\n",
new \Arr | {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php",
"language": "php",
"file_size": 37324,
"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\Serializer\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Encoder\YamlEncoder;
use Symfony\Component\Serializer\Exception\... | $encoder->encode(new \ArrayObject(['foo' => 1]), 'yaml'));
$this->assertEquals('{ foo: 1 }', $encoder->encode(new \ArrayObject(['foo' => 1]), 'yaml', ['preserve_empty_objects' => true]));
}
public function testSupportsEncoding()
{
| {
$encoder = new YamlEncoder();
$this->assertEquals('foo', $encoder->encode('foo', 'yaml'));
$this->assertEquals('{ foo: 1 }', $encoder->encode(['foo' => 1], 'yaml'));
$this->assertEquals('null', | {
"filepath": "src/Symfony/Component/Serializer/Tests/Encoder/YamlEncoderTest.php",
"language": "php",
"file_size": 3491,
"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\Serializer\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Ser... | ess($container);
$this->expectNotToPerformAssertions();
}
public function testProcessWithAttributeLoaderButNoTaggedServices()
{
$container = new ContainerBuilder();
$container->register('serializer.mapping.attribute_lo | eMetadataPassTest extends TestCase
{
public function testProcessWithNoAttributeLoader()
{
$container = new ContainerBuilder();
// Should not throw any exception
(new AttributeMetadataPass())->proc | {
"filepath": "src/Symfony/Component/Serializer/Tests/DependencyInjection/AttributeMetadataPassTest.php",
"language": "php",
"file_size": 4372,
"cut_index": 614,
"middle_length": 229
} |
endencyInjection\SerializerPass;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
/**
* Tests for the SerializerPass cl... | $this->expectExceptionMessage('You must tag at least one service as "serializer.normalizer" to use the "serializer" service');
$serializerPass->process($container);
}
public function testThrowExceptionWhenNoEncoders()
{
| ntainerBuilder();
$container->setParameter('kernel.debug', false);
$container->register('serializer');
$serializerPass = new SerializerPass();
$this->expectException(\RuntimeException::class);
| {
"filepath": "src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php",
"language": "php",
"file_size": 33155,
"cut_index": 1331,
"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\Serializer\Tests\Extractor;
use PHPUnit\Framework\TestCase;
use Symfony\Compon... | rtyListExtractorInterface::class);
$propertyListExtractor->expects($this->once())
->method('getProperties')
->with($object::class, $context)
->willReturn($properties);
$this->assertSame(
$pro | nction testGetPropertiesWithoutObjectClassResolver()
{
$object = new \stdClass();
$context = ['bar' => true];
$properties = ['prop1', 'prop2'];
$propertyListExtractor = $this->createMock(Prope | {
"filepath": "src/Symfony/Component/Serializer/Tests/Extractor/ObjectPropertyListExtractorTest.php",
"language": "php",
"file_size": 1949,
"cut_index": 537,
"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\Serializer\Debug;
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Sy... | SerializerAwareInterface
{
public function __construct(
private EncoderInterface|DecoderInterface $encoder,
private SerializerDataCollector $dataCollector,
private readonly string $serializerName = 'default',
) {
}
| y\Component\Serializer\SerializerInterface;
/**
* Collects some data about encoding.
*
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
*
* @final
*/
class TraceableEncoder implements EncoderInterface, DecoderInterface, | {
"filepath": "src/Symfony/Component/Serializer/Debug/TraceableEncoder.php",
"language": "php",
"file_size": 3649,
"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\Serializer\Debug;
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInte... | com>
*
* @final
*/
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface
{
public function __construct(
private NormalizerInterface|Den | alizerInterface;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerInterface;
/**
* Collects some data about normalization.
*
* @author Mathias Arlaud <mathias.arlaud@gmail. | {
"filepath": "src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php",
"language": "php",
"file_size": 4610,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\Debug;
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Normalizer\Denor... | RACE_ID = 'debug_trace_id';
public function __construct(
private SerializerInterface&NormalizerInterface&DenormalizerInterface&EncoderInterface&DecoderInterface $serializer,
private SerializerDataCollector $dataCollector,
priva | author Mathias Arlaud <mathias.arlaud@gmail.com>
*
* @final
*/
class TraceableSerializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
{
public const DEBUG_T | {
"filepath": "src/Symfony/Component/Serializer/Debug/TraceableSerializer.php",
"language": "php",
"file_size": 6674,
"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\Serializer\NameConverter;
use Symfony\Component\Serializer\Exception\UnexpectedPropertyException;
/**
... | |null $attributes The list of attributes to rename or null for all attributes
* @param bool $lowerCamelCase Use lowerCamelCase style
*/
public function __construct(
private ?array $attributes = null,
private bool | rter implements NameConverterInterface
{
/**
* Require all properties to be written in snake_case.
*/
public const REQUIRE_SNAKE_CASE_PROPERTIES = 'require_snake_case_properties';
/**
* @param string[] | {
"filepath": "src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php",
"language": "php",
"file_size": 2663,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\NameConverter;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
/**
* @author Fabien Bouri... | private static array $attributesMetadataCache = [];
public function __construct(
private readonly ClassMetadataFactoryInterface $metadataFactory,
private readonly ?NameConverterInterface $fallbackNameConverter = null,
) {
}
| ate static array $normalizeCache = [];
/**
* @var array<string, array<string, string|null>>
*/
private static array $denormalizeCache = [];
/**
* @var array<string, array<string, string>>
*/
| {
"filepath": "src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php",
"language": "php",
"file_size": 6093,
"cut_index": 716,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\NameConverter;
/**
* Defines the interface... |
* Converts a property name to its denormalized value.
*
* @param class-string|null $class
* @param array<string, mixed> $context
*/
public function denormalize(string $propertyName, ?string $class = null, ?string $format = | * @param class-string|null $class
* @param array<string, mixed> $context
*/
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
/** | {
"filepath": "src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php",
"language": "php",
"file_size": 1037,
"cut_index": 513,
"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\Serializer\NameConverter;
use Symfony\Component\Serializer\Exception\UnexpectedPropertyException;
/**
... | null for all attributes
* @param bool $lowerCamelCase Use lowerCamelCase style
*/
public function __construct(
private readonly ?array $attributes = null,
private readonly bool $lowerCamelCase = true,
) {
}
| equire all properties to be written in camelCase.
*/
public const REQUIRE_CAMEL_CASE_PROPERTIES = 'require_camel_case_properties';
/**
* @param string[]|null $attributes The list of attributes to rename or | {
"filepath": "src/Symfony/Component/Serializer/NameConverter/SnakeCaseToCamelCaseNameConverter.php",
"language": "php",
"file_size": 2460,
"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\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\RuntimeException;
/**
* Decoder delegat... | ders
*/
public function __construct(
private readonly array $decoders = [],
) {
}
final public function decode(string $data, string $format, array $context = []): mixed
{
return $this->getDecoder($format, $context) | org>
*
* @final
*/
class ChainDecoder implements ContextAwareDecoderInterface
{
/**
* @var array<string, array-key>
*/
private array $decoderByFormat = [];
/**
* @param array<DecoderInterface> $deco | {
"filepath": "src/Symfony/Component/Serializer/Encoder/ChainDecoder.php",
"language": "php",
"file_size": 2259,
"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\Serializer\Encoder;
use Symfony\Component\Serializer\Debug\TraceableEncoder;
use Symfony\Component\Seria... | [];
/**
* @param array<EncoderInterface> $encoders
*/
public function __construct(
private readonly array $encoders = [],
) {
}
final public function encode(mixed $data, string $format, array $context = []): string
| mail.com>
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*
* @final
*/
class ChainEncoder implements ContextAwareEncoderInterface
{
/**
* @var array<string, array-key>
*/
private array $encoderByFormat = | {
"filepath": "src/Symfony/Component/Serializer/Encoder/ChainEncoder.php",
"language": "php",
"file_size": 2912,
"cut_index": 563,
"middle_length": 229
} |
ValueException;
/**
* Encodes CSV data.
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Oliver Hoff <oliver@hofff.com>
*/
class CsvEncoder implements EncoderInterface, DecoderInterface
{
public const FORMAT = 'csv';
public const DELIMITER_KEY = 'csv_delimiter';
public const ENCLOSURE_KEY = 'cs... | \xEF\xBB\xBF";
private const FORMULAS_START_CHARACTERS = ['=', '-', '+', '@', "\t", "\r", "\n"];
private array $defaultContext = [
self::DELIMITER_KEY => ',',
self::ENCLOSURE_KEY => '"',
self::END_OF_LINE => "\n",
| onst AS_COLLECTION_KEY = 'as_collection';
public const NO_HEADERS_KEY = 'no_headers';
public const END_OF_LINE = 'csv_end_of_line';
public const OUTPUT_UTF8_BOM_KEY = 'output_utf8_bom';
private const UTF8_BOM = " | {
"filepath": "src/Symfony/Component/Serializer/Encoder/CsvEncoder.php",
"language": "php",
"file_size": 9906,
"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\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\Un... | data is in; valid values
* depend on the specific implementation. Authors implementing this interface
* are encouraged to document which formats they support in a non-inherited
* phpdoc comment.
*
* @throws UnexpectedValueException | $data Data to decode
* @param string $format Format name
* @param array<string, mixed> $context Options that decoders have access to
*
* The format parameter specifies which format the | {
"filepath": "src/Symfony/Component/Serializer/Encoder/DecoderInterface.php",
"language": "php",
"file_size": 1300,
"cut_index": 524,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Encoder;
use Symfony\Component\Serializer\E... | ueException
*/
public function encode(mixed $data, string $format, array $context = []): string;
/**
* Checks whether the serializer can encode to given format.
*
* @param string $format Format name
*/
public function | mixed $data Data to encode
* @param string $format Format name
* @param array<string, mixed> $context Options that normalizers/encoders have access to
*
* @throws UnexpectedVal | {
"filepath": "src/Symfony/Component/Serializer/Encoder/EncoderInterface.php",
"language": "php",
"file_size": 1040,
"cut_index": 513,
"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\Serializer\Encoder;
use Seld\JsonLint\JsonParser;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\E... | json_decode fails.
*/
public const DETAILED_ERROR_MESSAGES = 'json_decode_detailed_errors';
public const OPTIONS = 'json_decode_options';
/**
* Specifies the recursion depth.
*/
public const RECURSION_DEPTH = 'json_decode_ | sult as an associative array, false for a nested stdClass hierarchy.
*/
public const ASSOCIATIVE = 'json_decode_associative';
/**
* True to enable seld/jsonlint as a source for more specific error messages when | {
"filepath": "src/Symfony/Component/Serializer/Encoder/JsonDecode.php",
"language": "php",
"file_size": 4295,
"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\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\NotEncodableVal... | $this->defaultContext = array_merge($this->defaultContext, $defaultContext);
}
public function encode(mixed $data, string $format, array $context = []): string
{
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS | */
public const OPTIONS = 'json_encode_options';
private array $defaultContext = [
self::OPTIONS => \JSON_PRESERVE_ZERO_FRACTION,
];
public function __construct(array $defaultContext = [])
{
| {
"filepath": "src/Symfony/Component/Serializer/Encoder/JsonEncode.php",
"language": "php",
"file_size": 1682,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\Tests\Normalizer\Features;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Groups;
use Sym... | alizer metadata.
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
trait ContextMetadataTestTrait
{
#[DataProvider('contextMetadataDummyProvider')]
public function testContextMetadataNormalize(string $contextMetadataDummyClass)
| CaseNameConverter;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
/**
* Test context handling from Seri | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ContextMetadataTestTrait.php",
"language": "php",
"file_size": 6187,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;... | $normalizer = $this->getNormalizerForGroups();
$obj = new GroupDummy();
$obj->setFoo('foo');
$obj->setBar('bar');
$obj->setQuux('quux');
$obj->setFooBar('fooBar');
$obj->setSymfony('symfony');
$ | psTestTrait
{
abstract protected function getNormalizerForGroups(): NormalizerInterface;
abstract protected function getDenormalizerForGroups(): DenormalizerInterface;
public function testGroupsNormalize()
{
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/GroupsTestTrait.php",
"language": "php",
"file_size": 2533,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
u... | Dummy();
$level1->bar = 'level1';
$level2 = new MaxDepthDummy();
$level2->bar = 'level2';
$level1->child = $level2;
$level3 = new MaxDepthDummy();
$level3->bar = 'level3';
$level2->child = $level3;
| xDepthTestTrait
{
abstract protected function getNormalizerForMaxDepth(): NormalizerInterface;
public function testMaxDepth()
{
$normalizer = $this->getNormalizerForMaxDepth();
$level1 = new MaxDepth | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/MaxDepthTestTrait.php",
"language": "php",
"file_size": 3001,
"cut_index": 563,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Attribute\Context... | FORMAT_KEY => 'm-d-Y'])]
#[SerializedName('property_with_serialized_name')]
public \DateTimeImmutable $propertyWithSerializedName,
#[Context([DateTimeNormalizer::FORMAT_KEY => 'm-d-Y'])]
public \DateTimeImmutable $propertyW | __construct(
#[Context([DateTimeNormalizer:: | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummyWithContextAttribute.php",
"language": "php",
"file_size": 893,
"cut_index": 547,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\De... | $dummy = new ObjectDummy();
$dummy->bar = 'bar';
$denormalizer = $this->getDenormalizerForObjectToPopulate();
$obj = $denormalizer->denormalize(
['foo' => 'foo'],
ObjectDummy::class,
null,
| ializer\Tests\Fixtures\ToBeProxyfiedDummy;
trait ObjectToPopulateTestTrait
{
abstract protected function getDenormalizerForObjectToPopulate(): DenormalizerInterface;
public function testObjectToPopulate()
{
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectToPopulateTestTrait.php",
"language": "php",
"file_size": 3402,
"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\Serializer\Tests\Normalizer\Features;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Compone... | testSkipUninitializedValues(array $context)
{
$object = new TypedPropertiesObjectWithGetters();
$normalizer = $this->getNormalizerForSkipUninitializedValues();
$result = $normalizer->normalize($object, null, $context);
| ES.
*/
trait SkipUninitializedValuesTestTrait
{
abstract protected function getNormalizerForSkipUninitializedValues(): AbstractObjectNormalizer;
#[DataProvider('skipUninitializedValuesFlagProvider')]
public function | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php",
"language": "php",
"file_size": 2318,
"cut_index": 563,
"middle_length": 229
} |
hp
/*
* 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\Serializer\Tests\Normalizer\Features;
class TypedPropert... | lized(string $initialized): self
{
$this->initialized = $initialized;
return $this;
}
public function getInitialized2(): string
{
return $this->initialized2;
}
public function setInitialized2(string $initi | g $unInitialized): self
{
$this->unInitialized = $unInitialized;
return $this;
}
public function getInitialized(): string
{
return $this->initialized;
}
public function setInitia | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/TypedPropertiesObjectWithGetters.php",
"language": "php",
"file_size": 1097,
"cut_index": 515,
"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\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\S... | nSerializableDummy;
use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait;
/**
* @author Fred Cox <mcfedr@gmail.com>
*/
class JsonSerializableNormalizerTest extends TestCase
{
use CircularReferenceTestTrait;
publ | ny\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\JsonSerializableCircularReferenceDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Jso | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php",
"language": "php",
"file_size": 3830,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\Tests\Normalizer;
use BcMath\Number;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Sy... | mixed $data, bool $expected)
{
$this->assertSame($expected, $this->normalizer->supportsNormalization($data));
}
public static function supportsNormalizationProvider(): iterable
{
if (class_exists(\GMP::class)) {
| berNormalizer $normalizer;
protected function setUp(): void
{
$this->normalizer = new NumberNormalizer();
}
#[DataProvider('supportsNormalizationProvider')]
public function testSupportsNormalization( | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/NumberNormalizerTest.php",
"language": "php",
"file_size": 8157,
"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\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | ractObjectToPopulateReturnsNullWhenNonObjectIsProvided()
{
$object = $this->extractObjectToPopulate(ProxyDummy::class, [
'object_to_populate' => 'not an object',
]);
$this->assertNull($object);
}
public fun |
public function testExtractObjectToPopulateReturnsNullWhenKeyIsMissing()
{
$object = $this->extractObjectToPopulate(ProxyDummy::class, []);
$this->assertNull($object);
}
public function testExt | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/ObjectToPopulateTraitTest.php",
"language": "php",
"file_size": 1614,
"cut_index": 537,
"middle_length": 229
} |
nException;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
use Symfony\... | er\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummyChild;
use Symfony\Component\Serializer\Tests\F | zer;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
use Symfony\Component\Serializ | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php",
"language": "php",
"file_size": 26480,
"cut_index": 1331,
"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\Serializer\Tests\Normalizer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
/**
* Provides a test Normalizer which only imple... | {
}
public function getSupportedTypes(?string $format): array
{
return ['*' => false];
}
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
{
return | ?string $format = null, array $context = []): mixed
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php",
"language": "php",
"file_size": 928,
"cut_index": 606,
"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\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Normalizer... | );
}
public function testSupportsNormalization()
{
$this->assertTrue($this->normalizer->supportsNormalization(new TestMessage()));
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
}
public | ss TranslatableNormalizerTest extends TestCase
{
private readonly TranslatableNormalizer $normalizer;
protected function setUp(): void
{
$this->normalizer = new TranslatableNormalizer(new IdentityTranslator() | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/TranslatableNormalizerTest.php",
"language": "php",
"file_size": 2373,
"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\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Normalizer... | lizer::class));
$this->assertTrue($denormalizer->supportsDenormalization([], 'stdClass', 'any', [UnwrappingDenormalizer::UNWRAP_PATH => '[baz][inner]']));
$this->assertFalse($denormalizer->supportsDenormalization([], 'stdClass', 'any', [Un | com>
*/
class UnwrappingDenormalizerTest extends TestCase
{
public function testSupportsNormalization()
{
$denormalizer = new UnwrappingDenormalizer();
$denormalizer->setSerializer($this->createStub(Seria | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/UnwrappingDenormalizerTest.php",
"language": "php",
"file_size": 2916,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormaliz... | ctAttributesTestTrait
{
/**
* Returns a collection of objects to be normalized and compared with the expected array.
* It is a specific object normalizer test class responsibility to prepare testing data.
*/
abstract protected functi | zed properties.
*
* The attributes cache MUST NOT depend on a specific object state, so that cached attributes could be reused
* while normalizing any number of instances of the same class in any order.
*/
trait CacheableObje | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/CacheableObjectAttributesTestTrait.php",
"language": "php",
"file_size": 2589,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException;
use Symfony\Component\Serializer\Nor... | tructArguments();
$result = $denormalizer->denormalize($data, ConstructorArgumentsObject::class, 'json', [
'default_constructor_arguments' => [
ConstructorArgumentsObject::class => ['foo' => '', 'bar' => '', 'baz' => nu | DenormalizerForConstructArguments(): DenormalizerInterface;
public function testDefaultConstructorArguments()
{
$data = [
'foo' => 10,
];
$denormalizer = $this->getDenormalizerForCons | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php",
"language": "php",
"file_size": 3466,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;... | r = $this->getNormalizerForIgnoredAttributes();
$objectInner = new ObjectInner();
$objectInner->foo = 'innerFoo';
$objectInner->bar = 'innerBar';
$objectOuter = new ObjectOuter();
$objectOuter->foo = 'foo';
| tNormalizerForIgnoredAttributes(): NormalizerInterface;
abstract protected function getDenormalizerForIgnoredAttributes(): DenormalizerInterface;
public function testIgnoredAttributesNormalize()
{
$normalize | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/IgnoredAttributesTestTrait.php",
"language": "php",
"file_size": 3000,
"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\Serializer\Tests\Normalizer\Features;
class ObjectOuter
{
pub... | }
/**
* @return ObjectInner
*/
public function getInner()
{
return $this->inner;
}
public function setInner(ObjectInner $inner)
{
$this->inner = $inner;
}
public function setDate(\DateTimeInte |
}
public function setFoo($foo): void
{
$this->foo = $foo;
}
public function getBar()
{
return $this->bar;
}
public function setBar($bar): void
{
$this->bar = $bar;
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php",
"language": "php",
"file_size": 1302,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Excepti... | terface;
public function testRejectInvalidType()
{
$denormalizer = $this->getDenormalizerForTypeEnforcement();
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('The type of the "date" | es with a denormalizer that is aware of types.
* Covers AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT.
*/
trait TypeEnforcementTestTrait
{
abstract protected function getDenormalizerForTypeEnforcement(): DenormalizerIn | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/TypeEnforcementTestTrait.php",
"language": "php",
"file_size": 2008,
"cut_index": 537,
"middle_length": 229
} |
nt\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
use Symfony\Component\Serializer\Mapping\ClassMeta... | ny\Component\Serializer\Serializer;
class MapDenormalizationTest extends TestCase
{
public function testMapOfStringToNullableObject()
{
$normalizedData = $this->getSerializer()->denormalize([
'map' => [
'assertD | lassMetadataFactoryInterface;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfo | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/MapDenormalizationTest.php",
"language": "php",
"file_size": 9616,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Messenger\Exception\ValidationFailedException as Mess... | er\Serializer;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Exception\ValidationFailedException;
class ProblemNormalizerTest extends TestCase
{
private Pr | nt\Serializer\Exception\PartialDenormalizationException;
use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer;
use Symfony\Component\Serializer\Normalizer\ProblemNormalizer;
use Symfony\Component\Serializ | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/ProblemNormalizerTest.php",
"language": "php",
"file_size": 7558,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Serializer\Tests\Normalizer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Normalizer\UidNormalizer;
use Symfony\Component\Uid\Abstr... | }
public function testSupportsNormalization()
{
$this->assertTrue($this->normalizer->supportsNormalization(Uuid::v1()));
$this->assertTrue($this->normalizer->supportsNormalization(Uuid::v3(Uuid::v1(), 'foo')));
$this->asse | ent\Uid\UuidV5;
use Symfony\Component\Uid\UuidV6;
class UidNormalizerTest extends TestCase
{
private UidNormalizer $normalizer;
protected function setUp(): void
{
$this->normalizer = new UidNormalizer();
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php",
"language": "php",
"file_size": 7721,
"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\Serializer\Tests\Normalizer\Features;
class CallbacksObject
{... |
return $this->bar;
}
public function setBar($bar)
{
$this->bar = $bar;
}
public function getFoo(): ?string
{
return $this->foo;
}
public function setFoo(?string $foo)
{
$this->foo = $f | oo = $foo;
}
public function getBar()
{ | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksObject.php",
"language": "php",
"file_size": 840,
"cut_index": 520,
"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\Serializer\Tests\Normalizer\Features;
use PHPUnit\Framework\Attri... | izer = $this->getNormalizerForFilterBool();
$dummy = $normalizer->denormalize(['value' => $parameterValue], FilterBoolObject::class, context: ['filter_bool' => true]);
$this->assertSame($expectedValue, $dummy->value);
}
public st | tion getNormalizerForFilterBool(): DenormalizerInterface;
#[DataProvider('provideObjectWithBoolArguments')]
public function testObjectWithBoolArguments(?bool $expectedValue, ?string $parameterValue)
{
$normal | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/FilterBoolTestTrait.php",
"language": "php",
"file_size": 1419,
"cut_index": 524,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Normalizer\Normal... | $dummy = new ObjectDummy();
$dummy->bar = 'present';
$normalizer = $this->getNormalizerForSkipNullValues();
$result = $normalizer->normalize($dummy, null, ['skip_null_values' => true]);
$this->assertSame(['fooBar' => | e;
public function testSkipNullValues()
{
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipNullValuesTestTrait.php",
"language": "php",
"file_size": 906,
"cut_index": 547,
"middle_length": 52
} |
myPrivate;
use Symfony\Component\Serializer\Tests\Fixtures\Php80Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder;
use Symfony\Component\Serializer\Tests\Fixtures\StdClassNormalizer;
use Symfony\Component\Serializer\Tests\Fixtures\VoidNeverReturnTypeDummy;
use Symfony\Component\Serializer\Tests\Norma... | ests\Normalizer\Features\ContextMetadataTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer\Features\FilterBoolTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer\Features\GroupsTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer | llbacksTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer\Features\ConstructorArgumentsTestTrait;
use Symfony\Component\Serializer\T | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php",
"language": "php",
"file_size": 71873,
"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\Serializer\Tests\Normalizer\Features;
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
use Symfony\Component\Serializer\Normalizer\Deno... | ze()
{
$normalizer = $this->getNormalizerForAttributes();
$objectInner = new ObjectInner();
$objectInner->foo = 'innerFoo';
$objectInner->bar = 'innerBar';
$objectDummy = new ObjectDummy();
$objectDummy | utesTestTrait
{
abstract protected function getNormalizerForAttributes(): NormalizerInterface;
abstract protected function getDenormalizerForAttributes(): DenormalizerInterface;
public function testAttributesNormali | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/AttributesTestTrait.php",
"language": "php",
"file_size": 3830,
"cut_index": 614,
"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\Serializer\Tests\Dummy;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Grou... | ne
{
#[MaxDepth(1)]
#[Groups(['book:read', 'book:write'])]
#[SerializedName('identifier')]
#[Ignore]
#[Context(
normalizationContext: ['groups' => ['book:read']],
denormalizationContext: ['groups' => ['book:write']],
| ializer\Attribute\SerializedPath;
class DummyClassO | {
"filepath": "src/Symfony/Component/Serializer/Tests/Dummy/DummyClassOne.php",
"language": "php",
"file_size": 985,
"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\Serializer\Tests\Normalizer\Features;
#[\AllowDynamicProperties]
... | {
$this->baz = $baz;
}
public function getFooBar()
{
return $this->foo.$this->bar;
}
public function getCamelCase()
{
return $this->camelCase;
}
public function setCamelCase($camelCase)
{
| ion getFoo()
{
return $this->foo;
}
public function setFoo($foo)
{
$this->foo = $foo;
}
public function isBaz()
{
return $this->baz;
}
public function setBaz($baz)
| {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php",
"language": "php",
"file_size": 1478,
"cut_index": 524,
"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\Serializer\Tests\Normalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* Provides a test Norma... | array|string|int|float|bool|\ArrayObject|null
{
return null;
}
public function getSupportedTypes(?string $format): array
{
return ['*' => false];
}
public function supportsNormalization($data, ?string $format = nul | data, ?string $format = null, array $context = []): | {
"filepath": "src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php",
"language": "php",
"file_size": 955,
"cut_index": 582,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Ansi;
/**
* Tracks active ANSI SGR codes to preserve styling across line breaks.
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class AnsiCodeTracker
{
private bool $bold = false;
private bool ... | escape code and update tracking state.
*/
public function process(string $ansiCode): void
{
// Fast direct parsing: skip regex, extract params between \x1b[ and m
if (\strlen($ansiCode) < 3 || "\x1b" !== $ansiCode[0] || '[' !== | se;
private bool $hidden = false;
private bool $strikethrough = false;
private ?string $fgColor = null;
private ?string $bgColor = null;
private ?string $underlineColor = null;
/**
* Process an ANSI | {
"filepath": "src/Symfony/Component/Tui/Ansi/AnsiCodeTracker.php",
"language": "php",
"file_size": 7861,
"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\Tui\Render;
/**
* Represents the absolute position and size of a... |
* Check if the given screen coordinates are within this rect.
*
* @param int $row 0-indexed row
* @param int $col 0-indexed column
*/
public function contains(int $row, int $col): bool
{
return $row >= $this->row
| om>
*/
final class WidgetRect
{
public function __construct(
public readonly int $row,
public readonly int $col,
public readonly int $columns,
public readonly int $rows,
) {
}
/** | {
"filepath": "src/Symfony/Component/Tui/Render/WidgetRect.php",
"language": "php",
"file_size": 1494,
"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\Tui\Render;
use Symfony\Component\Tui\Style\Style;
use Symfony\Co... | pipeline.
*
* @return string[]
*/
public function renderWidget(AbstractWidget $widget, RenderContext $context): array;
/**
* Resolve the style for a widget by merging cascade layers.
*/
public function resolveStyle(Ab | without creating a circular class dependency.
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface WidgetRendererInterface
{
/**
* Render a single widget through the full | {
"filepath": "src/Symfony/Component/Tui/Render/WidgetRendererInterface.php",
"language": "php",
"file_size": 1394,
"cut_index": 524,
"middle_length": 229
} |
er\RenderContext;
use Symfony\Component\Tui\Style\DefaultStyleSheet;
use Symfony\Component\Tui\Style\Style;
use Symfony\Component\Tui\Style\StyleSheet;
use Symfony\Component\Tui\Tui;
/**
* Base widget class with lifecycle hooks and dirty tracking.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com... | tring<AbstractEvent>, list<callable>> */
private array $listeners = [];
// Render cache: stores the last output of Renderer::renderWidget()
// keyed on (renderRevision, columns, rows) so unchanged widgets
// skip style resolution, layout, | ivate ?WidgetContext $context = null;
private ?Style $internalStyle = null;
private static ?StyleSheet $defaultStyleSheet = null;
/** @var string[] */
private array $styleClasses = [];
/** @var array<class-s | {
"filepath": "src/Symfony/Component/Tui/Widget/AbstractWidget.php",
"language": "php",
"file_size": 12717,
"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\Tui\Widget;
/**
* Handles bracketed paste mode detection and buffering.
*
* Terminals that support bracketed paste wrap pasted text between
* ESC[200~ ... | = false;
private string $pasteBuffer = '';
private function isBufferingPaste(): bool
{
return $this->inPaste;
}
/**
* Process bracketed paste sequences in input data.
*
* Detects paste start/end markers and buff | tencier <fabien@symfony.com>
*/
trait BracketedPasteTrait
{
private const int MAX_PASTE_BYTES = 16 * 1024 * 1024;
private const string PASTE_OVERFLOW_MESSAGE = '[paste exceeded 16 MiB limit]';
private bool $inPaste | {
"filepath": "src/Symfony/Component/Tui/Widget/BracketedPasteTrait.php",
"language": "php",
"file_size": 3492,
"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\Tui\Widget;
use Symfony\Component\Tui\Event\CancelEvent;
use Symfony\Component... | truct($message);
}
/**
* Check if the loader was cancelled.
*/
public function isCancelled(): bool
{
return $this->cancelled;
}
/**
* Reset the cancelled state.
*/
public function reset(): void
| dget implements FocusableInterface
{
use FocusableTrait;
use KeybindingsTrait;
private bool $cancelled = false;
public function __construct(
string $message = 'Loading...',
) {
parent::__cons | {
"filepath": "src/Symfony/Component/Tui/Widget/CancellableLoaderWidget.php",
"language": "php",
"file_size": 1942,
"cut_index": 537,
"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\Tui\Widget;
use Symfony\Component\Tui\Exception\LogicException;
use Symfony\Component\Tui\Render\RenderContext;
/**
* Container widget that groups child ... | Or via stylesheet rules:
*
* $stylesheet->addRule('.panes', new Style(direction: Direction::Horizontal, gap: 2));
*
* Layout and chrome rendering is handled by the Renderer.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
* | * - Vertically expandable children
*
* Layout direction and gap are style properties, configurable via
* stylesheets or inline styles:
*
* $container->setStyle(new Style(direction: Direction::Horizontal, gap: 1));
*
* | {
"filepath": "src/Symfony/Component/Tui/Widget/ContainerWidget.php",
"language": "php",
"file_size": 4836,
"cut_index": 614,
"middle_length": 229
} |
ent;
use Symfony\Component\Tui\Input\Key;
use Symfony\Component\Tui\Input\Keybindings;
use Symfony\Component\Tui\Render\RenderContext;
use Symfony\Component\Tui\Style\CursorShape;
use Symfony\Component\Tui\Widget\Editor\EditorDocument;
use Symfony\Component\Tui\Widget\Editor\EditorRenderer;
use Symfony\Component\Tui\Wi... |
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class EditorWidget extends AbstractWidget implements FocusableInterface, VerticallyExpandableInterface
{
use BracketedPasteTrait;
use FocusableTrait;
use KeybindingsTrait | between collaborators:
* - {@see EditorDocument}: text buffer, cursor, undo/redo, kill ring
* - {@see EditorViewport}: scroll offset, viewport calculations
* - {@see EditorRenderer}: line rendering with cursor and word-wrap
* | {
"filepath": "src/Symfony/Component/Tui/Widget/EditorWidget.php",
"language": "php",
"file_size": 16879,
"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\Tui\Widget;
use Symfony\Component\Tui\Ansi\AnsiUtils;
use Symfony\Component\Tui\Input\Keybindings;
/**
... | ar at the right spot.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface FocusableInterface
{
/**
* Check if the widget currently has focus.
*/
public function isFocused(): bool;
/**
* Set the | o them.
*
* Widgets that display a text cursor should emit
* {@see AnsiUtils::cursorMarker()} at the cursor position when focused
* so the terminal's hardware cursor handles blinking natively and IME
* candidate windows appe | {
"filepath": "src/Symfony/Component/Tui/Widget/FocusableInterface.php",
"language": "php",
"file_size": 2326,
"cut_index": 563,
"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\Tui\Widget;
/**
* Default implementation of focus state for focusable widgets.
*
* Invalidates the widget when focus changes. Override setFocuse... | return $this->focused;
}
/**
* @return $this
*/
public function setFocused(bool $focused): static
{
if ($this->focused !== $focused) {
$this->focused = $focused;
$this->invalidate();
}
| e;
public function isFocused(): bool
{
| {
"filepath": "src/Symfony/Component/Tui/Widget/FocusableTrait.php",
"language": "php",
"file_size": 945,
"cut_index": 606,
"middle_length": 52
} |
;
use Symfony\Component\Tui\Event\SubmitEvent;
use Symfony\Component\Tui\Input\Key;
use Symfony\Component\Tui\Input\Keybindings;
use Symfony\Component\Tui\Render\RenderContext;
use Symfony\Component\Tui\Style\CursorShape;
use Symfony\Component\Tui\Widget\Util\Line;
use Symfony\Component\Tui\Widget\Util\StringUtils;
/*... | ?Keybindings $keybindings = null,
) {
if (null !== $keybindings) {
$this->setKeybindings($keybindings);
}
$this->line = new Line();
}
/**
* @param callable(SubmitEvent): void $callback
*
* @r | Interface
{
use BracketedPasteTrait;
use FocusableTrait;
use KeybindingsTrait;
private Line $line;
private string $prompt = '> ';
private bool $submitted = false;
public function __construct(
| {
"filepath": "src/Symfony/Component/Tui/Widget/InputWidget.php",
"language": "php",
"file_size": 14238,
"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\Tui\Widget;
use Symfony\Component\Tui\Input\Keybindings;
/**
* Default implementation of keybindings f... | e(string): bool)|null */
private ?\Closure $onInput = null;
/**
* Return the effective keybindings for this widget.
*
* Resolution order (later overrides earlier):
* 1. Widget defaults (from getDefaultKeybindings())
* 2. G | licit keybindings set on this widget (via setKeybindings())
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
trait KeybindingsTrait
{
private ?Keybindings $keybindings = null;
/** @var (\Closur | {
"filepath": "src/Symfony/Component/Tui/Widget/KeybindingsTrait.php",
"language": "php",
"file_size": 2223,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget;
use Symfony\Component\Tui\Ansi\AnsiUtils;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
use Symfony\Component\Tui\Loop\PeriodicStepper;
use Symfony\Component\Tui\Render\RenderContext;
use Symfony\Component\Tui\Widget\Util\StringU... | = 'dots';
private const DEFAULT_INTERVAL_MS = 80;
/** @var array<string, string[]> */
private static array $styles = [
'line' => ['-', '\\', '|', '/'],
'dots' => ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
'bou | hedule any ticks until start() is called.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class LoaderWidget extends AbstractWidget
{
use ScheduledTickTrait;
private const string DEFAULT_STYLE | {
"filepath": "src/Symfony/Component/Tui/Widget/LoaderWidget.php",
"language": "php",
"file_size": 7154,
"cut_index": 716,
"middle_length": 229
} |
ommonMark\Node\Block\ThematicBreak;
use League\CommonMark\Extension\CommonMark\Node\Inline\Code;
use League\CommonMark\Extension\CommonMark\Node\Inline\Emphasis;
use League\CommonMark\Extension\CommonMark\Node\Inline\Link;
use League\CommonMark\Extension\CommonMark\Node\Inline\Strong;
use League\CommonMark\Extension\Gi... | eague\CommonMark\Node\Inline\Text;
use League\CommonMark\Node\Node;
use League\CommonMark\Parser\MarkdownParser;
use Symfony\Component\Tui\Ansi\AnsiUtils;
use Symfony\Component\Tui\Ansi\TextWrapper;
use Symfony\Component\Tui\Exception\LogicException;
use S | ague\CommonMark\Extension\Table\TableRow;
use League\CommonMark\Extension\Table\TableSection;
use League\CommonMark\Node\Block\Document;
use League\CommonMark\Node\Block\Paragraph;
use League\CommonMark\Node\Inline\Newline;
use L | {
"filepath": "src/Symfony/Component/Tui/Widget/MarkdownWidget.php",
"language": "php",
"file_size": 19314,
"cut_index": 1331,
"middle_length": 229
} |
ringUtils;
/**
* Animated progress bar widget.
*
* Supports both determinate (with max steps) and indeterminate (no max) modes.
* Uses a format string with placeholders to render the bar.
*
* Built-in placeholders: %current%, %max%, %bar%, %percent%, %elapsed%,
* %remaining%, %estimated%, %memory%, %message%.
... | private int $startTime;
private bool $running = false;
private int $barWidth = 28;
private string $barChar = '━';
private string $emptyBarChar = '━';
private string $progressChar = '';
private string $format;
/** @var array<st | get
{
use ScheduledTickTrait;
private const TICK_INTERVAL_MS = 100;
private int $step = 0;
private int $startingStep = 0;
private ?int $max;
private int $stepWidth;
private float $percent = 0.0;
| {
"filepath": "src/Symfony/Component/Tui/Widget/ProgressBarWidget.php",
"language": "php",
"file_size": 16767,
"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\Tui\Widget;
use Symfony\Component\Tui\Event\QuitEvent;
/**
* Trait for widge... | * @param callable(QuitEvent): void $callback
*
* @return $this
*/
public function onQuit(callable $callback): static
{
return $this->on(QuitEvent::class, $callback);
}
/**
* Dispatch the quit event.
*
| e widget), the default behavior is to stop the TUI.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
trait QuitableTrait
{
/**
* Register a listener for the quit event on this widget.
*
| {
"filepath": "src/Symfony/Component/Tui/Widget/QuitableTrait.php",
"language": "php",
"file_size": 1643,
"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\Tui\Widget;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Shared scheduling life... | cheduledTick(float $intervalSeconds): void
{
if ($intervalSeconds <= 0.0) {
throw new InvalidArgumentException(\sprintf('Interval must be greater than 0, got %d.', $intervalSeconds));
}
if (null !== $this->scheduled | ckId = null;
private ?float $scheduledTickInterval = null;
abstract protected function resolveScheduledTickContext(): ?WidgetContext;
abstract protected function onScheduledTick(): void;
private function startS | {
"filepath": "src/Symfony/Component/Tui/Widget/ScheduledTickTrait.php",
"language": "php",
"file_size": 2220,
"cut_index": 563,
"middle_length": 229
} |
;
use Symfony\Component\Tui\Event\SelectionChangeEvent;
use Symfony\Component\Tui\Input\Key;
use Symfony\Component\Tui\Input\Keybindings;
use Symfony\Component\Tui\Render\RenderContext;
/**
* Interactive selection list with keyboard navigation.
*
* Item `label`, `description`, and `value` are rendered to the termin... | <array{value: string, label: string, description?: string}> */
private array $filteredItems;
private int $selectedIndex = 0;
private bool $selected = false;
/**
* @param array<array{value: string, label: string, description?: string} | s()}.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SelectListWidget extends AbstractWidget implements FocusableInterface
{
use FocusableTrait;
use KeybindingsTrait;
/** @var array | {
"filepath": "src/Symfony/Component/Tui/Widget/SelectListWidget.php",
"language": "php",
"file_size": 11623,
"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\Tui\Widget;
use Symfony\Component\Tui\Exception\LogicException;
use Symfony\Component\Tui\Widget\Util\St... | mfony.com>
*
* @phpstan-type SubmenuFactory callable(string, callable(?string): void): (FocusableInterface&AbstractWidget)
*/
final class SettingItem
{
private string $currentValue;
/**
* @param list<string> $values Predefined valu | is sanitized. See {@see TextWidget}
* for the raw-passthrough contract: sanitize untrusted label/description
* upstream via {@see StringUtils::stripControlBytes()}.
*
* @experimental
*
* @author Fabien Potencier <fabien@sy | {
"filepath": "src/Symfony/Component/Tui/Widget/SettingItem.php",
"language": "php",
"file_size": 2652,
"cut_index": 563,
"middle_length": 229
} |
;
use Symfony\Component\Tui\Event\SettingChangeEvent;
use Symfony\Component\Tui\Input\Key;
use Symfony\Component\Tui\Input\Keybindings;
use Symfony\Component\Tui\Render\RenderContext;
/**
* Settings panel with value cycling and submenus.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
clas... | [];
/**
* @param list<SettingItem> $items
*/
public function __construct(
private array $items,
private int $maxVisible = 10,
?Keybindings $keybindings = null,
) {
if (null !== $keybindings) {
| enu state
private (FocusableInterface&AbstractWidget)|null $activeSubmenu = null;
/** @var list<array{string, callable}> Listeners to remove from the global dispatcher on cleanup */
private array $submenuListeners = | {
"filepath": "src/Symfony/Component/Tui/Widget/SettingsListWidget.php",
"language": "php",
"file_size": 12713,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget;
use Symfony\Component\Tui\Ansi\AnsiUtils;
use Symfony\Component\Tui\Ansi\TextWrapper;
use Symfony\Component\Tui\Render\RenderContext;
use Symfony\Component\Tui\Widget\Figlet\FigletRenderer;
/**
* Text component - displays text with word wrappi... | rules, CSS classes, or Tailwind utility classes:
*
* // Stylesheet rule
* $stylesheet->addRule('.title', new Style(font: 'big'));
*
* // Tailwind utility class
* $widget->addStyleClass('font-big');
*
* // Template
* <text c | font is set via the Style system, the text is rendered as large
* ASCII art instead. Bundled fonts: big, small, slant, standard, mini.
* Custom fonts can be registered via the FontRegistry.
*
* Font can be set via stylesheet | {
"filepath": "src/Symfony/Component/Tui/Widget/TextWidget.php",
"language": "php",
"file_size": 5138,
"cut_index": 716,
"middle_length": 229
} |
hp
/*
* 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\Tui\Widget;
/**
* Interface for widgets that can expand... | rface VerticallyExpandableInterface
{
/**
* Set whether the widget should expand to fill available height.
*
* @return $this
*/
public function expandVertically(bool $expand): static;
/**
* Check if the widget should e | * In vertical layouts, multiple expanded siblings share the space equally.
* In horizontal layouts, all children receive the full available height.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
inte | {
"filepath": "src/Symfony/Component/Tui/Widget/VerticallyExpandableInterface.php",
"language": "php",
"file_size": 1092,
"cut_index": 515,
"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\Tui\Widget;
/**
* Interface for widgets that can contain and mutate child widgets.
*
* Extends ParentInterface with mutation methods (add, remov... |
*/
public function add(AbstractWidget $widget): static;
/**
* @return $this
*/
public function remove(AbstractWidget $widget): static;
/**
* Remove all child widgets.
*
* @return $this
*/
public fun | tends ParentInterface
{
/**
* @return $this | {
"filepath": "src/Symfony/Component/Tui/Widget/WidgetContainerInterface.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\Tui\Widget;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Tui\Event\AbstractEvent;
use Symfony\Component\Tui\Focus\... | final class WidgetContext
{
/** @var array<string, string> */
private array $tickIds = [];
/**
* @internal constructed by the framework; user code receives the context via {@see AbstractWidget::onAttach()}
*/
public function __co | Symfony\Component\Tui\Terminal\TerminalInterface;
use Symfony\Component\Tui\Tui;
/**
* Runtime context provided to widgets when attached to the tree.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
| {
"filepath": "src/Symfony/Component/Tui/Widget/WidgetContext.php",
"language": "php",
"file_size": 3538,
"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\Tui\Widget;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Tui\Fo... | $terminal;
private ?AbstractWidget $root = null;
public function __construct(
Tui $tui,
Keybindings $keybindings,
FocusManager $focusManager,
Renderer $renderer,
TerminalInterface $terminal,
EventDis | /**
* Internal widget tree manager.
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class WidgetTree
{
private WidgetContext $context;
private readonly TerminalInterface | {
"filepath": "src/Symfony/Component/Tui/Widget/WidgetTree.php",
"language": "php",
"file_size": 2379,
"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\Tui\Widget\Util;
/**
* Emacs-style kill ring for cut/paste operations.
*
* Consecutive kill operations are appended to the same entry.
* Yank/yank-pop ... | = 50,
) {
}
/**
* Add text to the kill ring.
*
* If the last action was also a kill, the text is appended/prepended
* to the most recent entry (consecutive kills accumulate).
*/
public function add(string $text, bo | ing $lastAction = null;
/**
* @var array{start_line: int, start_col: int, end_line: int, end_col: int}|null
*/
private ?array $lastYank = null;
public function __construct(
private int $maxEntries | {
"filepath": "src/Symfony/Component/Tui/Widget/Util/KillRing.php",
"language": "php",
"file_size": 3602,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget\Util;
/**
* Grapheme-aware single-line text buffer with cursor position.
*
* Encapsulates text content and a byte-offset cursor. Every editing method
* mutates internal state and returns whether the operation had an effect,
* letting the cal... | $this->text = $text;
$this->cursor = max(0, min($cursor, \strlen($text)));
}
public function getText(): string
{
return $this->text;
}
public function getCursor(): int
{
return $this->cursor;
}
| rimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Line
{
private string $text;
private int $cursor;
public function __construct(string $text = '', int $cursor = 0)
{
| {
"filepath": "src/Symfony/Component/Tui/Widget/Util/Line.php",
"language": "php",
"file_size": 6866,
"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\Tui\Widget\Util;
/**
* General-purpose string utilities for terminal input handling.
*
* @experimenta... | * in multi-byte characters like emojis (e.g. 😀 = \xF0\x9F\x98\x80).
*/
public static function hasControlChars(string $data): bool
{
for ($i = 0; $i < \strlen($data); ++$i) {
$code = \ord($data[$i]);
if ($code | *
* Only checks for ASCII control characters (0x00-0x1F and 0x7F).
* Does NOT check for C1 control characters (U+0080-U+009F) at the byte
* level, because bytes 0x80-0x9F are valid UTF-8 continuation bytes used
| {
"filepath": "src/Symfony/Component/Tui/Widget/Util/StringUtils.php",
"language": "php",
"file_size": 2099,
"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\Tui\Widget\Util;
use Symfony\Component\Tui\Ansi\AnsiUtils;
/**
* Grapheme-aware word navigation for text editing.
*
* Provides cursor movement logic: s... | * Algorithm: skip trailing whitespace, then skip a punctuation run or a
* word-character run.
*/
public static function skipWordBackward(string $text, int $cursor): int
{
if (0 === $cursor) {
return 0;
}
| *
* @author Fabien Potencier <fabien@symfony.com>
*/
final class WordNavigator
{
/**
* Returns the new cursor position after moving one word backward within
* the given text. The cursor is a byte offset.
*
| {
"filepath": "src/Symfony/Component/Tui/Widget/Util/WordNavigator.php",
"language": "php",
"file_size": 3841,
"cut_index": 614,
"middle_length": 229
} |
24;
/** @var string[] */
private array $lines = [''];
private int $cursorLine = 0;
private int $cursorCol = 0;
private KillRing $killRing;
// Undo/Redo
/** @var array<int, array{lines: string[], cursor_line: int, cursor_col: int}> */
private array $undoStack = [];
/** @var array<i... | KillRing $killRing = null)
{
$this->killRing = $killRing ?? new KillRing();
}
// --- Accessors ---
/**
* @return string[]
*/
public function getLines(): array
{
return $this->lines;
}
public func | ode = null; // 'forward' or 'backward'
// Paste handling
private int $pasteCount = 0;
/** @var array<array{marker: string, content: string}> */
private array $pasteMarkers = [];
public function __construct(? | {
"filepath": "src/Symfony/Component/Tui/Widget/Editor/EditorDocument.php",
"language": "php",
"file_size": 20597,
"cut_index": 1331,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget\Editor;
use Symfony\Component\Tui\Ansi\AnsiUtils;
use Symfony\Component\Tui\Ansi\TextWrapper;
use Symfony\Component\Tui\Style\CursorShape;
use Symfony\Component\Tui\Style\Style;
/**
* Renders editor content lines with cursor and word-wrap.
*
... | $lines Document lines
* @param array{scroll_offset: int, visible_line_count: int, lines_above: int, lines_below: int} $viewport Viewport parameters
* @param int | fony.com>
*
* @internal
*/
final class EditorRenderer
{
/**
* Render the full editor output: borders + content lines + padding.
*
* @param string[] | {
"filepath": "src/Symfony/Component/Tui/Widget/Editor/EditorRenderer.php",
"language": "php",
"file_size": 8714,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget\Editor;
use Symfony\Component\Tui\Ansi\TextWrapper;
/**
* Manages scroll offset and viewport calculations for the editor.
*
* Owns the scroll offset and computes which logical lines are visible
* in the terminal viewport, accounting for word... | /**
* Scroll by a full page.
*
* @param string[] $lines Document lines
* @param int $direction 1 for down, -1 for up
* @param int $pageSize Number of lines per page
* @param int $cursorLine Current curso | EditorViewport
{
private int $scrollOffset = 0;
public function getScrollOffset(): int
{
return $this->scrollOffset;
}
public function reset(): void
{
$this->scrollOffset = 0;
}
| {
"filepath": "src/Symfony/Component/Tui/Widget/Editor/EditorViewport.php",
"language": "php",
"file_size": 5446,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Widget\Figlet;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Parses and represents a FIGlet font (.flf file).
*
* The FIGlet font format stores ASCII art representations of characters.
* Each character is defined as a fixed nu... |
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class FigletFont
{
private const int MAX_DECOMPRESSED_BYTES = 4 * 1024 * 1024;
/** @var array<int, string[]> codepoint → array of lines */
private array $characters = [];
/**
| cter (typically $) is rendered as a visible space
* that prevents smushing; it's replaced with a regular space on output.
*
* @see https://github.com/cmatsuoka/figlet/blob/master/figfont.txt
*
* @experimental
*
* @internal | {
"filepath": "src/Symfony/Component/Tui/Widget/Figlet/FigletFont.php",
"language": "php",
"file_size": 7109,
"cut_index": 716,
"middle_length": 229
} |
class TextWrapper
{
/**
* Wrap a single line into chunks with position tracking.
*
* Unlike wrapTextWithAnsi(), each chunk carries its start/end position
* in the original line, allowing callers to map cursor positions
* accurately through word-wrap boundaries.
*
* The chunk text ... | '' === $line) {
return [['text' => '', 'start_index' => 0, 'end_index' => 0]];
}
if ($width <= 0) {
return [['text' => $line, 'start_index' => 0, 'end_index' => \strlen($line)]];
}
$lineWidth = Ansi | $width Maximum visible width per chunk
*
* @return list<array{text: string, start_index: int, end_index: int}>
*/
public static function wrapLineIntoChunks(string $line, int $width): array
{
if ( | {
"filepath": "src/Symfony/Component/Tui/Ansi/TextWrapper.php",
"language": "php",
"file_size": 15727,
"cut_index": 921,
"middle_length": 229
} |
hp
/*
* 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\Tui\Exception;
/**
* Exception thrown when rendering fa... | {
parent::__construct($message);
}
public function getLineNumber(): int
{
return $this->lineNumber;
}
public function getLineWidth(): int
{
return $this->lineWidth;
}
public function getTerminalWi | xtends RuntimeException
{
public function __construct(
string $message,
private readonly int $lineNumber = 0,
private readonly int $lineWidth = 0,
private readonly int $terminalWidth = 0,
) | {
"filepath": "src/Symfony/Component/Tui/Exception/RenderException.php",
"language": "php",
"file_size": 1062,
"cut_index": 515,
"middle_length": 229
} |
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class CellBuffer
{
// Attribute bitmask constants
public const ATTR_BOLD = 1;
public const ATTR_DIM = 2;
public const ATTR_ITALIC = 4;
public const ATTR_UNDERLINE = 8;
public const ATTR_BLINK = 16;
public const ATTR_REVERSE = 32;... | array $fg;
/** @var string[] Background color code (e.g., "48;2;30;30;46") or "" for default */
private array $bg;
/** @var int[] Attribute bitmask (bold|dim|italic|underline|blink|reverse|strikethrough) */
private array $attrs;
/* R | ars;
/** @var int[] Display width of each cell (1 for normal, 2 for CJK, 0 for continuation) */
private array $widths;
/** @var string[] Foreground color code (e.g., "38;2;255;0;0") or "" for default */
private | {
"filepath": "src/Symfony/Component/Tui/Render/CellBuffer.php",
"language": "php",
"file_size": 20324,
"cut_index": 1331,
"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\Tui\Render;
use Symfony\Component\Tui\Ansi\AnsiUtils;
/**
* Composites multi... | Usage:
*
* $lines = Compositor::composite(
* new Layer($backgroundLines),
* new Layer($foregroundLines, transparent: true),
* );
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final | the
* content below show through where no explicit background is set.
*
* The canvas dimensions are derived from the first (base) layer:
* height is the number of lines, width is the visible width of the
* first line.
*
* | {
"filepath": "src/Symfony/Component/Tui/Render/Compositor.php",
"language": "php",
"file_size": 1848,
"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\Tui\Render;
/**
* A compositing layer: content lines at a position, optionall... | $row Vertical offset in the composite
* @param int $col Horizontal offset in the composite
* @param bool $transparent Whether cells with default background inherit from layers below
* @param int|null $width Exp | elow shows through).
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Layer
{
/**
* @param string[] $lines ANSI-formatted content lines
* @param int | {
"filepath": "src/Symfony/Component/Tui/Render/Layer.php",
"language": "php",
"file_size": 1513,
"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\Tui\Render;
use Symfony\Component\Tui\Style\Style;
use Symfony\Component\Tui\Widget\Figlet\FontRegistry;... | * - Terminals measure size in character cells (columns × rows), not pixels
* - The TerminalInterface uses `getColumns()` and `getRows()`
* - Standard tools like `stty`, `tput`, and env vars `COLUMNS`/`LINES` use this terminology
*
* @experimental
*
* | try for FIGlet rendering.
*
* This is an immutable value object - use with*() methods to create modified copies.
*
* ## Terminology: columns and rows
*
* This class uses `columns` and `rows` to match terminal conventions:
| {
"filepath": "src/Symfony/Component/Tui/Render/RenderContext.php",
"language": "php",
"file_size": 2734,
"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\Tui\Render;
/**
* Capability interface for managing the re... | d do a full re-render
*/
public function requestRender(bool $force = false): void;
/**
* Flush any pending render immediately.
*
* Unlike requestRender() which defers to the next tick, this
* synchronously renders the curr | al
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface RenderRequestorInterface
{
/**
* Request a render on the next tick.
*
* @param bool $force If true, clear all cached state an | {
"filepath": "src/Symfony/Component/Tui/Render/RenderRequestorInterface.php",
"language": "php",
"file_size": 1208,
"cut_index": 518,
"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\Serializer\Encoder;
/**
* Encodes JSON data.
*
* @author Jordi Boggiano <j.... | {
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
$this->encodingImpl = $encodingImpl ?? new JsonEncode($this->defaultContext);
$this->decodingImpl = $decodingImpl ?? new JsonDecode($this->defaultConte | odingImpl;
private array $defaultContext = [
JsonDecode::ASSOCIATIVE => true,
];
public function __construct(?JsonEncode $encodingImpl = null, ?JsonDecode $decodingImpl = null, array $defaultContext = [])
| {
"filepath": "src/Symfony/Component/Serializer/Encoder/JsonEncoder.php",
"language": "php",
"file_size": 1739,
"cut_index": 537,
"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\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\Exception\RuntimeException;
use... | 'preserve_empty_objects';
/**
* Override the amount of spaces to use for indentation of nested nodes.
*
* This option only works in the constructor, not in calls to `encode`.
*/
public const YAML_INDENTATION = 'yaml_indentation | r Kévin Dunglas <dunglas@gmail.com>
*/
class YamlEncoder implements EncoderInterface, DecoderInterface
{
public const FORMAT = 'yaml';
private const ALTERNATIVE_FORMAT = 'yml';
public const PRESERVE_EMPTY_OBJECTS = | {
"filepath": "src/Symfony/Component/Serializer/Encoder/YamlEncoder.php",
"language": "php",
"file_size": 3373,
"cut_index": 614,
"middle_length": 229
} |
mpiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Serial... | zer" as
* encoders and normalizers to the "serializer" service.
*
* @author Javier Lopez <f12loalf@gmail.com>
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class SerializerPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait | malizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
/**
* Adds all services with the tags "serializer.encoder" and "serializer.normali | {
"filepath": "src/Symfony/Component/Serializer/DependencyInjection/SerializerPass.php",
"language": "php",
"file_size": 11899,
"cut_index": 921,
"middle_length": 229
} |
Dispatcher\EventDispatcherInterface;
use Symfony\Component\Tui\Event\AbstractEvent;
use Symfony\Component\Tui\Event\InputEvent;
use Symfony\Component\Tui\Event\TickEvent;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
use Symfony\Component\Tui\Focus\FocusManager;
use Symfony\Component\Tui\Input\Keybindin... | nal\TerminalInterface;
use Symfony\Component\Tui\Widget\AbstractWidget;
use Symfony\Component\Tui\Widget\ContainerWidget;
use Symfony\Component\Tui\Widget\Figlet\FontRegistry;
use Symfony\Component\Tui\Widget\FocusableInterface;
use Symfony\Component\Tui\W | r;
use Symfony\Component\Tui\Render\RenderRequestorInterface;
use Symfony\Component\Tui\Render\ScreenWriter;
use Symfony\Component\Tui\Style\StyleSheet;
use Symfony\Component\Tui\Terminal\Terminal;
use Symfony\Component\Tui\Termi | {
"filepath": "src/Symfony/Component/Tui/Tui.php",
"language": "php",
"file_size": 16026,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Tui\Style;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Represents border values like CSS border.
*
* Supports 1, 2, 3, or 4 values:
* - 1 value: all sides
* - 2 values: top/bottom, left/right
* - 3 values: top, left/right, bo... | unction __construct(
int $top,
int $right,
int $bottom,
int $left,
BorderPattern|string|null $pattern = null,
Color|string|int|null $color = null,
) {
$this->top = max(0, $top);
$this->rig | :NORMAL;
public readonly int $top;
public readonly int $right;
public readonly int $bottom;
public readonly int $left;
public readonly BorderPattern $pattern;
public readonly ?Color $color;
public f | {
"filepath": "src/Symfony/Component/Tui/Style/Border.php",
"language": "php",
"file_size": 7239,
"cut_index": 716,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Tui\Style;
/**
* Terminal cursor shape, mapped to DEC... | the blinking
* variants so the terminal provides native cursor animation at
* zero CPU cost.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
enum CursorShape: int
{
case Block = 1;
case Underline = 3;
case Bar = 5; | y one. We use | {
"filepath": "src/Symfony/Component/Tui/Style/CursorShape.php",
"language": "php",
"file_size": 786,
"cut_index": 513,
"middle_length": 14
} |
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\Tui\Style;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Represents padding valu... | t;
public function __construct(int $top, int $right, int $bottom, int $left)
{
$this->top = max(0, $top);
$this->right = max(0, $right);
$this->bottom = max(0, $bottom);
$this->left = max(0, $left);
}
/**
| m, left
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Padding
{
public readonly int $top;
public readonly int $right;
public readonly int $bottom;
public readonly int $lef | {
"filepath": "src/Symfony/Component/Tui/Style/Padding.php",
"language": "php",
"file_size": 2990,
"cut_index": 563,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.