Commit Graph

554 Commits

Author SHA1 Message Date
Fabien Potencier 4fe2b4d1d5 Bump min Doctrine DBAL requirement to 2.10 2020-05-22 19:21:20 +02:00
Nicolas Grekas 430b884570 Merge branch '5.1'
* 5.1:
  [PhpUnitBridge] fix leftover
  [PhpUnitBridge] fix installing under PHP >= 8
  Use ">=" for the "php" requirement
  bump icu 67.1
  [DI] Remove preload primitive types
  [Validator] Add missing translations of nn locale
  [HttpKernel] Fix that the `Store` would not save responses with the X-Content-Digest header present
  [Intl] bump icu 67.1
  [Validator] allow passing a validator to Validation::createCallable()
2020-05-20 19:44:07 +02:00
Nicolas Grekas e65cdb685f Merge branch '5.0' into 5.1
* 5.0:
  [PhpUnitBridge] fix leftover
  [PhpUnitBridge] fix installing under PHP >= 8
  Use ">=" for the "php" requirement
  bump icu 67.1
2020-05-20 19:43:50 +02:00
Nicolas Grekas b429b15eb5 Merge branch '4.4' into 5.0
* 4.4:
  [PhpUnitBridge] fix leftover
  [PhpUnitBridge] fix installing under PHP >= 8
  Use ">=" for the "php" requirement
  bump icu 67.1
2020-05-20 19:38:26 +02:00
Nicolas Grekas f8aa0873cf Use ">=" for the "php" requirement 2020-05-20 10:37:50 +02:00
Fabien Potencier 25c4889c8e updated version to 5.2 2020-05-16 14:09:30 +02:00
Nicolas Grekas f8616f8eae Merge branch '5.0'
* 5.0:
  [PhpUnitBridge] fix bad test
  [4.4] CS fixes
  [3.4] CS fixes
  Disable phpunit verbosity
  Queue name is a required parameter
  [FrameworkBundle] display actual target for error in AssetsInstallCommand
  Remove patches for Doctrine bugs and deprecations
  [Mime] fix bad method call on "EmailAddressContains"
  [DI][EventDispatcher] added contract for implementation
2020-05-08 14:36:29 +02:00
Nicolas Grekas 0b34b39cc8 Merge branch '4.4' into 5.0
* 4.4:
  [PhpUnitBridge] fix bad test
  [4.4] CS fixes
  [3.4] CS fixes
  Disable phpunit verbosity
  Queue name is a required parameter
  [FrameworkBundle] display actual target for error in AssetsInstallCommand
  Remove patches for Doctrine bugs and deprecations
  [Mime] fix bad method call on "EmailAddressContains"
  [DI][EventDispatcher] added contract for implementation
2020-05-08 14:34:39 +02:00
Nicolas Grekas 2dbfeb9db9 Merge branch '3.4' into 4.4
* 3.4:
  [FrameworkBundle] display actual target for error in AssetsInstallCommand
  Remove patches for Doctrine bugs and deprecations
  [DI][EventDispatcher] added contract for implementation
2020-05-08 11:58:40 +02:00
Grégoire Paris 2f305cdc83 Remove patches for Doctrine bugs and deprecations 2020-05-08 11:45:13 +02:00
Nicolas Grekas 02d9597a41 Merge branch '5.0'
* 5.0:
  Force doctrine/dbal <=2.10.2 when testing
2020-05-05 15:53:42 +02:00
Nicolas Grekas cd21c8208e Merge branch '4.4' into 5.0
* 4.4:
  Force doctrine/dbal <=2.10.2 when testing
2020-05-05 15:53:15 +02:00
Nicolas Grekas f8bedf4e79 Merge branch '3.4' into 4.4
* 3.4:
  Force doctrine/dbal <=2.10.2 when testing
