Commit Graph

531 Commits

Author SHA1 Message Date
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
Fabien Potencier f6c6cf7dc9 [Twig] Add NotificationEmail 2019-09-18 17:08:12 +02:00
Fabien Potencier 20f2a34e8c Merge branch '4.4'
* 4.4:
  [WebProfiler] Deprecated intercept_redirects in 4.4
  bump required symfony/contracts version
2019-09-16 21:21:57 +02:00
Christian Flothmann 343d01f63b bump required symfony/contracts version 2019-09-16 16:43:57 +02:00
Nicolas Grekas 6b6562cf13 Merge branch '4.4'
* 4.4: (21 commits)
  [appveyor] exclude tty group
  [HttpFoundation] Add types to private/final/internal methods and constructors.
  Add types to private/final/internal methods and constructors.
  SCA: minor code tweaks
  Tweak output
  [FrameworkBundle] Added --sort option for TranslationUpdateCommand
  [HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available
  [DI] generate preload.php file for PHP 7.4 in cache folder
  Allow version 2 of the contracts package.
  [Serializer] Allow multi-dimenstion object array in AbstractObjectNormalizer
  fixed typo
  [HttpKernel] Fix Apache mod_expires Session Cache-Control issue
  deprecated not passing dash symbol (-) to STDIN commands
  [VarDumper] display ellipsed FQCN for nested classes
  [VarDumper] Display fully qualified title
  [Mailer] Change the syntax for DSNs using failover or roundrobin
  Removed workaround introduced in 4.3
  [Console] Added support for definition list
  [OptionsResolver] Display full nested options hierarchy in exceptions
  New welcome page
  ...
2019-09-08 22:44:36 +02:00
Alexander M. Turek a1ee32039b Allow version 2 of the contracts package. 2019-09-08 12:38:38 +02:00
Nicolas Grekas bfdf79e25d Merge branch '4.4'
* 4.4:
  [MonologBridge] Bump min version for monolog ^1.25 and drop dead code
  [Bridge/Twig] use tty group on testLintDefaultPaths
  fix tests mocking final events
2019-09-06 18:03:39 +02:00
Grégoire Pineau 1e19c65b67 [MonologBridge] Bump min version for monolog ^1.25 and drop dead code 2019-09-06 16:22:32 +02:00
Nicolas Grekas 45f650ebda Merge branch '4.4'
* 4.4:
  [Routing] fix static route reordering when a previous dynamic route conflicts
  conflict with HttpKernel 5
  Return null as Expire header if it was set to null
  bug #33370 Fix import statement typo in NullCache (adrienbrault)
  [ProxyManager] remove ProxiedMethodReturnExpression polyfill
  fix dumping not inlined scalar tag values
  Fix import statement typo in NullCache
  [DoctrineBridge] Allow configuring class names through methods instead of class parameters
2019-08-30 14:51:40 +02:00
Nicolas Grekas 22ed6247fa Merge branch '4.3' into 4.4
* 4.3:
  [Routing] fix static route reordering when a previous dynamic route conflicts
  Return null as Expire header if it was set to null
  bug #33370 Fix import statement typo in NullCache (adrienbrault)
  [ProxyManager] remove ProxiedMethodReturnExpression polyfill
  fix dumping not inlined scalar tag values
2019-08-30 14:49:06 +02:00
Nicolas Grekas 247815d21c Merge branch '3.4' into 4.3
* 3.4:
  Return null as Expire header if it was set to null
  [ProxyManager] remove ProxiedMethodReturnExpression polyfill
  fix dumping not inlined scalar tag values
2019-08-30 14:41:22 +02:00
Nicolas Grekas 792f93018a [ProxyManager] remove ProxiedMethodReturnExpression polyfill 2019-08-29 16:54:55 +02:00
Nicolas Grekas 21b87024f0 Use PHP 7.4 on deps=low 2019-08-22 08:53:14 +02:00
Alexander M. Turek f30edcab65 Support for Twig 3. 2019-08-21 14:55:51 +02:00
Nicolas Grekas 2a6cd1578d Merge branch '4.4'
* 4.4:
  [WebLink] implement PSR-13 directly
2019-08-12 17:29:44 +02:00
Nicolas Grekas b570ee1103 [WebLink] implement PSR-13 directly 2019-08-12 15:51:36 +02:00
Nicolas Grekas 547b9b8fc3 Merge branch '4.4'
* 4.4:
  [HttpKernel] fixed class having a leading \ in a route controller
  [HttpKernel] trim the leading backslash in the controller init
  Bump minimal requirements
  Use PHPUnit 8.3 on Travis when possible
2019-08-09 14:41:16 +02:00
Nicolas Grekas 24858f2aee Merge branch '4.3' into 4.4
* 4.3:
  Bump minimal requirements
  Use PHPUnit 8.3 on Travis when possible
2019-08-09 14:40:26 +02:00
Nicolas Grekas 07cf927237 Merge branch '3.4' into 4.3
* 3.4:
  Bump minimal requirements
  Use PHPUnit 8.3 on Travis when possible
2019-08-09 14:37:48 +02:00
Jérémy Derussé 41d94c3226
Bump minimal requirements 2019-08-09 13:59:47 +02:00
Nicolas Grekas c6409da7ef Merge branch '4.4'
* 4.4:
  fix merge
  Fix inconsistent return points.
  pass translation parameters to the trans filter
  [Mime] fixed wrong mimetype
  [ProxyManagerBridge] Polyfill for unmaintained version
  [HttpClient] Declare `$active` first to prevent weird issue
  Remove deprecated assertContains
  [HttpClient] fix tests
  SCA: dropped unused mocks, duplicate import and a function alias usage
  Added correct plural for box -> boxes
  [Config] fix test
  Fix remaining tests
  fix getName() when transport is null
  [Console] Check for ErrorHandler classes
  Improve fa (persian) translation
2019-08-07 14:07:17 +02:00
Nicolas Grekas a0c2aa8302 Merge branch '4.3' into 4.4
* 4.3:
  Fix inconsistent return points.
  pass translation parameters to the trans filter
  [Mime] fixed wrong mimetype
  [ProxyManagerBridge] Polyfill for unmaintained version
  [HttpClient] Declare `$active` first to prevent weird issue
  Remove deprecated assertContains
  [HttpClient] fix tests
  SCA: dropped unused mocks, duplicate import and a function alias usage
  Added correct plural for box -> boxes
  [Config] fix test
  Fix remaining tests
  Improve fa (persian) translation
2019-08-07 14:00:28 +02:00
Nicolas Grekas 3cd7726d0d Merge branch '3.4' into 4.3
* 3.4:
  [ProxyManagerBridge] Polyfill for unmaintained version
  SCA: dropped unused mocks, duplicate import and a function alias usage
  [Config] fix test
  Improve fa (persian) translation
2019-08-07 10:30:22 +02:00
Jérémy Derussé 33f722d86e [ProxyManagerBridge] Polyfill for unmaintained version 2019-08-07 10:25:59 +02:00