prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\TestCas... | = new NoLimiter();
$this->assertInstanceOf(RateLimit::class, $limiter->consume());
}
public function testReserve()
{
$limiter = new NoLimiter();
$this->assertInstanceOf(Reservation::class, $limiter->reserve());
}
}
| ublic function testConsume()
{
$limiter | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/NoLimiterTest.php",
"language": "php",
"file_size": 822,
"cut_index": 514,
"middle_length": 52
} |
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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Compon... | ic function provideRate(): iterable
{
yield [new Rate(new \DateInterval('PT15S'), 10)];
yield [Rate::perSecond(10)];
yield [Rate::perMinute(10)];
yield [Rate::perHour(10)];
yield [Rate::perDay(10)];
yield | :fromString((string) $rate));
}
public stat | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/RateTest.php",
"language": "php",
"file_size": 956,
"cut_index": 582,
"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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Compone... | ckMock::register(RateLimit::class);
}
public function testConsume()
{
$limiter = $this->createLimiter();
$limiter->consume(8);
sleep(15);
$rateLimit = $limiter->consume();
$this->assertTrue($rateLimit- | dowLimiterTest extends TestCase
{
private InMemoryStorage $storage;
protected function setUp(): void
{
$this->storage = new InMemoryStorage();
ClockMock::register(InMemoryStorage::class);
Clo | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowLimiterTest.php",
"language": "php",
"file_size": 4639,
"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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Compone... | $window = new SlidingWindow('foo', 10);
$this->assertSame(2 * 10, $window->getExpirationTime());
$this->assertSame(2 * 10, $window->getExpirationTime());
$data = serialize($window);
sleep(10);
$cachedWindow = unseri | public function __toString(): string
{
self::$fired = true;
return '';
}
}
#[Group('time-sensitive')]
class SlidingWindowTest extends TestCase
{
public function testGetExpirationTime()
{
| {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowTest.php",
"language": "php",
"file_size": 4833,
"cut_index": 614,
"middle_length": 229
} |
mfony\Component\RateLimiter\Exception\MaxWaitDurationExceededException;
use Symfony\Component\RateLimiter\Policy\Rate;
use Symfony\Component\RateLimiter\Policy\TokenBucket;
use Symfony\Component\RateLimiter\Policy\TokenBucketLimiter;
use Symfony\Component\RateLimiter\RateLimit;
use Symfony\Component\RateLimiter\Storage... | ter(TokenBucket::class);
ClockMock::register(RateLimit::class);
}
public function testReserve()
{
$limiter = $this->createLimiter();
$this->assertEquals(0, $limiter->reserve(5)->getWaitDuration());
$this->asser | e;
protected function setUp(): void
{
$this->storage = new InMemoryStorage();
ClockMock::register(TokenBucketLimiter::class);
ClockMock::register(InMemoryStorage::class);
ClockMock::regis | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/TokenBucketLimiterTest.php",
"language": "php",
"file_size": 9191,
"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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\TestCase;
use Sym... | 'tokens' => 0,
'timer' => 0.0,
'burstSize' => 10,
'rate' => 'PT1M-10',
];
$payload = \sprintf('O:%d:"%s":%d:{', \strlen(TokenBucket::class), TokenBucket::class, \count($data));
foreach | d = true;
return '';
}
}
class TokenBucketTest extends TestCase
{
public function testUnserializeRejectsObjectInTypedIdProperty()
{
$data = [
'id' => new TokenBucketTestToStringGadget(),
| {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/TokenBucketTest.php",
"language": "php",
"file_size": 1485,
"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\RateLimiter\Tests\Policy;
use PHPUnit\Framework\TestCase;
use Sym... | t' => 0,
'intervalInSeconds' => 1,
'maxSize' => 10,
'timer' => 0.0,
];
$payload = \sprintf('O:%d:"%s":%d:{', \strlen(Window::class), Window::class, \count($data));
foreach ($data as $key => $value |
return '';
}
}
class WindowTest extends TestCase
{
public function testUnserializeRejectsObjectInTypedIdProperty()
{
$data = [
'id' => new WindowTestToStringGadget(),
'hitCoun | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Policy/WindowTest.php",
"language": "php",
"file_size": 1450,
"cut_index": 524,
"middle_length": 229
} |
s 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\RateLimiter\Tests\Resources;
use Symfony\Component\RateLimiter\LimiterStateIn... | {
$this->id = $id;
$this->expirationTime = $expirationTime;
}
public function getId(): string
{
return $this->id;
}
public function getExpirationTime(): ?int
{
return $this->expirationTime;
}
}
| ime = 10)
| {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Resources/DummyWindow.php",
"language": "php",
"file_size": 806,
"cut_index": 536,
"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\RateLimiter\Tests\Storage;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemInterface;
use Psr\Cac... | is->exactly(2))->method('expiresAfter')->with(10);
$pool->method('getItem')->willReturnMap([
[sha1('test'), $cacheItem],
]);
$pool->expects($this->exactly(2))->method('save')->with($cacheItem);
$window = new Wi | on testSave()
{
$pool = $this->createMock(CacheItemPoolInterface::class);
$storage = new CacheStorage($pool);
$cacheItem = $this->createMock(CacheItemInterface::class);
$cacheItem->expects($th | {
"filepath": "src/Symfony/Component/RateLimiter/Tests/Storage/CacheStorageTest.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\RateLimiter\Storage;
use Psr\Cache\CacheItemPoolInterface;
use Sy... | limiterState);
if (null !== ($expireAfter = $limiterState->getExpirationTime())) {
$cacheItem->expiresAfter($expireAfter);
}
$this->pool->save($cacheItem);
}
public function fetch(string $limiterStateId): ?Limi | private CacheItemPoolInterface $pool,
) {
}
public function save(LimiterStateInterface $limiterState): void
{
$cacheItem = $this->pool->getItem(sha1($limiterState->getId()));
$cacheItem->set($ | {
"filepath": "src/Symfony/Component/RateLimiter/Storage/CacheStorage.php",
"language": "php",
"file_size": 1383,
"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\RateLimiter\Storage;
use Symfony\Component\RateLimiter\LimiterStateInterface;
... | if (!isset($this->buckets[$limiterStateId])) {
return null;
}
[$expireAt, $limiterState] = $this->buckets[$limiterStateId];
if (null !== $expireAt && $expireAt <= microtime(true)) {
unset($this->buckets[$li | iterState): void
{
$this->buckets[$limiterState->getId()] = [$this->getExpireAt($limiterState), serialize($limiterState)];
}
public function fetch(string $limiterStateId): ?LimiterStateInterface
{
| {
"filepath": "src/Symfony/Component/RateLimiter/Storage/InMemoryStorage.php",
"language": "php",
"file_size": 1627,
"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\Mime;
use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\MessageIDValidation;
use Egulias\EmailValidator\Validation\RFCValida... | ing between the first < and last > as email address.
* This allows to use a single string to construct an Address, which can be convenient to use in
* config, and allows to have more readable config.
* This does not try to cover all edge cas | onent\Mime\Exception\RfcComplianceException;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Address
{
/**
* A regex that matches a structure like 'Name <email@address.com>'.
* It matches anyth | {
"filepath": "src/Symfony/Component/Mime/Address.php",
"language": "php",
"file_size": 4715,
"cut_index": 614,
"middle_length": 229
} |
cterStream
{
/** Pre-computed for optimization */
private const UTF8_LENGTH_MAP = [
"\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1,
"\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1,
... | 2e" => 1, "\x2f" => 1,
"\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1,
"\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1,
" | , "\x1e" => 1, "\x1f" => 1,
"\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1,
"\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x | {
"filepath": "src/Symfony/Component/Mime/CharacterStream.php",
"language": "php",
"file_size": 9347,
"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\Mime;
use Symfony\Component\Mime\Header\Headers;
use Symfon... | sage-ID headers.
* These are added by the client that actually sends the email.
*/
public function getPreparedHeaders(): Headers
{
$headers = clone $this->getHeaders();
if (!$headers->has('MIME-Version')) {
$h | t $body = null)
{
parent::__construct($headers, $body);
$this->getHeaders()->addTextHeader('X-Unsent', '1');
}
/**
* Override default behavior as draft emails do not require From/Sender/Date/Mes | {
"filepath": "src/Symfony/Component/Mime/DraftEmail.php",
"language": "php",
"file_size": 1127,
"cut_index": 518,
"middle_length": 229
} |
art;
use Symfony\Component\Mime\Part\File;
use Symfony\Component\Mime\Part\Multipart\AlternativePart;
use Symfony\Component\Mime\Part\Multipart\MixedPart;
use Symfony\Component\Mime\Part\Multipart\RelatedPart;
use Symfony\Component\Mime\Part\TextPart;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class Emai... | RIORITY_LOWEST => 'Lowest',
];
/**
* @var resource|string|null
*/
private $text;
private ?string $textCharset = null;
/**
* @var resource|string|null
*/
private $html;
private ?string $htmlCharset = null; | Y_LOWEST = 5;
private const PRIORITY_MAP = [
self::PRIORITY_HIGHEST => 'Highest',
self::PRIORITY_HIGH => 'High',
self::PRIORITY_NORMAL => 'Normal',
self::PRIORITY_LOW => 'Low',
self::P | {
"filepath": "src/Symfony/Component/Mime/Email.php",
"language": "php",
"file_size": 15546,
"cut_index": 921,
"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\RateLimiter;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*/
final class Reservation
{
/**
* @param float $t... | return $this->timeToAct;
}
public function getWaitDuration(): float
{
return max(0, (-microtime(true)) + $this->timeToAct);
}
public function getRateLimit(): RateLimit
{
return $this->rateLimit;
}
| }
public function getTimeToAct(): float
{
| {
"filepath": "src/Symfony/Component/RateLimiter/Reservation.php",
"language": "php",
"file_size": 989,
"cut_index": 582,
"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\Tui\Tests\Loop;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Tui\Exce... | s);
PeriodicStepper::everyMs(0);
}
public function testAdvanceAccumulatesElapsedDelta()
{
$stepper = new PeriodicStepper(0.1, 5);
$this->assertSame(0, $stepper->advance(0.05));
$this->assertSame(1, $stepper->ad | $this->expectException(InvalidArgumentException::class);
new PeriodicStepper(0.0);
}
public function testEveryMsRejectsInvalidInterval()
{
$this->expectException(InvalidArgumentException::clas | {
"filepath": "src/Symfony/Component/Tui/Tests/Loop/PeriodicStepperTest.php",
"language": "php",
"file_size": 1515,
"cut_index": 537,
"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\Tui\Event;
use Symfony\Component\Tui\Widget\AbstractWidget;
/**
* Event dispatched when a widget's value changes.
*
* @... | nstruct($target);
}
/**
* Get the current value.
*/
public function getValue(): string
{
return $this->value;
}
/**
* Check if the current value is empty or contains only whitespace.
*/
public funct | readonly string $value,
) {
parent::__co | {
"filepath": "src/Symfony/Component/Tui/Event/ChangeEvent.php",
"language": "php",
"file_size": 966,
"cut_index": 582,
"middle_length": 52
} |
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\Tui\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* Event dispatched when ra... | en Potencier <fabien@symfony.com>
*/
class InputEvent extends Event
{
public function __construct(
private readonly string $data,
) {
}
/**
* The raw input data from the terminal.
*/
public function getData(): string | r processing.
*
* @experimental
*
* @author Fabi | {
"filepath": "src/Symfony/Component/Tui/Event/InputEvent.php",
"language": "php",
"file_size": 898,
"cut_index": 547,
"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\Tui\Event;
use Symfony\Component\Tui\Widget\SelectListWidget;
/**
* Event di... | public function __construct(
SelectListWidget $target,
private readonly array $item,
) {
parent::__construct($target);
}
/**
* Get the full highlighted item array.
*
* @return array{value: string, label: | }).
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SelectionChangeEvent extends AbstractEvent
{
/**
* @param array{value: string, label: string, description?: string} $item
*/
| {
"filepath": "src/Symfony/Component/Tui/Event/SelectionChangeEvent.php",
"language": "php",
"file_size": 1612,
"cut_index": 537,
"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\Event;
use Symfony\Component\Tui\Widget\AbstractW... | public function getValue(): string
{
return $this->value;
}
/**
* Check if the submitted value is empty or contains only whitespace.
*/
public function isBlank(): bool
{
return '' === trim($this->value);
| xtends AbstractEvent
{
public function __construct(
AbstractWidget $target,
private readonly string $value,
) {
parent::__construct($target);
}
/**
* Get the submitted value.
*/
| {
"filepath": "src/Symfony/Component/Tui/Event/SubmitEvent.php",
"language": "php",
"file_size": 1004,
"cut_index": 512,
"middle_length": 229
} |
> ["\x1b[2~"],
'delete' => ["\x1b[3~"],
'page_up' => ["\x1b[5~", "\x1b[[5~"],
'page_down' => ["\x1b[6~", "\x1b[[6~"],
'clear' => ["\x1b[E", "\x1bOE"],
'f1' => ["\x1bOP", "\x1b[11~", "\x1b[[A"],
'f2' => ["\x1bOQ", "\x1b[12~", "\x1b[[B"],
'f3' => ["\x1bOR", "\x1b[13... | 'f3' => 13,
'f4' => 14,
'f5' => 15,
'f6' => 17,
'f7' => 18,
'f8' => 19,
'f9' => 20,
'f10' => 21,
'f11' => 23,
'f12' => 24,
];
private const LEGACY_FUNCTION_KEY_LETTERS = [ | 9~"],
'f9' => ["\x1b[20~"],
'f10' => ["\x1b[21~"],
'f11' => ["\x1b[23~"],
'f12' => ["\x1b[24~"],
];
private const LEGACY_FUNCTION_KEY_CODES = [
'f1' => 11,
'f2' => 12,
| {
"filepath": "src/Symfony/Component/Tui/Input/KeyParser.php",
"language": "php",
"file_size": 34086,
"cut_index": 2151,
"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\Input;
/**
* Configurable keybindings manager.
*
* Maps action names to... | ->bindings = $bindings;
$this->parser = $parser ?? new KeyParser();
}
public function matches(string $data, string $action): bool
{
if (!isset($this->bindings[$action])) {
return false;
}
foreach ($ | */
private array $bindings;
private KeyParser $parser;
/**
* @param array<string, string[]> $bindings
*/
public function __construct(array $bindings = [], ?KeyParser $parser = null)
{
$this | {
"filepath": "src/Symfony/Component/Tui/Input/Keybindings.php",
"language": "php",
"file_size": 1739,
"cut_index": 537,
"middle_length": 229
} |
rray<int, array<int, array{char: string, style: string}>> */
private array $cells = [];
private int $cursorRow = 0;
private int $cursorCol = 0;
private int $width;
private int $height;
private AnsiCodeTracker $styleTracker;
public function __construct(int $width = 80, int $height = 24)
... | = 0;
$this->styleTracker->reset();
}
/**
* Process terminal output and update the screen buffer.
*/
public function write(string $data): void
{
$i = 0;
$len = \strlen($data);
while ($i < $len) {
| */
public function clear(): void
{
$this->cells = [];
for ($row = 0; $row < $this->height; ++$row) {
$this->cells[$row] = [];
}
$this->cursorRow = 0;
$this->cursorCol | {
"filepath": "src/Symfony/Component/Tui/Terminal/ScreenBuffer.php",
"language": "php",
"file_size": 18261,
"cut_index": 1331,
"middle_length": 229
} |
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Terminal implements TerminalInterface
{
private ?StdinBuffer $stdinBuffer = null;
private string $initialSttyState = '';
private bool $kittyProtocolActive = false;
private bool $started = false;
private ?string $std... | = null;
private ?int $cachedRows = null;
public function start(callable $onInput, callable $onResize, callable $onKittyProtocolActivated): void
{
if ($this->started) {
return;
}
$this->onInput = $onInput(. | /
private ?\Closure $onResize = null;
/** @var (\Closure(): void)|null */
private ?\Closure $onKittyProtocolActivated = null;
// Cached terminal dimensions (refreshed on SIGWINCH)
private ?int $cachedColumns | {
"filepath": "src/Symfony/Component/Tui/Terminal/Terminal.php",
"language": "php",
"file_size": 10746,
"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\Terminal;
use Symfony\Component\Tui\Input\StdinBuffer;
/**
* Virtual terminal for testing.
*
* Captures output and allows simulating input for unit... | lTerminal implements TerminalInterface
{
private string $output = '';
private ?StdinBuffer $stdinBuffer = null;
private ?\Closure $onResize = null;
public function __construct(
private int $columns = 80,
private int $rows = | d don't respond to terminal
* queries (e.g. cell size). This is used by the rendering pipeline
* to adjust its behavior accordingly.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class Virtua | {
"filepath": "src/Symfony/Component/Tui/Terminal/VirtualTerminal.php",
"language": "php",
"file_size": 4543,
"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\Loop;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
... | Exception(\sprintf('Steps per second must be greater than 0, got %d.', $stepsPerSecond));
}
if ($maxStepsPerUpdate < 1) {
throw new InvalidArgumentException(\sprintf('Max steps per update must be greater than 0, got %d.', $maxS | te float $accumulator = 0.0;
public function __construct(
private float $stepsPerSecond,
private int $maxStepsPerUpdate = 5,
) {
if ($stepsPerSecond <= 0.0) {
throw new InvalidArgument | {
"filepath": "src/Symfony/Component/Tui/Loop/FixedStepAccumulator.php",
"language": "php",
"file_size": 1846,
"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\Tui\Loop;
/**
* Small monotonic-ish clock abstraction for game a... | eltaTime = null): float
{
if (null === $deltaTime) {
$now = hrtime(true) / 1e9;
$elapsed = max(0.0, $now - $this->time);
$this->time = $now;
return $elapsed;
}
$elapsed = max(0.0 | t(
?float $time = null,
) {
$this->time = $time ?? hrtime(true) / 1e9;
}
/**
* Advance clock state and return elapsed seconds since previous advance.
*/
public function advance(?float $d | {
"filepath": "src/Symfony/Component/Tui/Loop/LoopClock.php",
"language": "php",
"file_size": 1282,
"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\RateLimiter;
use Symfony\Component\RateLimiter\Exception\ReserveNotSupportedEx... | ublic function reserve(int $tokens = 1, ?float $maxTime = null): Reservation
{
throw new ReserveNotSupportedException(__CLASS__);
}
public function consume(int $tokens = 1): RateLimit
{
$minimalRateLimit = null;
for | function __construct(
private array $limiters,
) {
if (!$limiters) {
throw new \LogicException(\sprintf('"%s::%s()" require at least one limiter.', self::class, __METHOD__));
}
}
p | {
"filepath": "src/Symfony/Component/RateLimiter/CompoundLimiter.php",
"language": "php",
"file_size": 1616,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\RateLimiter;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\RateLimiter\Policy\FixedWindowLimiter;
use Symfony\Component\RateLimiter\Policy\... | nstruct(
array $config,
private StorageInterface $storage,
private ?LockFactory $lockFactory = null,
) {
$options = new OptionsResolver();
self::configureOptions($options);
$this->config = $options->reso | y\Component\RateLimiter\Storage\StorageInterface;
/**
* @author Wouter de Jong <wouter@wouterj.nl>
*/
final class RateLimiterFactory implements RateLimiterFactoryInterface
{
private array $config;
public function __co | {
"filepath": "src/Symfony/Component/RateLimiter/RateLimiterFactory.php",
"language": "php",
"file_size": 5494,
"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\Tests\Loop;
use PHPUnit\Framework\TestCase;
use Symf... | ock = new LoopClock();
usleep(1000);
$elapsed = $clock->advance();
$this->assertGreaterThan(0.0, $elapsed);
}
public function testResetSetsCurrentTime()
{
$clock = new LoopClock(100.0);
$clock->reset(4 | $elapsed = $clock->advance(0.25);
$this->assertSame(0.25, $elapsed);
$this->assertSame(100.25, $clock->now());
}
public function testAdvanceWithoutDeltaUsesWallClockElapsedTime()
{
$cl | {
"filepath": "src/Symfony/Component/Tui/Tests/Loop/LoopClockTest.php",
"language": "php",
"file_size": 1063,
"cut_index": 515,
"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\Tests\Loop;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Tui\Exception\InvalidArgumentExcep... | $scheduler = new TickScheduler();
$calls = 0;
$start = microtime(true);
$scheduler->schedule(static function () use (&$calls): void {
++$calls;
}, 0.5);
$scheduler->runDue($start + 0.10);
$this- | kScheduler();
$this->expectException(InvalidArgumentException::class);
$scheduler->schedule(static function (): void {}, 0.0);
}
public function testRunDueExecutesAndReschedulesCallbacks()
{
| {
"filepath": "src/Symfony/Component/Tui/Tests/Loop/TickSchedulerTest.php",
"language": "php",
"file_size": 2374,
"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\Event;
use Symfony\Component\Tui\Widget\AbstractWidget;... | /
class FocusEvent extends AbstractEvent
{
public function __construct(
AbstractWidget&FocusableInterface $target,
private readonly ?FocusableInterface $previous,
) {
parent::__construct($target);
}
/**
* Get t | know when focus is lost can observe widget removal directly or
* track the previous focus via {@see getPrevious()} on subsequent
* focus-change events.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
* | {
"filepath": "src/Symfony/Component/Tui/Event/FocusEvent.php",
"language": "php",
"file_size": 1150,
"cut_index": 518,
"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\Event;
/**
* Event dispatched on each tick of the main... | previous tick callback.
*/
public function getDeltaTime(): float
{
return $this->deltaTime;
}
public function setBusy(bool $busy = true): void
{
$this->hasBusyHint = true;
$this->busy = $busy;
}
pu | kEvent
{
private bool $hasBusyHint = false;
private bool $busy = false;
public function __construct(
private readonly float $deltaTime = 0.0,
) {
}
/**
* Time elapsed (in seconds) since the | {
"filepath": "src/Symfony/Component/Tui/Event/TickEvent.php",
"language": "php",
"file_size": 1162,
"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\Tui\Terminal;
/**
* Terminal that delegates to multiple terminals simultaneously.
*
* This is useful for:
* - Running examples with both a real termina... | he primary terminal (used for input and dimensions)
* @param TerminalInterface $secondary Additional terminal that receives writes
*/
public function __construct(
private TerminalInterface $primary,
private TerminalInterface $ | s.
* All terminals receive write operations.
*
* @experimental
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class TeeTerminal implements TerminalInterface
{
/**
* @param TerminalInterface $primary T | {
"filepath": "src/Symfony/Component/Tui/Terminal/TeeTerminal.php",
"language": "php",
"file_size": 3387,
"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\Tui\Loop;
use Revolt\EventLoop;
/**
* Drives the main TUI tick interval using adaptive scheduling.
*
* @experimental
*
* @internal
*
* @author Fabi... | lic function refresh(bool $running, bool $renderRequested, ?float $nextScheduledDelay, bool $hasTickCallback, ?bool $lastTickBusyHint): void
{
$this->setInterval($this->computeDesiredInterval($running, $renderRequested, $nextScheduledDelay, $ha |
public function __construct(
private readonly TickRuntimeInterface $runtime,
private readonly float $activeTickInterval = 0.01,
private readonly float $idleTickInterval = 0.25,
) {
}
pub | {
"filepath": "src/Symfony/Component/Tui/Loop/AdaptativeTicker.php",
"language": "php",
"file_size": 3253,
"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\Loop;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Internal scheduler for r... | void $callback
*/
public function schedule(callable $callback, float $intervalSeconds): string
{
if ($intervalSeconds <= 0) {
throw new InvalidArgumentException(\sprintf('Interval must be greater than 0, got %f.', $interval | ;
/**
* @var array<string, array{
* callback: callable(): void,
* interval: float,
* next_run_at: float
* }>
*/
private array $intervals = [];
/**
* @param callable(): | {
"filepath": "src/Symfony/Component/Tui/Loop/TickScheduler.php",
"language": "php",
"file_size": 2491,
"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\Event;
use Symfony\Component\Tui\Widget\SelectListWidget;
/*... | get);
}
/**
* Get the full selected item array.
*
* @return array{value: string, label: string, description?: string}
*/
public function getItem(): array
{
return $this->item;
}
/**
* Get the selec | * @param array{value: string, label: string, description?: string} $item
*/
public function __construct(
SelectListWidget $target,
private readonly array $item,
) {
parent::__construct($tar | {
"filepath": "src/Symfony/Component/Tui/Event/SelectEvent.php",
"language": "php",
"file_size": 1446,
"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\Tui\Event;
use Symfony\Component\Tui\Widget\AbstractWidget;
use Symfony\Contracts\EventD... | *
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class AbstractEvent extends BaseEvent
{
public function __construct(
private readonly AbstractWidget $target,
) {
}
public function getTarget(): AbstractWidget
{
| t that
* originated the event.
*
* @experimental
| {
"filepath": "src/Symfony/Component/Tui/Event/AbstractEvent.php",
"language": "php",
"file_size": 893,
"cut_index": 547,
"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\Tui\Event;
use Symfony\Component\Tui\Widget\SettingsListWidget;
... | ing identifier.
*/
public function getId(): string
{
return $this->id;
}
/**
* Get the new setting value.
*/
public function getValue(): string
{
return $this->value;
}
/**
* Check if th |
{
public function __construct(
SettingsListWidget $target,
private readonly string $id,
private readonly string $value,
) {
parent::__construct($target);
}
/**
* Get the sett | {
"filepath": "src/Symfony/Component/Tui/Event/SettingChangeEvent.php",
"language": "php",
"file_size": 1446,
"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\Tui\Terminal;
/**
* Interface for terminal implementations.
*
* Provides abstraction over terminal I/... | (string): void $onInput Called when input is received
* @param callable(): void $onResize Called when terminal is resized
* @param callable(): void $onKittyProtocolActivated Called when Kitty keyboard | terface
{
/**
* Start the terminal with input and resize handlers.
*
* This typically enables raw mode, sets up signal handlers,
* and prepares the terminal for TUI operation.
*
* @param callable | {
"filepath": "src/Symfony/Component/Tui/Terminal/TerminalInterface.php",
"language": "php",
"file_size": 3000,
"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\RateLimiter;
/**
* @author Kevin Bond <kevinbond@gmail.com>
*/
final class CompoundRat... | unction create(?string $key = null): LimiterInterface
{
$rateLimiters = [];
foreach ($this->rateLimiterFactories as $rateLimiterFactory) {
$rateLimiters[] = $rateLimiterFactory->create($key);
}
return new C | ble $rateLimiterFactories)
{
}
public f | {
"filepath": "src/Symfony/Component/RateLimiter/CompoundRateLimiterFactory.php",
"language": "php",
"file_size": 894,
"cut_index": 547,
"middle_length": 52
} |
aking key parsing work correctly.
* Also handles bracketed paste mode.
*
* @experimental
*
* @internal
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class StdinBuffer
{
private const int MAX_PASTE_BYTES = 16 * 1024 * 1024;
private const int MAX_PENDING_BYTES = 1024 * 1024;
private const... | ram callable(string): void $callback
*/
public function onData(callable $callback): void
{
$this->onData = $callback(...);
}
/**
* Set callback for paste content.
*
* @param callable(string): void $callback
| * @var (\Closure(string): void)|null */
private ?\Closure $onPaste = null;
private bool $inPaste = false;
private string $pasteBuffer = '';
/**
* Set callback for individual key sequences.
*
* @pa | {
"filepath": "src/Symfony/Component/Tui/Input/StdinBuffer.php",
"language": "php",
"file_size": 11982,
"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\Loop;
use Symfony\Component\Tui\Exception\InvalidArgumentException;
/**
* Converts elapsed time in... | entException(\sprintf('Interval must be greater than 0, got %d.', $intervalSeconds));
}
$this->accumulator = new FixedStepAccumulator(1.0 / $intervalSeconds, $maxStepsPerUpdate);
$this->clock = new LoopClock();
}
public st | ulator;
private LoopClock $clock;
public function __construct(
private float $intervalSeconds,
int $maxStepsPerUpdate = 8,
) {
if ($intervalSeconds <= 0.0) {
throw new InvalidArgum | {
"filepath": "src/Symfony/Component/Tui/Loop/PeriodicStepper.php",
"language": "php",
"file_size": 2410,
"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\Mime\Part\Multipart;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Part\AbstractMultipartPart;
use Symfony\Comp... | ers()->setMaxLineLength(\PHP_INT_MAX);
}
public function getMediaSubtype(): string
{
return 'form-data';
}
public function getParts(): array
{
return $this->prepareFields($this->fields);
}
private function | ray<string|array|TextPart> $fields
*/
public function __construct(
private array $fields = [],
) {
parent::__construct();
// HTTP does not support \r\n in header values
$this->getHead | {
"filepath": "src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php",
"language": "php",
"file_size": 3068,
"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\Mime\Tests\Part\Multipart;
use PHPUnit\Framework\TestCase;
us... | t($a = new MessagePart(new Message()), $b = new MessagePart(new Message()));
$this->assertEquals('multipart', $r->getMediaType());
$this->assertEquals('digest', $r->getMediaSubtype());
$this->assertEquals([$a, $b], $r->getParts());
| n testConstructor()
{
$r = new DigestPar | {
"filepath": "src/Symfony/Component/Mime/Tests/Part/Multipart/DigestPartTest.php",
"language": "php",
"file_size": 836,
"cut_index": 520,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Part\Multipart;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\Multipart\FormDataPart;
use Symfony\Component\Mime\Part\TextP... | ore than 76 characters, ok?',
'bar' => clone $b,
'baz' => clone $c,
]);
$this->assertEquals('multipart', $f->getMediaType());
$this->assertEquals('form-data', $f->getMediaSubtype());
$t = new TextPart | nt');
$c = DataPart::fromPath($file = __DIR__.'/../../Fixtures/mimetypes/test.gif');
$f = new FormDataPart([
'foo' => $content = 'very very long content that will not be cut even if the length is way m | {
"filepath": "src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php",
"language": "php",
"file_size": 7993,
"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\Mime\Tests\Part\Multipart;
use PHPUnit\Framework\TestCas... | $this->assertEquals('related', $r->getMediaSubtype());
$this->assertEquals([$a, $b, $c], $r->getParts());
$this->assertFalse($a->getHeaders()->has('Content-ID'));
$this->assertTrue($b->getHeaders()->has('Content-ID'));
| $r = new RelatedPart($a = new TextPart('content'), $b = new TextPart('HTML content', 'utf-8', 'html'), $c = new TextPart('HTML content again', 'utf-8', 'html'));
$this->assertEquals('multipart', $r->getMediaType());
| {
"filepath": "src/Symfony/Component/Mime/Tests/Part/Multipart/RelatedPartTest.php",
"language": "php",
"file_size": 1064,
"cut_index": 515,
"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\Mime\Tests\Test\Constraint;
use PHPUnit\Framework\ExpectationFail... | value "expectedValue"', $constraint->toString());
}
public function testFailureDescription()
{
$mailboxHeader = 'text@example.com';
$headers = new Headers();
$headers->addMailboxHeader($mailboxHeader, 'actualValue@examp | s EmailAddressContainsTest extends TestCase
{
public function testToString()
{
$constraint = new EmailAddressContains('headerName', 'expectedValue');
$this->assertSame('contains address "headerName" with | {
"filepath": "src/Symfony/Component/Mime/Tests/Test/Constraint/EmailAddressContainsTest.php",
"language": "php",
"file_size": 1393,
"cut_index": 524,
"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\Mime\Tests\Test\Constraint;
use PHPUnit\Framework\Expect... | ription()
{
$email = new Email();
$email->attach('attachment content', 'attachment.txt');
$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage('Failed asserting that the Email has sen | TestCase
{
public function testToString()
{
$constraint = new EmailAttachmentCount(1);
$this->assertSame('has sent "1" attachment(s)', $constraint->toString());
}
public function testFailureDesc | {
"filepath": "src/Symfony/Component/Mime/Tests/Test/Constraint/EmailAttachmentCountTest.php",
"language": "php",
"file_size": 1090,
"cut_index": 515,
"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\Mime\Tests\Test\Constraint;
use PHPUnit\Framework\Expectati... | ublic function testFailureDescription()
{
$headers = new Headers();
$headers->addMailboxHeader('headerName', 'test@example.com');
$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage( | s EmailHasHeaderTest extends TestCase
{
public function testToString()
{
$constraint = new EmailHasHeader('headerName');
$this->assertSame('has header "headerName"', $constraint->toString());
}
p | {
"filepath": "src/Symfony/Component/Mime/Tests/Test/Constraint/EmailHasHeaderTest.php",
"language": "php",
"file_size": 1166,
"cut_index": 518,
"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\Mime\Tests\Test\Constraint;
use PHPUnit\Framework\Expectati... | tFailureDescription()
{
$expectedValue = 'expectedValue';
$email = new Email();
$email->html('actualValue')->text($expectedValue);
$this->expectException(ExpectationFailedException::class);
$this->expectExceptio | TestCase
{
public function testToString()
{
$constraint = new EmailHtmlBodyContains('expectedValue');
$this->assertSame('contains "expectedValue"', $constraint->toString());
}
public function tes | {
"filepath": "src/Symfony/Component/Mime/Tests/Test/Constraint/EmailHtmlBodyContainsTest.php",
"language": "php",
"file_size": 1164,
"cut_index": 518,
"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\Mime\Tests\Test\Constraint;
use PHPUnit\Framework\Expectati... | tFailureDescription()
{
$expectedValue = 'expectedValue';
$email = new Email();
$email->html($expectedValue)->text('actualValue');
$this->expectException(ExpectationFailedException::class);
$this->expectExceptio | TestCase
{
public function testToString()
{
$constraint = new EmailTextBodyContains('expectedValue');
$this->assertSame('contains "expectedValue"', $constraint->toString());
}
public function tes | {
"filepath": "src/Symfony/Component/Mime/Tests/Test/Constraint/EmailTextBodyContainsTest.php",
"language": "php",
"file_size": 1164,
"cut_index": 518,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Crypto;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\Mime... | n7PDdZ8EuuxlAa7oNo/38YYV+5Oki93m
io6rGV8zLMGLLygAB1sJaJVP5W9wm0RLY776YFL4V/nekA5ZTnA4+KaIYwIDAQAB
AoGAJLhjgoKkA8kI1omkxAjDWRlmqD1Ga4hKy2FYd/GxbnPVVZ+0atUG/Cvarw2d
kWVZjkxcr8nFoPTrwHOJQgUyOXWLuIuirznoTtDKzC+4JlDsZJd8hkVohqwKfdPA
| ss DkimSignerTest extends TestCase
{
private static string $pk = <<<EOF
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC6lQYNOMaboSOE/c2KNl8Rwk61zoMXrEmXC926an3/jHrtj9wB
ndP2DY2nUyz0vpmJlcDOjDwTGs8U/C7z | {
"filepath": "src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php",
"language": "php",
"file_size": 8318,
"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\Mime\Tests\Crypto;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Mime\Crypto\SMimeEncrypter;
use Symfony\Component\Mime\Cryp... | ')
->from('noreply@example.com')
->text('El Barto was not here');
$message->getHeaders()->addIdHeader('Message-ID', 'some@id');
$encrypter = new SMimeEncrypter($this->samplesDir.'encrypt.crt');
$encryptedMe | estEncryptMessage()
{
$message = (new Email())
->date(new \DateTimeImmutable('2019-04-07 10:36:30', new \DateTimeZone('Europe/Paris')))
->to('fabien@symfony.com')
->subject('Testing | {
"filepath": "src/Symfony/Component/Mime/Tests/Crypto/SMimeEncrypterTest.php",
"language": "php",
"file_size": 4289,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Crypto;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Mime\Crypto\SMimeEncrypter;
use Symfony\Component\Mime\Crypto\SMimeSigner;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Header\Headers;
use Symfo... | ->addMailboxListHeader('From', ['fabien@symfony.com']),
new TextPart('content')
);
$signer = new SMimeSigner($this->samplesDir.'sign.crt', $this->samplesDir.'sign.key');
$signedMessage = $signer->sign($m |
public function testSignedMessage()
{
$message = new Message(
(new Headers())
->addDateHeader('Date', new \DateTimeImmutable('2019-04-07 10:36:30', new \DateTimeZone('Europe/Paris')))
| {
"filepath": "src/Symfony/Component/Mime/Tests/Crypto/SMimeSignerTest.php",
"language": "php",
"file_size": 6948,
"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\Mime\Tests\Crypto;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Exception\RuntimeException... | ) {
@unlink($file);
}
$this->tmpFiles = [];
}
protected function generateTmpFilename(): string
{
return $this->tmpFiles[] = tempnam(sys_get_temp_dir(), 'sf_mime_');
}
protected function normalizeFil | ];
protected function setUp(): void
{
$this->samplesDir = str_replace('\\', '/', realpath(__DIR__.'/../').'/_data/');
}
protected function tearDown(): void
{
foreach ($this->tmpFiles as $file | {
"filepath": "src/Symfony/Component/Mime/Tests/Crypto/SMimeTestCase.php",
"language": "php",
"file_size": 2393,
"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\Mime\Tests\Header;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Header\DateHeader;
class ... | imeImmutable());
$header->setDateTime($dateTime = new \DateTimeImmutable());
$this->assertEquals($dateTime, $header->getDateTime());
}
public function testDateTimeIsConvertedToImmutable()
{
$dateTime = new \DateTime();
| er('Date', $dateTime = new \DateTimeImmutable());
$this->assertEquals($dateTime, $header->getDateTime());
}
public function testDateTimeCanBeSetBySetter()
{
$header = new DateHeader('Date', new \DateT | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/DateHeaderTest.php",
"language": "php",
"file_size": 2869,
"cut_index": 563,
"middle_length": 229
} |
ny\Component\Mime\Header\Headers;
use Symfony\Component\Mime\Header\IdentificationHeader;
use Symfony\Component\Mime\Header\MailboxListHeader;
use Symfony\Component\Mime\Header\PathHeader;
use Symfony\Component\Mime\Header\UnstructuredHeader;
class HeadersTest extends TestCase
{
public function testAddMailboxListH... | aders->get('Date'));
}
public function testAddTextHeaderDelegatesToFactory()
{
$headers = new Headers();
$headers->addTextHeader('Subject', 'some text');
$this->assertNotNull($headers->get('Subject'));
}
public |
public function testAddDateHeaderDelegatesToFactory()
{
$dateTime = new \DateTimeImmutable();
$headers = new Headers();
$headers->addDateHeader('Date', $dateTime);
$this->assertNotNull($he | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/HeadersTest.php",
"language": "php",
"file_size": 12834,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Header;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Header\IdentificationHeader;
class IdentificationHeaderTest extends TestCase
{
public function testValueMatchesMsgIdSpec()
{
/* -- RFC 2822, 3.6.4.
messa... | ld-quote = DQUOTE *(qtext / quoted-pair) DQUOTE
no-fold-literal = "[" *(dtext / quoted-pair) "]"
*/
$header = new IdentificationHeader('Message-ID', 'id-left@id-right');
$this->assertEquals('<id-left@id-righ | = [CFWS] "<" id-left "@" id-right ">" [CFWS]
id-left = dot-atom-text / no-fold-quote / obs-id-left
id-right = dot-atom-text / no-fold-literal / obs-id-right
no-fo | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php",
"language": "php",
"file_size": 5820,
"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\Mime\Tests\Header;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Header\MailboxHeader;
class MailboxHeade... | header->setBody($address = new Address('helene@symfony.com'));
$this->assertEquals($address, $header->getAddress());
$this->assertEquals($address, $header->getBody());
$header->setAddress($address = new Address('thomas@symfony.com') | ddress, $header->getAddress());
$this->assertEquals($address, $header->getBody());
}
public function testAddress()
{
$header = new MailboxHeader('Sender', new Address('fabien@symfony.com'));
$ | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php",
"language": "php",
"file_size": 3744,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Header;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Header\MailboxListHeader;
class MailboxListHeaderTest extends TestCase
{
// RFC 2822, 3.6.2 for all tests
public function testMailbox... | ris@swiftmailer.org>'], $header->getAddressStrings());
}
public function testAddressCanBeReturnedForAddress()
{
$header = new MailboxListHeader('From', $addresses = [new Address('chris@swiftmailer.org')]);
$this->assertEquals($ | gs());
}
public function testMailboxIsRenderedForNameAddress()
{
$header = new MailboxListHeader('From', [new Address('chris@swiftmailer.org', 'Chris Corbyn')]);
$this->assertEquals(['Chris Corbyn <ch | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php",
"language": "php",
"file_size": 5710,
"cut_index": 716,
"middle_length": 229
} |
ds TestCase
{
private string $lang = 'en-us';
public function testValueIsReturnedVerbatim()
{
$header = new ParameterizedHeader('Content-Type', 'text/plain');
$this->assertEquals('text/plain', $header->getValue());
}
public function testParametersAreAppended()
{
/* -- R... | " / ":" / "\" / <">
"/" / "[" / "]" / "?" / "="
; Must be in quoted-string,
; to use within parameter values
*/
$header = new ParameterizedHeader('Content-Type', 'text/plain');
| ase-insensitive.
value := token / quoted-string
token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
or tspecials>
tspecials := "(" / ")" / "<" / ">" / "@" /
"," / "; | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/ParameterizedHeaderTest.php",
"language": "php",
"file_size": 12586,
"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\Mime\Tests\Header;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Address;
use Symfony\Compo... | new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
}
public function testValueIsAngleAddrWithValidAddress()
{
/* -- RFC 2822, 3.6.7.
return = "Return-Path:" path CRLF
path | new Address('chris@swiftmailer.org'));
$this->assertEquals($address, $header->getAddress());
}
public function testAddressMustComplyWithRfc2822()
{
$this->expectException(\Exception::class);
| {
"filepath": "src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php",
"language": "php",
"file_size": 2541,
"cut_index": 563,
"middle_length": 229
} |
TestCase
{
public function testGetNameReturnsNameVerbatim()
{
$header = new UnstructuredHeader('Subject', '');
$this->assertEquals('Subject', $header->getName());
}
public function testGetValueReturnsValueVerbatim()
{
$header = new UnstructuredHeader('Subject', 'Test');
... | oString());
}
public function testLongHeadersAreFoldedAtWordBoundary()
{
/* -- RFC 2822, 2.2.3
Each header field is logically a single line of characters comprising
the field name, the colon, and the field body. For co | of a field name, followed by a colon
(":"), followed by a field body, and terminated by CRLF.
*/
$header = new UnstructuredHeader('Subject', 'Test');
$this->assertEquals('Subject: Test', $header->t | {
"filepath": "src/Symfony/Component/Mime/Tests/Header/UnstructuredHeaderTest.php",
"language": "php",
"file_size": 9982,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Encoder\Base64Encoder;
class Base64EncoderTest extends TestCase
{
/*
There's really no point in testing the entire base64 encoding to the
level QP encoding has been ... | treated as 4 concatenated 6-bit groups, each
of which is translated into a single digit in the base64 alphabet.
*/
$encoder = new Base64Encoder();
$this->assertEquals('MTIz', $encoder->encodeString('123'), '3 bytes of inp | esents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating 3 8bit input groups.
These 24 bits are then | {
"filepath": "src/Symfony/Component/Mime/Tests/Encoder/Base64EncoderTest.php",
"language": "php",
"file_size": 6436,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Encoder\QpEncoder;
class QpEncoderTest extends TestCase
{
/* -- RFC 2045, 6.7 --
(1) (General 8bit representation) Any octet, except a CR or
LF tha... | used; lowercase letters are not allowed. Thus, for
example, the decimal value 12 (US-ASCII form feed) can
be represented by "=0C", and the decimal value 61 (US-
ASCII EQUAL SIGN) can be represe | hexadecimal representation of the octet's value. The
digits of the hexadecimal alphabet, for this purpose,
are "0123456789ABCDEF". Uppercase letters must be
| {
"filepath": "src/Symfony/Component/Mime/Tests/Encoder/QpEncoderTest.php",
"language": "php",
"file_size": 9130,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Encoder\QpMimeHeaderEncoder;
class QpMimeHeaderEncoderTest extends TestCase
{
public function testNameIsQ()
{
$encoder = new QpMimeHeaderEncoder();
$this... | DoesNotMatchRegularExpression('~[ \t]~', $encoder->encodeString("a \t b"), 'encoded-words in headers cannot contain LWSP as per RFC 2047.');
}
public function testSpaceIsRepresentedByUnderscore()
{
/* -- RFC 2047, 4.2.
(2) The | be used in
'encoded-text'. Space and tab characters are not allowed, so that
the beginning and end of an 'encoded-word' are obvious.
*/
$encoder = new QpMimeHeaderEncoder();
$this->assert | {
"filepath": "src/Symfony/Component/Mime/Tests/Encoder/QpMimeHeaderEncoderTest.php",
"language": "php",
"file_size": 5591,
"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\Mime\Tests\Encoder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Encoder\Rfc2231Encoder;
class Rfc2231EncoderTest extends TestCase
{
pri... | oken".
*/
public function testEncodingAsciiCharactersProducesValidToken()
{
$string = '';
foreach (range(0x00, 0x7F) as $octet) {
$char = pack('C', $octet);
$string .= $char;
}
$encoder = | r mentioning bytes can be represented as their octet values (e.g. %20 for
the SPACE character).
The tests here focus on how to use that representation to always generate text
which matches RFC 2045's definition of "t | {
"filepath": "src/Symfony/Component/Mime/Tests/Encoder/Rfc2231EncoderTest.php",
"language": "php",
"file_size": 4285,
"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\Mime\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjectio... | ;
$container->addCompilerPass(new AddMimeTypeGuesserPass());
$definition = new Definition(FileinfoMimeTypeGuesser::class);
$definition->addArgument('/path/to/magic/file');
$definition->addTag('mime.mime_type_guesser');
| Pass;
use Symfony\Component\Mime\FileinfoMimeTypeGuesser;
use Symfony\Component\Mime\MimeTypes;
class AddMimeTypeGuesserPassTest extends TestCase
{
public function testTags()
{
$container = new ContainerBuilder() | {
"filepath": "src/Symfony/Component/Mime/Tests/DependencyInjection/AddMimeTypeGuesserPassTest.php",
"language": "php",
"file_size": 2401,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Constraint;
use Symfony... | is->headerName, $this->expectedValue);
}
/**
* @param RawMessage $message
*/
protected function matches($message): bool
{
if (RawMessage::class === $message::class) {
throw new \LogicException('Unable to test | lic function __construct(
private string $headerName,
private string $expectedValue,
) {
}
public function toString(): string
{
return \sprintf('contains address "%s" with value "%s"', $th | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php",
"language": "php",
"file_size": 1935,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Constraint... | tches($message): bool
{
if (RawMessage::class === $message::class || Message::class === $message::class) {
throw new \LogicException('Unable to test a message attachment on a RawMessage or Message instance.');
}
ret | edValue,
) {
}
public function toString(): string
{
return \sprintf('has sent "%d" attachment(s)', $this->expectedValue);
}
/**
* @param RawMessage $message
*/
protected function ma | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailAttachmentCount.php",
"language": "php",
"file_size": 1252,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Cons... | :class === $message::class) {
throw new \LogicException('Unable to test a message header on a RawMessage instance.');
}
return $message->getHeaders()->has($this->headerName);
}
/**
* @param RawMessage $message
| unction toString(): string
{
return \sprintf('has header "%s"', $this->headerName);
}
/**
* @param RawMessage $message
*/
protected function matches($message): bool
{
if (RawMessage: | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailHasHeader.php",
"language": "php",
"file_size": 1129,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Constraint;
use Symfony... | * @param RawMessage $message
*/
protected function matches($message): bool
{
if (RawMessage::class === $message::class) {
throw new \LogicException('Unable to test a message header on a RawMessage instance.');
}
| derName,
private string $expectedValue,
) {
}
public function toString(): string
{
return \sprintf('has header "%s" with value "%s"', $this->headerName, $this->expectedValue);
}
/**
| {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php",
"language": "php",
"file_size": 1631,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Cons... | $message): bool
{
if (RawMessage::class === $message::class || Message::class === $message::class) {
throw new \LogicException('Unable to test a message HTML body on a RawMessage or Message instance.');
}
return str | ng $expectedText,
) {
}
public function toString(): string
{
return \sprintf('contains "%s"', $this->expectedText);
}
/**
* @param RawMessage $message
*/
protected function matches( | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailHtmlBodyContains.php",
"language": "php",
"file_size": 1248,
"cut_index": 518,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Constraint... | il) {
throw new \LogicException('Can only test a message subject on an Email instance.');
}
return str_contains((string) $other->getSubject(), $this->expectedSubjectValue);
}
protected function failureDescription($othe |
public function toString(): string
{
return \sprintf('contains subject with value "%s"', $this->expectedSubjectValue);
}
protected function matches($other): bool
{
if (!$other instanceof Ema | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailSubjectContains.php",
"language": "php",
"file_size": 1264,
"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\Mime\Test\Constraint;
use PHPUnit\Framework\Constraint\Cons... | $message): bool
{
if (RawMessage::class === $message::class || Message::class === $message::class) {
throw new \LogicException('Unable to test a message text body on a RawMessage or Message instance.');
}
return str | ng $expectedText,
) {
}
public function toString(): string
{
return \sprintf('contains "%s"', $this->expectedText);
}
/**
* @param RawMessage $message
*/
protected function matches( | {
"filepath": "src/Symfony/Component/Mime/Test/Constraint/EmailTextBodyContains.php",
"language": "php",
"file_size": 1248,
"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\Mime\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
abstract class AbstractMimeTypeGuesserTestCase extends Te... | {
$this->markTestSkipped('Guesser is not supported');
}
$cwd = getcwd();
chdir(__DIR__.'/Fixtures/mimetypes');
try {
$this->assertEquals('image/gif', $this->getGuesser()->guessMimeType('-test'));
| ;
@unlink($path);
}
}
abstract protected function getGuesser(): MimeTypeGuesserInterface;
public function testGuessWithLeadingDash()
{
if (!$this->getGuesser()->isGuesserSupported()) | {
"filepath": "src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php",
"language": "php",
"file_size": 4123,
"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\Mime\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\CharacterStream;
class CharacterStreamTest extends TestCase
{
public function t... | ream->read(2));
$this->assertSame(pack('C*', 0xD0, 0xBB), $stream->read(1));
$this->assertSame(pack('C*', 0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->read(3));
$this->assertSame(pack('C*', 0xD1, 0x85), $stream->read(1));
$ | 0xD1, 0x8E,
0xD0, 0xB1,
0xD1, 0x8B,
0xD1, 0x85
));
$this->assertSame(pack('C*', 0xD0, 0x94), $stream->read(1));
$this->assertSame(pack('C*', 0xD0, 0xB6, 0xD0, 0xBE), $st | {
"filepath": "src/Symfony/Component/Mime/Tests/CharacterStreamTest.php",
"language": "php",
"file_size": 3325,
"cut_index": 614,
"middle_length": 229
} |
use Symfony\Component\Mime\Test\Constraint\EmailHeaderSame;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\MimeMessageNormalizer;
use Symfony\C... | public function testUnserializeRejectsObjectInTypedCharsetProperty(int $slot)
{
$email = new Email();
$email->text('text body');
$email->html('html body');
$data = $email->__serialize();
$data[$slot] = new EmailT | public static bool $fired = false;
public function __toString(): string
{
self::$fired = true;
return '';
}
}
class EmailTest extends TestCase
{
#[DataProvider('provideTrampolineSlots')]
| {
"filepath": "src/Symfony/Component/Mime/Tests/EmailTest.php",
"language": "php",
"file_size": 31893,
"cut_index": 1331,
"middle_length": 229
} |
ponent\Mime\Exception\LogicException;
use Symfony\Component\Mime\Header\Headers;
use Symfony\Component\Mime\Header\MailboxListHeader;
use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\Message;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\Multipart\AlternativeP... | omponent\Serializer\Normalizer\PropertyNormalizer;
use Symfony\Component\Serializer\Serializer;
class MessageTest extends TestCase
{
public function testConstruct()
{
$m = new Message();
$this->assertNull($m->getBody());
$t | er\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\MimeMessageNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\C | {
"filepath": "src/Symfony/Component/Mime/Tests/MessageTest.php",
"language": "php",
"file_size": 14314,
"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\Mime\Tests;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Mime\Exception\... | r->registerGuesser(new class implements MimeTypeGuesserInterface {
public function isGuesserSupported(): bool
{
return false;
}
public function guessMimeType(string $mimeType): ?string
| esserTestCase
{
protected function getGuesser(): MimeTypeGuesserInterface
{
return new MimeTypes();
}
public function testUnsupportedGuesser()
{
$guesser = $this->getGuesser();
$guesse | {
"filepath": "src/Symfony/Component/Mime/Tests/MimeTypesTest.php",
"language": "php",
"file_size": 2958,
"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\Mime\Tests\Part;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Fr... | $template = (new SMimePart('body content', 'application', 'pkcs7-mime', []))->__serialize();
$template[$key] = new SMimePartTestToStringGadget();
$payload = \sprintf('O:%d:"%s":%d:{', \strlen(SMimePart::class), SMimePart::class, \count($ | self::$fired = true;
return '';
}
}
class SMimePartTest extends TestCase
{
#[DataProvider('provideTrampolineKeys')]
public function testUnserializeRejectsObjectInTypedStringProperty(string $key)
{
| {
"filepath": "src/Symfony/Component/Mime/Tests/Part/SMimePartTest.php",
"language": "php",
"file_size": 1662,
"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\Mime;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Exceptio... | *
* @param string $cmd The command to run to get the MIME type of a file
*/
public function __construct(
private string $cmd = 'file -b --mime -- %s 2>/dev/null',
) {
}
public function isGuesserSupported(): bool
{
| ments MimeTypeGuesserInterface
{
/**
* The $cmd pattern must contain a "%s" string that will be replaced
* with the file name to guess.
*
* The command output must start with the MIME type of the file.
| {
"filepath": "src/Symfony/Component/Mime/FileBinaryMimeTypeGuesser.php",
"language": "php",
"file_size": 2195,
"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\Mime;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfo... | e A magic file to use with the finfo instance
*
* @see https://php.net/finfo-open
*/
public function __construct(
private ?string $magicFile = null,
) {
}
public function isGuesserSupported(): bool
{
retu | sek <bschussek@gmail.com>
*/
class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
{
/**
* @var array<string, \finfo>
*/
private static $finfoCache = [];
/**
* @param string|null $magicFil | {
"filepath": "src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php",
"language": "php",
"file_size": 2007,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime;
use Symfony\Component\Mime\Exception\RuntimeException;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\Multipart\AlternativePart;
use Symfony\Component\Mime\Part\Multipart\MixedPart;
use Symfony\Component\Mime\Part\Multipart\... | ple" Email instance
$body = $message->getBody();
if ($body instanceof TextPart) {
return self::createEmailFromTextPart($message, $body);
}
if ($body instanceof AlternativePart) {
return self::createE | ble to convert the message to an email
*/
public static function toEmail(Message $message): Email
{
if ($message instanceof Email) {
return $message;
}
// try to convert to a "sim | {
"filepath": "src/Symfony/Component/Mime/MessageConverter.php",
"language": "php",
"file_size": 5161,
"cut_index": 716,
"middle_length": 229
} |
'application/fdf' => ['fdf'],
'application/fdt+xml' => ['fdt'],
'application/fits' => ['fits', 'fit', 'fts'],
'application/font-tdpfr' => ['pfr'],
'application/font-woff' => ['woff'],
'application/futuresplash' => ['swf', 'spl'],
'application/geo+json' => ['geojson', '... | ['stk'],
'application/ico' => ['ico'],
'application/ics' => ['vcs', 'ics', 'ifb', 'icalendar'],
'application/illustrator' => ['ai'],
'application/inkml+xml' => ['ink', 'inkml'],
'application/ipfix' => ['ipfix'],
| 'application/gxf' => ['gxf'],
'application/gzip' => ['gz'],
'application/har+json' => ['har'],
'application/hjson' => ['hjson'],
'application/hta' => ['hta'],
'application/hyperstudio' => | {
"filepath": "src/Symfony/Component/Mime/MimeTypes.php",
"language": "php",
"file_size": 200416,
"cut_index": 7068,
"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\Mime;
use Symfony\Component\Mime\Exception\LogicException;
/**
* @author Fabien Potencier <fabien@symf... | this->message)) {
return $this->message;
}
if (\is_resource($this->message)) {
return stream_get_contents($this->message, -1, 0);
}
$message = '';
foreach ($this->message as $chunk) {
| message,
) {
}
public function __destruct()
{
if (\is_resource($this->message)) {
fclose($this->message);
}
}
public function toString(): string
{
if (\is_string($ | {
"filepath": "src/Symfony/Component/Mime/RawMessage.php",
"language": "php",
"file_size": 2442,
"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\Mime\Part;
use Symfony\Component\Mime\Header\Headers;
/**
* @author Fabien Potencier <fabien@symfony.c... | turn $this->parts;
}
public function getMediaType(): string
{
return 'multipart';
}
public function getPreparedHeaders(): Headers
{
$headers = parent::getPreparedHeaders();
$headers->setHeaderParameter('Con | )
{
parent::__construct();
foreach ($parts as $part) {
$this->parts[] = $part;
}
}
/**
* @return AbstractPart[]
*/
public function getParts(): array
{
re | {
"filepath": "src/Symfony/Component/Mime/Part/AbstractMultipartPart.php",
"language": "php",
"file_size": 2288,
"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\Mime\Part;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Header\Headers;
/**
* @author Fabien Potencier <fabi... | nstanceof File && !$filename) {
$filename = $body->getFilename();
}
$contentType ??= $body instanceof File ? $body->getContentType() : 'application/octet-stream';
[$this->mediaType, $subtype] = explode('/', $contentType | ng|File $body Use a File instance to defer loading the file until rendering
*/
public function __construct($body, ?string $filename = null, ?string $contentType = null, ?string $encoding = null)
{
if ($body i | {
"filepath": "src/Symfony/Component/Mime/Part/DataPart.php",
"language": "php",
"file_size": 4109,
"cut_index": 614,
"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\Mime\Part;
use Symfony\Component\Mime\MimeTypes;
/**
*... | ON));
self::$mimeTypes ??= new MimeTypes();
return self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
}
public function getSize(): int
{
return filesize($this->path);
}
public function getF | $filename = null,
) {
}
public function getPath(): string
{
return $this->path;
}
public function getContentType(): string
{
$ext = strtolower(pathinfo($this->path, \PATHINFO_EXTENSI | {
"filepath": "src/Symfony/Component/Mime/Part/File.php",
"language": "php",
"file_size": 1095,
"cut_index": 515,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Part;
use Symfony\Component\Mime\Encoder\Base64ContentEncoder;
use Symfony\Component\Mime\Encoder\ContentEncoderInterface;
use Symfony\Component\Mime\Encoder\EightBitContentEncoder;
use Symfony\Component\Mime\Encoder\QpContentEncoder;
use Symfony\Compo... | private ?string $disposition = null;
private ?string $name = null;
private string $encoding;
private ?bool $seekable = null;
/**
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
| vate const DEFAULT_ENCODERS = ['quoted-printable', 'base64', '8bit'];
private static array $encoders = [];
/** @var resource|string|File */
private $body;
private ?string $charset;
private string $subtype;
| {
"filepath": "src/Symfony/Component/Mime/Part/TextPart.php",
"language": "php",
"file_size": 9125,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}
// load new map
$data = json_decode(file_get_contents('https://cdn.jsdelivr.net/gh/jshttp/mime-db/db.json'), true);
$new = [];
foreach ($data as $mimeType => $mimeTypeInformation) {... | if ('*' != $pattern[0] || '.' != $pattern[1]) {
continue;
}
$exts[] = substr($pattern, 2);
}
if (!$exts) {
continue;
}
$mt = strtolower((string) $node['type']);
$new[$mt] = array_merge($new | tents('https://gitlab.freedesktop.org/xdg/shared-mime-info/-/raw/master/data/freedesktop.org.xml.in'));
foreach ($xml as $node) {
$exts = [];
foreach ($node->glob as $glob) {
$pattern = (string) $glob['pattern'];
| {
"filepath": "src/Symfony/Component/Mime/Resources/bin/update_mime_types.php",
"language": "php",
"file_size": 5308,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Mime\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Exception\RfcComplianceException;
class... | s->assertEquals('Fabien', $a->getName());
$this->assertEquals('fabien@symfonï.com', $a->getAddress());
$this->assertEquals('"Fabien" <fabien@xn--symfon-nwa.com>', $a->toString());
$this->assertEquals('fabien@xn--symfon-nwa.com', $a- |
$this->assertEquals('fabien@xn--symfon-nwa.com', $a->toString());
$this->assertEquals('fabien@xn--symfon-nwa.com', $a->getEncodedAddress());
$a = new Address('fabien@symfonï.com', 'Fabien');
$thi | {
"filepath": "src/Symfony/Component/Mime/Tests/AddressTest.php",
"language": "php",
"file_size": 6363,
"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\Mime\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Message;
use Symfony\Component\Mime\MessageConvert... | content'));
$this->assertConversion((clone $email)->html('HTML content <img src="cid:test.jpg" />'));
$this->assertConversion((clone $email)
->text('text content')
->html('HTML content <img src="cid:test.jpg" />')
| pes/test.gif');
$email = (new Email())->from('fabien@symfony.com')->to('you@example.com');
$this->assertSame($email, MessageConverter::toEmail($email));
$this->assertConversion((clone $email)->text('text | {
"filepath": "src/Symfony/Component/Mime/Tests/MessageConverterTest.php",
"language": "php",
"file_size": 3397,
"cut_index": 614,
"middle_length": 229
} |
der\Headers;
use Symfony\Component\Mime\Header\IdentificationHeader;
use Symfony\Component\Mime\Header\ParameterizedHeader;
use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
class Dat... | assertEquals(base64_encode('content'), implode('', iterator_to_array($p->bodyToIterable())));
$this->assertEquals('application', $p->getMediaType());
$this->assertEquals('octet-stream', $p->getMediaSubType());
$p = new DataPart('co | s(base64_encode('content'), $p->bodyToString());
$this->assertEquals(base64_encode('content'), implode('', iterator_to_array($p->bodyToIterable())));
// bodyToIterable() can be called several times
$this-> | {
"filepath": "src/Symfony/Component/Mime/Tests/Part/DataPartTest.php",
"language": "php",
"file_size": 9841,
"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\Mime;
use Symfony\Component\Mime\Exception\LogicException;
use Symfony\Component\Mime\Header\Headers;
use Symfony\Component\Mime\Part\AbstractPart;
use Sym... | this->headers;
if (null !== $this->body) {
$this->body = clone $this->body;
}
}
/**
* @return $this
*/
public function setBody(?AbstractPart $body): static
{
$this->body = $body;
retu | ?Headers $headers = null,
private ?AbstractPart $body = null,
) {
$this->headers = $headers ? clone $headers : new Headers();
}
public function __clone()
{
$this->headers = clone $ | {
"filepath": "src/Symfony/Component/Mime/Message.php",
"language": "php",
"file_size": 4430,
"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\Mime\HtmlToTextConverter;
use League\HTMLToMarkdown\HtmlConverter;
use League\HTMLToMark... | ter = new HtmlConverter([
'hard_break' => true,
'strip_tags' => true,
'remove_nodes' => 'head style',
]),
) {
}
public function convert(string $html, string $charset): string
{
return $th | ruct(
private HtmlConverterInterface $conver | {
"filepath": "src/Symfony/Component/Mime/HtmlToTextConverter/LeagueHtmlToMarkdownConverter.php",
"language": "php",
"file_size": 894,
"cut_index": 547,
"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\Mime\Part;
use Symfony\Component\Mime\Message;
use Symfony\Component\Mime\RawM... | public function getMediaType(): string
{
return 'message';
}
public function getMediaSubtype(): string
{
return 'rfc822';
}
public function getBody(): string
{
return $this->message->toString();
| {
if ($message instanceof Message) {
$name = $message->getHeaders()->getHeaderBody('Subject').'.eml';
} else {
$name = 'email.eml';
}
parent::__construct('', $name);
}
| {
"filepath": "src/Symfony/Component/Mime/Part/MessagePart.php",
"language": "php",
"file_size": 1514,
"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\Mime\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\DraftEm... | is->assertStringContainsString('X-Unsent: 1', $email);
}
public function testBccIsRemoved()
{
$email = (new DraftEmail())->text('some text')->bcc('sam@example.com')->toString();
$this->assertStringNotContainsString('sam@exampl | Body()
{
$email = (new DraftEmail())->text('some text')->toString();
$this->assertStringContainsString('some text', $email);
$this->assertStringContainsString('MIME-Version: 1.0', $email);
$th | {
"filepath": "src/Symfony/Component/Mime/Tests/DraftEmailTest.php",
"language": "php",
"file_size": 1511,
"cut_index": 537,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.