2020-05-05 15:52:57 +02:00
Nicolas Grekas d1953d61cd Force doctrine/dbal <=2.10.2 when testing 2020-05-05 15:43:18 +02:00
Jérémy Derussé 7c4888eed1 [AmazonSqsMessenger] Use AsyncAws to handle SQS communication 2020-05-03 18:22:01 +02:00
Jérémy Derussé 21243874bc [Mailer] Use AsyncAws to handle SES requests 2020-05-03 16:23:41 +02:00
Nicolas Grekas 6dc7d8b211 Merge branch '5.0'
* 5.0:
  [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions
  [Messenger] Make sure redis transports are initialized correctly
  Remove return type for Twig function workflow_metadata()
  [DI] fix typo
2020-04-15 18:09:08 +02:00
Nicolas Grekas 4f8f3747d3 Merge branch '4.4' into 5.0
* 4.4:
  [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions
  [Messenger] Make sure redis transports are initialized correctly
  Remove return type for Twig function workflow_metadata()
  [DI] fix typo
2020-04-15 17:59:10 +02:00
soyuka cfd5a29eaf [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions 2020-04-15 17:55:41 +02:00
Nicolas Grekas 53b0f63bc3 [String] leverage Stringable from PHP 8 2020-03-13 11:54:27 +01:00
Grégoire Pineau c3f14dd0f4 [UID] Added the component + Added support for UUID 2020-03-12 18:21:37 +01:00
Nicolas Grekas ef113feeb3 [HttpClient] Add portable HTTP/2 implementation based on Amp's HTTP client 2020-03-02 14:21:45 +01:00
Nicolas Grekas 3e35d8e9e3 Leverage trigger_deprecation() from symfony/deprecation-contracts 2020-02-08 15:04:50 +01:00
Nicolas Grekas e9f0cfe9db Merge branch '5.0'
* 5.0: (31 commits)
  [HttpClient] NativeHttpClient should not send >1.1 protocol version
  [HttpClient] fix support for non-blocking resource streams
  [Mailer] Make sure you can pass custom headers to Mailgun
  [Mailer] Remove line breaks in email attachment content
  Update links to documentation
  [Validator] Add the missing translations for the Arabic (ar) locale
  ensure to expect no validation for the right reasons
  [Security-Guard] fixed 35203 missing name tag in param docblock
  [HttpClient] fix casting responses to PHP streams
  [PhpUnitBridge] Add test case for @expectedDeprecation annotation
  [PhpUnitBridge][SymfonyTestsListenerTrait] Remove $testsWithWarnings stack
  [FrameworkBundle] Fix getUser() phpdoc in AbstractController
  [Mailer] Fix addresses management in Sendgrid API payload
  [Mailer][MailchimpBridge] Fix missing attachments when sending via Mandrill API
  [Mailer][MailchimpBridge] Fix incorrect sender address when sender has name
  [HttpClient] fix capturing SSL certificates with NativeHttpClient
  Update year in license files
  Update year in license files
  [TwigBridge][Form] Added missing help messages in form themes
  Update year in license files
  ...
2020-01-04 15:20:45 +01:00
Nicolas Grekas 4c790b0589 doctrine/doctrine-bundle ^1.5 is not compatible with Symfony 5 2019-12-30 18:22:15 +01:00
Nicolas Grekas 331765b95d Merge branch '5.0'
* 5.0:
  Fix leftover from doctrine/persistence < 1.3
  Require doctrine/persistence ^1.3
2019-12-12 16:10:59 +01:00
Nicolas Grekas 9a88f527a6 Merge branch '4.4' into 5.0
* 4.4:
  Fix leftover from doctrine/persistence < 1.3
  Require doctrine/persistence ^1.3
2019-12-12 16:09:39 +01:00
Nicolas Grekas 866de0fb8b Merge branch '4.3' into 4.4
* 4.3:
  Require doctrine/persistence ^1.3
2019-12-12 16:02:38 +01:00
Nicolas Grekas ce5dcb96c1 Require doctrine/persistence ^1.3 2019-12-12 15:53:41 +01:00
Nicolas Grekas 1b4ab81085 Merge branch '5.0'
* 5.0:
  [Routing] fix tests
  [DI] minor cleanup
  [Form] group constraints when calling the validator
  Remove wrong @group legacy annotations
  [DependencyInjection] Fix dumping multiple deprecated aliases
  allow button names to start with uppercase letter
  Allow PHP ^7.2.5
  States that the HttpClient provides a Http Async implementation
  [Routing] Fix ContainerLoader and ObjectLoaderTest
  [HttpKernel] Make ErrorListener::onKernelException()'s dispatcher argument explicit
  [HttpKernel] Drop deprecated ExceptionListener
  Removed extra whitespace
  [Security] Fix best encoder not wired using migrate_from
2019-11-21 08:02:52 +01:00
Nicolas Grekas 6194c2a96c Allow PHP ^7.2.5 2019-11-18 18:27:11 +01:00
Fabien Potencier e60a876201 updated version to 5.1 2019-11-17 19:31:35 +01:00
Nicolas Grekas cab859c4ae Merge branch '4.3' into 4.4
* 4.3:
  Add conflict rule for Monolog 2.
2019-11-17 15:08:02 +01:00
Nicolas Grekas 5188215fe9 Merge branch '3.4' into 4.3
* 3.4:
  Add conflict rule for Monolog 2.
2019-11-17 15:07:50 +01:00
Alexander M. Turek d53b91a45a Add conflict rule for Monolog 2. 2019-11-17 14:23:03 +01:00
Nicolas Grekas a3376918ba Merge branch '4.4'
* 4.4:
  [ErrorHandler] help finish the PR
  [ErrorHandler] merge and remove the ErrorRenderer component
2019-11-12 10:25:44 +01:00
Nicolas Grekas 6c9157bbc2 [ErrorHandler] merge and remove the ErrorRenderer component 2019-11-10 18:54:30 +01:00
Alexander M. Turek f2dc2d6d8b Disallow symfony/contracts v2. 2019-11-09 20:42:39 +01:00
Alexander M. Turek 4de3773979 Add parameter type declarations to contracts. 2019-11-09 10:18:34 +01:00
Nicolas Grekas e3261f4f7f [SecurityBundle] test with doctrine-bundle 2 2019-10-22 11:22:01 +02:00
Nicolas Grekas ff6078edd7 fix merge 2019-10-22 10:22:13 +02:00
Nicolas Grekas c4653e1f65 Restrict secrets management to sodium+filesystem 2019-10-19 20:26:39 +02:00
Nicolas Grekas 4e5c6ba0d3 Merge branch '4.4'
* 4.4:
  [travis] Fix build-packages script
  Add types to constructors and private/final/internal methods (Batch III)
  [HttpClient] Async HTTPlug client
  [Messenger] Allow to configure the db index on Redis transport
  [HttpClient] bugfix exploding values of headers
  [VarDumper] Made all casters final
  [VarDumper] Added a support for casting Ramsey/Uuid
  Remove useless testCanCheckIfTerminalIsInteractive test case
  [Validator] Add the missing translations for the Thai (\"th\") locale
  [Routing] gracefully handle docref_root ini setting
  [Validator] Fix ValidValidator group cascading usage
2019-10-07 14:45:39 +02:00
Nyholm 4fd593f869 [HttpClient] Async HTTPlug client 2019-10-07 13:21:57 +02:00
Fabien Potencier 7f97a3f11f [Notifier] added the component 2019-10-05 12:48:03 +02:00
Fabien Potencier 5d154fb304 feature #33553 [String] a new component for object-oriented strings management with an abstract unit system (nicolas-grekas, hhamon, gharlan)
This PR was merged into the 5.0-dev branch.

Discussion
----------

[String] a new component for object-oriented strings management with an abstract unit system

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This is a reboot of #22184 (thanks @hhamon for working on it) and a generalization of my previous work on the topic ([patchwork/utf8](https://github.com/tchwork/utf8)). Unlike existing libraries (including `patchwork/utf8`), this component provides a unified API for the 3 unit systems of strings: bytes, code points and grapheme clusters.

The unified API is defined by the `AbstractString` class. It has 2 direct child classes: `BinaryString` and `AbstractUnicodeString`, itself extended by `Utf8String` and `GraphemeString`.

All objects are immutable and provide clear edge-case semantics, using exceptions and/or (nullable) types!

Two helper functions are provided to create such strings:
```php
new GraphemeString('foo') == u('foo'); // when dealing with Unicode, prefer grapheme units
new BinaryString('foo') == b('foo');
```

`GraphemeString` is the most linguistic-friendly variant of them, which means it's the one ppl should use most of the time *when dealing with written text*.

Future ideas:
 - improve tests
 - add more docblocks (only where they'd add value!)
 - consider adding more methods in the string API (`is*()?`, `*Encode()`?, etc.)
 - first class Emoji support
 - merge the Inflector component into this one
 - use `width()` to improve `truncate()` and `wordwrap()`
 - move method `slug()` to a dedicated locale-aware service class
 - propose your ideas (send PRs after merge)

Out of (current) scope:
 - what [intl](https://php.net/intl) provides (collations, transliterations, confusables, segmentation, etc)

Here is the unified API I'm proposing in this PR, borrowed from looking at many existing libraries, but also Java, Python, JavaScript and Go.

```php
function __construct(string $string = '');
static function unwrap(array $values): array
static function wrap(array $values): array
function after($needle, bool $includeNeedle = false, int $offset = 0): self;
function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self;
function append(string ...$suffix): self;
function before($needle, bool $includeNeedle = false, int $offset = 0): self;
function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self;
function camel(): self;
function chunk(int $length = 1): array;
function collapseWhitespace(): self
function endsWith($suffix): bool;
function ensureEnd(string $suffix): self;
function ensureStart(string $prefix): self;
function equalsTo($string): bool;
function folded(): self;
function ignoreCase(): self;
function indexOf($needle, int $offset = 0): ?int;
function indexOfLast($needle, int $offset = 0): ?int;
function isEmpty(): bool;
function join(array $strings): self;
function jsonSerialize(): string;
function length(): int;
function lower(): self;
function match(string $pattern, int $flags = 0, int $offset = 0): array;
function padBoth(int $length, string $padStr = ' '): self;
function padEnd(int $length, string $padStr = ' '): self;
function padStart(int $length, string $padStr = ' '): self;
function prepend(string ...$prefix): self;
function repeat(int $multiplier): self;
function replace(string $from, string $to): self;
function replaceMatches(string $fromPattern, $to): self;
function slice(int $start = 0, int $length = null): self;
function snake(): self;
function splice(string $replacement, int $start = 0, int $length = null): self;
function split(string $delimiter, int $limit = null, int $flags = null): array;
function startsWith($prefix): bool;
function title(bool $allWords = false): self;
function toBinary(string $toEncoding = null): BinaryString;
function toGrapheme(): GraphemeString;
function toUtf8(): Utf8String;
function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
function truncate(int $length, string $ellipsis = ''): self;
function upper(): self;
function width(bool $ignoreAnsiDecoration = true): int;
function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self;
function __clone();
function __toString(): string;
```

`AbstractUnicodeString` adds these:
```php
static function fromCodePoints(int ...$codes): self;
function ascii(array $rules = []): self;
function codePoint(int $index = 0): ?int;
function folded(bool $compat = true): parent;
function normalize(int $form = self::NFC): self;
function slug(string $separator = '-'): self;
```

and `BinaryString`:
```php
static function fromRandom(int $length = 16): self;
function byteCode(int $index = 0): ?int;
function isUtf8(): bool;
function toUtf8(string $fromEncoding = null): Utf8String;
function toGrapheme(string $fromEncoding = null): GraphemeString;
```

Case insensitive operations are done with the `ignoreCase()` method.
e.g. `b('abc')->ignoreCase()->indexOf('B')` will return `1`.

For reference, CLDR transliterations (used in the `ascii()` method) are defined here:
https://github.com/unicode-org/cldr/tree/master/common/transforms

Commits
-------

dd8745aced [String] add more tests
82a00956bc [String] add tests
012e92a772 [String] a new component for object-oriented strings management with an abstract unit system
2019-09-26 10:14:27 +02:00
Nicolas Grekas 012e92a772 [String] a new component for object-oriented strings management with an abstract unit system 2019-09-25 16:38:20 +02:00
Nicolas Grekas 2d877b1804 Merge branch '4.4'
* 4.4:
  [Security/Http] fix typo in deprecation message
  [Security] Deprecate isGranted()/decide() on more than one attribute
  Fixed a minor typo in the UPGRADE to 5.0 guide
  Various tweaks 3.4
  Various tweaks 4.3
  [Security] Make stateful firewalls turn responses private only when needed
  [PhpUnit] Fix usleep mock return value
  Revert \"feature #33507 [WebProfiler] Deprecated intercept_redirects in 4.4 (dorumd)\"
  [TwigBundle] typo
  [TwigBundle] fix test case
  [Lock] use Predis\ClientInterface instead of Predis\Client
  Allow Twig 3
  Minor tweaks
  Fix version typo in deprecation notice
  [Form][SubmitType] Add "validate" option
  hint to the --parse-tags when parsing tags fails
  Make legacy "wrong" RFC2047 encoding apply only to one header
2019-09-24 18:05:28 +02:00
Nicolas Grekas 09f4eb5cd8 Allow Twig 3 2019-09-23 16:04:59 +02:00
Nicolas Grekas 4442a3f2ac Merge branch '4.4'
* 4.4:
  Re-enable previously failing PHP 7.4 test cases
  [PhpUnitBridge] fix uninitialized variable
  [ErrorRenderer] fix Cannot use object of type ErrorException as array exception #33631
  [Twig] Add missing check
  Revert "bug #33618 fix tests depending on other components' tests (xabbuh)"
  install from source to include components tests
  Fix undefined constant and other minor issues
  [Twig] Add NotificationEmail
  ensure compatibility with type resolver 0.5
  Call AssertEquals with proper parameters
  [DependencyInjection] Allow binding iterable and tagged services
  [Twig] Fix Twig config extra keys
  fix tests depending on other components' tests
  Fix lint commands frozen on empty stdin
2019-09-19 18:03:37 +02:00