Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
62
vendor/guzzlehttp/uri-template/AGENTS.md
vendored
Normal file
62
vendor/guzzlehttp/uri-template/AGENTS.md
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# Agent Guidelines
|
||||
|
||||
## Code and tooling
|
||||
|
||||
- All code must remain compatible with PHP 7.4. Run PHPStan and PHP-CS-Fixer
|
||||
only under a PHP 7.4.x runtime; never run either tool under any other PHP
|
||||
major.minor version.
|
||||
- Use fully qualified `#[\SensitiveParameter]` on concrete executable
|
||||
parameters when their established role normally carries a secret,
|
||||
credential-bearing aggregate, or confidential Guzzle-owned container, and
|
||||
the active frame can throw or invoke throwing code.
|
||||
- Repeat the attribute on every qualifying owned caller, callee, concrete trait
|
||||
method, and closure parameter. Do not add it to interfaces, abstract-only
|
||||
declarations, pure/no-realistic-throw helpers, assignment-only sites,
|
||||
arbitrary generic payloads, or completed non-recoverable derivatives.
|
||||
- For PHP 7.4 compatibility, put `#[\SensitiveParameter]` on its own line and
|
||||
the parameter on the following line, expand the complete parameter list, and
|
||||
never add a comma after the final parameter. Native trace redaction starts on
|
||||
PHP 8.2 and does not redact logs, messages, properties, wire traffic, captured
|
||||
variables, return values, or the separate backtrace `$this`/`object`.
|
||||
- Always pass an explicit character list to `trim()`, `ltrim()`, and `rtrim()`;
|
||||
never rely on the default characters.
|
||||
- Handle `preg_*` engine failures: when the result is used as data, test for
|
||||
`false` or `null` and throw a `\RuntimeException` including
|
||||
`preg_last_error_msg()`; boolean validation guards must compare strictly, such
|
||||
as `=== 1`, so an engine failure can only ever fail closed. Diagnostic
|
||||
escaping is the narrow exception: use a deterministic bytewise fallback rather
|
||||
than throwing, so it cannot obscure the original exception.
|
||||
- Anchor validation patterns to the true end of input with the `D` modifier or
|
||||
`\z`; a bare `$` accepts a trailing newline.
|
||||
- Never embed raw control bytes in exception messages and other diagnostics;
|
||||
escape or redact the offending value first.
|
||||
- Helper classes that expose only public static methods are `final` and have a
|
||||
private constructor.
|
||||
- Resist native PHP serialization when a class holds live state (streams,
|
||||
resources, handles, callbacks, credentials); plain data holders remain
|
||||
serializable.
|
||||
- To resist, `__serialize()` and `__unserialize()` both throw
|
||||
`\LogicException(static::class.' should never be serialized')` and its
|
||||
unserialized counterpart, implemented directly on the guarded class.
|
||||
- In general, numeric inputs should not accept non-finite floats. In situations
|
||||
where they are accepted and we need to cast to a string, we should branch on
|
||||
`\is_finite($value)`, using `(string) $value` for the finite case and
|
||||
`\is_nan($value) ? 'NAN' : ($value > 0 ? 'INF' : '-INF')` otherwise.
|
||||
- Never call `strtolower()`, `strtoupper()`, `strcasecmp()`, `stripos()`, or
|
||||
other locale-sensitive case functions; fold ASCII case with
|
||||
`strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')`
|
||||
and its inverse instead.
|
||||
- Changes in behavior need a `CHANGELOG.md` entry in the unreleased section of
|
||||
the target branch and an `UPGRADING.md` note when the behavior differs between
|
||||
major versions.
|
||||
|
||||
## Documentation
|
||||
|
||||
- Wrap markdown prose and PHPDoc text to 80 columns using greedy wrapping. Never
|
||||
split a markdown link or an inline code span across a line break; a line that
|
||||
cannot be broken may exceed the limit. Avoid em dashes.
|
||||
- Keep PHPDoc and the corresponding `docs/` pages in sync: shared prose is
|
||||
deliberately word-for-word identical, including boilerplate copied verbatim
|
||||
between related functions, so apply the same edit to every copy. Only
|
||||
formatting and linking may differ, such as a docs link becoming a PHPDoc
|
||||
`@see` tag; the wording must never drift.
|
||||
161
vendor/guzzlehttp/uri-template/CHANGELOG.md
vendored
Normal file
161
vendor/guzzlehttp/uri-template/CHANGELOG.md
vendored
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to `uri-template` will be documented in this file.
|
||||
|
||||
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## v2.0.1 - 2026-08-24
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for PHP 8.6
|
||||
|
||||
## v2.0.0 - 2026-07-20
|
||||
|
||||
### Changed
|
||||
|
||||
- Invalid URI template syntax now throws `InvalidArgumentException` instead of expanding partially
|
||||
- Literal template text is now validated and valid non-ASCII literals are pct-encoded
|
||||
- URI template variable names and modifiers are now validated according to RFC 6570
|
||||
- Prefix modifiers are now rejected for list and map values
|
||||
- Referenced variable values are now validated before expansion
|
||||
- Dense zero-indexed arrays are expanded as lists and sparse or mixed-key arrays as maps
|
||||
- `UriTemplate` is now non-instantiable; use `UriTemplate::expand()` statically
|
||||
- Nested null values in lists and maps are now treated as undefined members and omitted
|
||||
- Variable values must now be valid UTF-8; invalid byte sequences throw `InvalidArgumentException`
|
||||
- Booleans now expand as `1` and `0` at every nesting level
|
||||
- Non-finite floats now throw `InvalidArgumentException` instead of expanding as `INF` or `NAN`
|
||||
- Non-empty lists whose members are all null are now treated as defined variables
|
||||
- Variable specifier whitespace padding is now detected with the real whitespace set
|
||||
- `UriTemplate` now rejects native PHP serialization and unserialization
|
||||
- Referenced variable values are now detached and formed before expansion begins
|
||||
- Template syntax is now validated for every expression before variable values are formed
|
||||
- Stringable objects are now converted to strings once per value position while values are formed
|
||||
- Invalid UTF-8 in variable values and map keys is now rejected while values are formed
|
||||
- Finite floats are now converted to their expansion strings while values are formed
|
||||
- Exceptions thrown by `__toString()` now surface while values are formed, before any output exists
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed invalid template expressions being accepted as query and path-style parameter names
|
||||
- Fixed prefix modifiers counting bytes instead of Unicode code points and pct-encoded triplets
|
||||
- Fixed unsupported variable shapes producing warnings, conversion errors, or `Array` output
|
||||
- Fixed path-style parameter explode rendering empty members as `name=` instead of bare `name`
|
||||
- Fixed map keys not using the operator's allow set under reserved and fragment expansion
|
||||
- Fixed map explode rendering empty members as `name=` instead of bare `name` for unnamed operators
|
||||
- Fixed the documented variables array type rejecting integer keys for numeric variable names
|
||||
- Fixed all-null maps throwing with prefix modifiers instead of being skipped as undefined
|
||||
- Fixed prefix modifiers splitting Unicode code points encoded as multiple pct-encoded triplets
|
||||
- Fixed path-style composites rendering bare `name` instead of `name=` for empty joined members
|
||||
- Fixed null nested query array members being rejected for their keys instead of being omitted
|
||||
- Fixed float values expanding with the locale decimal separator on PHP versions before 8.0
|
||||
- Fixed PCRE engine failures on very long variable names being reported as invalid template syntax
|
||||
- Fixed invalid UTF-8 errors for list and map members not reporting the member path
|
||||
- Fixed exception messages embedding raw controls or malformed UTF-8 from expressions and map keys
|
||||
- Fixed invalid UTF-8 in literal text reported at the segment offset, not the first invalid byte
|
||||
- Fixed PCRE engine failures during literal text validation being reported as invalid UTF-8
|
||||
- Fixed PCRE engine failures during variable UTF-8 validation not being reported as runtime errors
|
||||
- Fixed PCRE engine failures during invalid UTF-8 offset recovery being reported as invalid UTF-8
|
||||
|
||||
### Removed
|
||||
|
||||
- Dropped support for PHP 7.2 and 7.3
|
||||
|
||||
## v1.0.10 - 2026-07-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed prefix modifiers counting Unicode code points and pct-encoded characters instead of bytes
|
||||
|
||||
## v1.0.9 - 2026-07-08
|
||||
|
||||
### Changed
|
||||
|
||||
- Pass explicit trim characters ahead of the PHP 8.6 trim default change
|
||||
|
||||
## v1.0.8 - 2026-06-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Report PCRE errors when URI template value encoding fails
|
||||
|
||||
## v1.0.7 - 2026-06-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed the operator's leading character being omitted when defined variables expand to empty strings
|
||||
- Fixed non-finite float values emitting coercion warnings on PHP 8.5
|
||||
|
||||
## v1.0.6 - 2026-05-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed empty nested arrays adding empty components to exploded query expansions
|
||||
- Fixed nested query array keys being double-encoded during exploded query expansion
|
||||
- Fixed reserved and fragment expansion preserving existing pct-encoded triplets in variable values
|
||||
|
||||
## v1.0.5 - 2025-08-22
|
||||
|
||||
### Changed
|
||||
|
||||
- Officially support PHP 8.5
|
||||
|
||||
## v1.0.4 - 2025-02-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Officially support PHP 8.4
|
||||
|
||||
## v1.0.3 - 2023-12-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated link to RFC 6570
|
||||
|
||||
## v1.0.2 - 2023-08-27
|
||||
|
||||
### Changed
|
||||
|
||||
- Officially support PHP 8.2 and 8.3
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed using `0` as an expanded value
|
||||
|
||||
## v1.0.1 - 2021-10-07
|
||||
|
||||
### Changed
|
||||
|
||||
- Officially support PHP 8.1
|
||||
|
||||
## v1.0.0 - 2021-08-14
|
||||
|
||||
### Changed
|
||||
|
||||
- Dropped support for PHP 7.1
|
||||
|
||||
## v0.2.0 - 2020-07-21
|
||||
|
||||
### Added
|
||||
|
||||
- Support PHP 7.1 and 8.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `GuzzleHttp\Utility\` to `GuzzleHttp\UriTemplate\`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Delegate RFC 3986 query string encoding to PHP
|
||||
- Fixed some bugs when parts ofs values are not strings
|
||||
|
||||
## v0.1.1 - 2020-06-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an error due to strict_types [d47d1b0a8e78a3fac1cd0f69d675fc9e06771ac8](https://github.com/guzzle/uri-template/commit/d47d1b0a8e78a3fac1cd0f69d675fc9e06771ac8)
|
||||
|
||||
## v0.1.0 - 2020-06-30
|
||||
|
||||
### Added
|
||||
- Moved the `UriTemplate` class in this package
|
||||
1
vendor/guzzlehttp/uri-template/CLAUDE.md
vendored
Normal file
1
vendor/guzzlehttp/uri-template/CLAUDE.md
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
@AGENTS.md
|
||||
23
vendor/guzzlehttp/uri-template/LICENSE
vendored
Normal file
23
vendor/guzzlehttp/uri-template/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Michael Dowling <mtdowling@gmail.com>
|
||||
Copyright (c) 2020 George Mponos <gmponos@gmail.com>
|
||||
Copyright (c) 2020 Graham Campbell <hello@gjcampbell.co.uk>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
81
vendor/guzzlehttp/uri-template/README.md
vendored
Normal file
81
vendor/guzzlehttp/uri-template/README.md
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# Guzzle URI Template
|
||||
|
||||
`guzzlehttp/uri-template` expands
|
||||
[RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570) URI templates in PHP.
|
||||
It turns templates such as `/users/{id}{?tab}` into concrete URI strings using
|
||||
values from an array.
|
||||
|
||||
Use this package when an API describes paths or links with URI templates. If you
|
||||
only need to send HTTP requests, start with
|
||||
[`guzzlehttp/guzzle`](https://github.com/guzzle/guzzle/blob/8.0/README.md);
|
||||
install this package directly when your application needs URI template
|
||||
expansion.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
composer require guzzlehttp/uri-template
|
||||
```
|
||||
|
||||
## Version Guidance
|
||||
|
||||
| Version | Status | PHP Version |
|
||||
|---------|--------------|--------------|
|
||||
| 2.0 | Latest | >=7.4,<8.7 |
|
||||
| 1.0 | Maintenance | >=7.2.5,<8.7 |
|
||||
|
||||
## Quick Start
|
||||
|
||||
```php
|
||||
use GuzzleHttp\UriTemplate\UriTemplate;
|
||||
|
||||
$uri = UriTemplate::expand('/users/{id}{?tab}', [
|
||||
'id' => 123,
|
||||
'tab' => 'settings',
|
||||
]);
|
||||
|
||||
echo $uri;
|
||||
// /users/123?tab=settings
|
||||
```
|
||||
|
||||
The first argument is an RFC 6570 URI template. The second argument is an array
|
||||
of variables. Variable names in the array must match the names used by the
|
||||
template.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [URI Template Usage](docs/uri-template-usage.md)
|
||||
- [Input Contract](docs/input-contract.md)
|
||||
- [Upgrade Guide](UPGRADING.md)
|
||||
- [Changelog](CHANGELOG.md)
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
make test
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
If you discover a security vulnerability within this package, please send an
|
||||
email to security@tidelift.com. All security vulnerabilities will be promptly
|
||||
addressed. Please do not disclose security-related issues publicly until a fix
|
||||
has been announced. Please see
|
||||
[Security Policy](https://github.com/guzzle/uri-template/security/policy) for
|
||||
more information.
|
||||
|
||||
## License
|
||||
|
||||
Guzzle URI Template is made available under the MIT License (MIT). Please see
|
||||
[License File](LICENSE) for more information.
|
||||
|
||||
## For Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of Guzzle and thousands of other packages are working with
|
||||
Tidelift to deliver commercial support and maintenance for the open source
|
||||
dependencies you use to build your applications. Save time, reduce risk, and
|
||||
improve code health, while paying the maintainers of the exact dependencies you
|
||||
use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-uri-template?utm_source=packagist-guzzlehttp-uri-template&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
575
vendor/guzzlehttp/uri-template/UPGRADING.md
vendored
Normal file
575
vendor/guzzlehttp/uri-template/UPGRADING.md
vendored
Normal file
|
|
@ -0,0 +1,575 @@
|
|||
Guzzle URI Template Upgrade Guide
|
||||
=================================
|
||||
|
||||
1.x to 2.0
|
||||
----------
|
||||
|
||||
Guzzle URI Template 2.0 is a major release that raises the minimum PHP version
|
||||
and validates RFC 6570 template syntax, literal text, variable names, value
|
||||
modifiers, and referenced variable values more strictly before expansion.
|
||||
Invalid input now fails with `InvalidArgumentException` instead of being
|
||||
partially expanded, returned unchanged, or producing PHP warnings.
|
||||
|
||||
Applications that expand application-controlled templates with scalar values
|
||||
should usually need small changes. Applications that load templates from
|
||||
configuration, service descriptions, or remote systems, or that pass mixed PHP
|
||||
value shapes into templates, should review the stricter validation rules below.
|
||||
|
||||
#### PHP Version and Dependencies
|
||||
|
||||
Guzzle URI Template 2.0 requires PHP `^7.4 || ^8.0`. Guzzle URI Template 1.x
|
||||
supported PHP `^7.2.5 || ^8.0`.
|
||||
|
||||
If your application still supports PHP 7.2 or 7.3, continue using Guzzle URI
|
||||
Template 1.x until your minimum PHP version is raised.
|
||||
|
||||
Guzzle URI Template 2.0 continues to require `symfony/polyfill-php80:^1.25`, so
|
||||
there are no runtime package dependency changes beyond PHP.
|
||||
|
||||
#### Input Contract
|
||||
|
||||
`UriTemplate::expand()` expects an RFC 6570 URI template and a variable map.
|
||||
Guzzle URI Template 2.0 validates template syntax, literal text, variable
|
||||
specifiers, value modifiers, and referenced variable values before expansion.
|
||||
Invalid input throws `InvalidArgumentException` instead of being partially
|
||||
expanded, returned unchanged, or producing PHP warnings.
|
||||
|
||||
Only variables referenced by the template are validated. Extra values in the
|
||||
variable map are ignored, even if those extra values have unsupported PHP types.
|
||||
Missing variables and variables set to `null` are treated as undefined and are
|
||||
omitted from the expansion. Empty strings are defined values and are expanded.
|
||||
|
||||
Invalid template syntax includes malformed braces, unsupported operators,
|
||||
invalid variable names, invalid modifiers, and repeated operator-like variable
|
||||
specifiers.
|
||||
|
||||
Prefix modifiers are valid template syntax, but they apply only to scalar or
|
||||
stringable referenced values. If a prefix modifier references a defined list or
|
||||
map value, including a non-empty list whose members are all `null`, expansion
|
||||
throws `InvalidArgumentException`; missing and `null` variables, empty arrays,
|
||||
and maps whose members are all `null` are treated as undefined and omitted.
|
||||
|
||||
#### Common Migration Fixes
|
||||
|
||||
Use pct-encoded literal text in templates. Pass variable values in their normal
|
||||
application form and let the expander encode them according to the expression
|
||||
type:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search%20terms/{id}', ['id' => 1]);
|
||||
|
||||
UriTemplate::expand('/search{?q}', ['q' => 'search terms']);
|
||||
```
|
||||
|
||||
Use valid RFC 6570 variable names. If the expanded URI must contain a query
|
||||
parameter name that is not a valid template variable name, place that name in an
|
||||
exploded map:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?query*}', [
|
||||
'query' => ['default-graph-uri' => 'https://example.com/'],
|
||||
]);
|
||||
```
|
||||
|
||||
Apply prefix modifiers only to scalar or stringable values:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{name:3}', ['name' => 'value']);
|
||||
```
|
||||
|
||||
Validate variable maps before expansion if they contain user-provided values.
|
||||
Unsupported resources, closures, non-stringable objects, non-finite floats, and
|
||||
unsupported nested arrays now throw `InvalidArgumentException`.
|
||||
|
||||
Apply defaults before expansion instead of using non-RFC template extension
|
||||
syntax:
|
||||
|
||||
```php
|
||||
$q = $q ?? 'default';
|
||||
|
||||
UriTemplate::expand('/search{?q}', ['q' => $q]);
|
||||
```
|
||||
|
||||
#### Literal Text
|
||||
|
||||
Literal text outside expressions is now validated and encoded using RFC 6570
|
||||
literal rules; apostrophes are valid literal characters per verified RFC 6570
|
||||
erratum 6937. Invalid literal characters, including spaces, raw or malformed `%`
|
||||
sequences, double quotes, controls, `<`, `>`, backslash, caret, backtick, and
|
||||
pipe, now throw `InvalidArgumentException`. Valid non-ASCII literal text must be
|
||||
valid UTF-8 and is pct-encoded during expansion. Templates without expressions
|
||||
are also validated and encoded.
|
||||
|
||||
Existing valid pct-encoded triplets in literal text are preserved. Raw `%`
|
||||
characters and malformed pct-encoded triplets are invalid literal text.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search terms/{id}', ['id' => 1]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search%20terms/{id}', ['id' => 1]);
|
||||
```
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/files/%/{id}', ['id' => 1]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/files/%25/{id}', ['id' => 1]);
|
||||
```
|
||||
|
||||
#### Variable Names
|
||||
|
||||
Variable names in templates must use RFC 6570 syntax: ASCII letters, ASCII
|
||||
digits, `_`, pct-encoded triplets, and dot separators. Pct-encoded triplets are
|
||||
part of the variable name and are not decoded for variable lookup.
|
||||
|
||||
Raw Unicode characters are not valid variable names. Use the pct-encoded form in
|
||||
both the template and the variable map key:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/lookup{?Stra%C3%9Fe}', [
|
||||
'Stra%C3%9Fe' => 'Gruner Weg',
|
||||
]);
|
||||
```
|
||||
|
||||
Dot separators are part of the variable name. They do not traverse nested PHP
|
||||
arrays:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/people/{last.name}', [
|
||||
'last.name' => 'Doe',
|
||||
]);
|
||||
```
|
||||
|
||||
For example, hyphenated variable names are invalid in templates. Rename them to
|
||||
use a valid character such as `_`, or use valid dot-separated names where that
|
||||
matches your variable map.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?default-graph-uri}', [
|
||||
'default-graph-uri' => 'https://example.com/',
|
||||
]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?default_graph_uri}', [
|
||||
'default_graph_uri' => 'https://example.com/',
|
||||
]);
|
||||
```
|
||||
|
||||
If the resulting query parameter name must contain a hyphen, use an exploded map
|
||||
so the hyphenated name is data rather than template syntax:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?query*}', [
|
||||
'query' => ['default-graph-uri' => 'https://example.com/'],
|
||||
]);
|
||||
```
|
||||
|
||||
Whitespace is also invalid inside variable specifiers.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{?x, y}', ['x' => 1, 'y' => 2]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{?x,y}', ['x' => 1, 'y' => 2]);
|
||||
```
|
||||
|
||||
URI Template extension syntaxes that are not part of RFC 6570, such as default
|
||||
values, join expressions, and prefix extension expressions, are rejected. Apply
|
||||
those policies in application code before expansion.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?q=default}', []);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?q}', ['q' => 'default']);
|
||||
```
|
||||
|
||||
#### Value Modifiers
|
||||
|
||||
Prefix modifiers, such as `{var:3}`, are valid only for scalar or stringable
|
||||
values. Prefix lengths must be positive integers from `1` through `9999`, with
|
||||
no leading zeroes. Prefix lengths are counted as Unicode code points and
|
||||
existing pct-encoded characters, not bytes or visual grapheme clusters.
|
||||
Consecutive pct-encoded triplets that encode one Unicode code point in UTF-8,
|
||||
such as `%C3%A9`, count as one character. A prefixed string value must be valid
|
||||
UTF-8, otherwise expansion throws `InvalidArgumentException`.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{list:1}', [
|
||||
'list' => ['red', 'green'],
|
||||
]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{name:1}', ['name' => 'red']);
|
||||
```
|
||||
|
||||
Use the explode modifier, `*`, to expand lists and maps item by item:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{/list*}', [
|
||||
'list' => ['red', 'green'],
|
||||
]);
|
||||
|
||||
// /red/green
|
||||
```
|
||||
|
||||
#### Exploded Map Values
|
||||
|
||||
Exploded map members with empty-string values now render as the bare name under
|
||||
every operator except the form-style `?` and `&`, which keep `name=`, following
|
||||
the normative prose in RFC 6570 section 3.2.1. Guzzle URI Template 1.x rendered
|
||||
`name=` under every operator.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{;m*}{/m*}{?m*}', ['m' => ['a' => '']]);
|
||||
|
||||
// 1.x: ;a=/a=?a=
|
||||
// 2.0: ;a/a?a=
|
||||
```
|
||||
|
||||
#### Variable Values
|
||||
|
||||
Supported variable values are `null`, scalars, stringable objects, lists, and
|
||||
maps. `null` means undefined and is omitted from expansion. Lists and maps may
|
||||
contain scalar or stringable values. Arrays whose keys are exactly `0` through
|
||||
`n-1` in ascending insertion order are expanded as lists. All other arrays,
|
||||
including reordered, sparse, and mixed-key arrays, are expanded as maps.
|
||||
|
||||
Scalars are cast to strings before expansion. `true` expands as `1` and `false`
|
||||
expands as `0`, at every nesting level. Guzzle URI Template 1.x expanded
|
||||
top-level `false` as an empty string; pass `''` explicitly if that output is
|
||||
required, or `null` to omit the variable.
|
||||
|
||||
Floats always expand with `.` as the decimal separator. Guzzle URI Template 1.x
|
||||
followed the `LC_NUMERIC` locale on PHP versions before 8.0, so a process that
|
||||
had called `setlocale()` with a comma-decimal locale such as `de_DE` could
|
||||
expand `3.5` as `3%2C5`. Non-finite floats are not supported: `INF`, `-INF`,
|
||||
and `NAN` now throw `InvalidArgumentException` instead of expanding as literal
|
||||
text.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?q,page}', [
|
||||
'q' => null,
|
||||
'page' => 1,
|
||||
]);
|
||||
|
||||
// /search?page=1
|
||||
|
||||
UriTemplate::expand('/search{?q,page}', [
|
||||
'q' => '',
|
||||
'page' => 1,
|
||||
]);
|
||||
|
||||
// /search?q=&page=1
|
||||
```
|
||||
|
||||
Nested arrays in maps are supported for exploded query-style expansions, such as
|
||||
`{?var*}` and `{&var*}`, to preserve existing Guzzle URI Template behavior.
|
||||
|
||||
`null` members inside lists and maps are treated as undefined and omitted,
|
||||
consistent with top-level `null`. RFC 6570 section 3.2.1 expands a list as a
|
||||
concatenation of "the defined member string values", and section 2.4.2 states
|
||||
that "only the defined pairs are present in the expansion". A map whose members
|
||||
are all `null` is treated as a wholly undefined variable, because RFC 6570
|
||||
section 2.3 considers an associative array undefined when all member names are
|
||||
associated with undefined values. A non-empty list whose members are all `null`
|
||||
is a defined variable with no defined members, because the same section calls a
|
||||
list undefined only when it contains zero members: the operator first string is
|
||||
still emitted, named forms render the name with the operator's empty-value
|
||||
form, and prefix modifiers are rejected as for any other list.
|
||||
|
||||
Guzzle URI Template 1.x agreed with 2.0 on most expansions of such lists,
|
||||
including the `#`, `.`, and `/` first strings, `?l=`, `&l=`, and `;l`. 1.x
|
||||
differed on the exploded named forms, rendering `;l`, `?l=`, and `&l=` where
|
||||
2.0 renders `;`, `?`, and `&`, on lists mixing `null` and defined members,
|
||||
where 1.x expanded `[null, 'x']` as `,x` while 2.0 omits the `null` member and
|
||||
expands `x`, and on prefix modifiers, where 1.x expanded `{l:1}` with an
|
||||
all-`null` list as an empty string while 2.0 throws `InvalidArgumentException`:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{/l}{;l}{;l*}', ['l' => [null]]);
|
||||
|
||||
// 1.x: /;l;l
|
||||
// 2.0: /;l;
|
||||
```
|
||||
|
||||
Unsupported values throw `InvalidArgumentException` before expansion. This
|
||||
includes resources, closures, non-stringable objects, unsupported nested arrays,
|
||||
recursive arrays, and arrays nested more than 64 levels deep.
|
||||
|
||||
Variable values must now be valid UTF-8. Invalid byte sequences throw
|
||||
`InvalidArgumentException` instead of being percent-encoded byte by byte. Encode
|
||||
binary data, for example with base64, before expansion.
|
||||
|
||||
Convert non-stringable objects before expansion:
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
$date = new \DateTimeImmutable('2026-01-01');
|
||||
|
||||
UriTemplate::expand('/events{?date}', ['date' => $date]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
$date = new \DateTimeImmutable('2026-01-01');
|
||||
|
||||
UriTemplate::expand('/events{?date}', [
|
||||
'date' => $date->format(DATE_ATOM),
|
||||
]);
|
||||
```
|
||||
|
||||
Referenced variable values are detached from the variables array and formed
|
||||
before expansion begins, as required by RFC 6570 section 3. Definedness is
|
||||
bound and raw values are read before any `__toString()` method runs, so an
|
||||
object cannot change another referenced variable through a PHP reference.
|
||||
Stringable objects are then converted to strings once per value position, in
|
||||
template order, and scalars are converted to their expansion strings, so a
|
||||
repeated variable keeps a static value even when a `__toString()` method
|
||||
changes the float precision or the locale mid-expansion. String values and
|
||||
map keys are validated as UTF-8 while values are formed, so value errors
|
||||
surface in member order. Guzzle URI Template 1.x called
|
||||
`__toString()` again for every occurrence, so an object returning different
|
||||
values could expand differently within one template. Exceptions thrown by
|
||||
`__toString()` propagate unchanged; they surface while values are formed,
|
||||
after template syntax validation and before any part of the URI is produced,
|
||||
and may preempt validation errors for values formed later:
|
||||
|
||||
```php
|
||||
$counter = new class() {
|
||||
private $n = 0;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) ++$this->n;
|
||||
}
|
||||
};
|
||||
|
||||
UriTemplate::expand('{x}-{x}', ['x' => $counter]);
|
||||
|
||||
// 1.x: 1-2
|
||||
// 2.0: 1-1
|
||||
```
|
||||
|
||||
#### Array Values
|
||||
|
||||
PHP arrays are classified by shape. Arrays whose keys are exactly `0` through
|
||||
`n-1` in ascending insertion order are lists. All other arrays, including
|
||||
reordered, sparse, and mixed-key arrays, are maps. This makes expansion
|
||||
deterministic and preserves PHP insertion order for maps.
|
||||
|
||||
If a sparse array is intended to be a list, reindex it before expansion:
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
$tag = [1 => 'red', 2 => 'green'];
|
||||
|
||||
UriTemplate::expand('/tags{/tag*}', ['tag' => $tag]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
$tag = [1 => 'red', 2 => 'green'];
|
||||
|
||||
UriTemplate::expand('/tags{/tag*}', ['tag' => array_values($tag)]);
|
||||
|
||||
// /tags/red/green
|
||||
```
|
||||
|
||||
Use maps when the member names are part of the URI:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter*}', [
|
||||
'filter' => [
|
||||
'status' => 'open',
|
||||
'sort' => 'created',
|
||||
],
|
||||
]);
|
||||
```
|
||||
|
||||
#### Nested Arrays
|
||||
|
||||
Nested arrays are supported only for exploded query-style expansions, such as
|
||||
`{?var*}` and `{&var*}`. They are encoded using RFC 3986 query encoding with PHP
|
||||
bracket syntax. Empty nested arrays are omitted from the expansion.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter}', [
|
||||
'filter' => [
|
||||
'author' => [
|
||||
'name' => 'Ada Lovelace',
|
||||
],
|
||||
],
|
||||
]);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter*}', [
|
||||
'filter' => [
|
||||
'author' => [
|
||||
'name' => 'Ada Lovelace',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// /search?author%5Bname%5D=Ada%20Lovelace
|
||||
```
|
||||
|
||||
Nested arrays are not supported in simple, reserved, fragment, label, path, or
|
||||
path-style parameter expansions. Lists containing arrays are also invalid. If a
|
||||
nested query array contains objects, convert them to scalar values before
|
||||
expansion.
|
||||
|
||||
#### Path-Style Parameter Expansion
|
||||
|
||||
Path-style parameter expansion (`{;var}`) renders empty values in two ways that
|
||||
differ from Guzzle URI Template 1.x. Both changes are scoped to the `;`
|
||||
operator; the query operators `{?var*}` and `{&var*}` still render `name=` for
|
||||
empty members.
|
||||
|
||||
Exploded path-style maps with empty-string members now render a bare name
|
||||
instead of `name=`, following the RFC 6570 section 3.2.1 rule that omits the `=`
|
||||
for an empty value under operators that do not indicate form-style parameters.
|
||||
Guzzle URI Template 1.x appended `=` to every exploded member.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{;m*}', ['m' => ['a' => '', 'b' => 'x']]);
|
||||
|
||||
// 1.x: ;a=;b=x
|
||||
// 2.0: ;a;b=x
|
||||
```
|
||||
|
||||
Non-exploded path-style expansion of a list or map containing defined members
|
||||
that all expand empty now appends `=` after the name. A composite value is
|
||||
empty only when it contains no defined members, so a joined member expansion
|
||||
that is an empty string is still rendered as `name=`. Guzzle URI Template 1.x
|
||||
omitted the `=` and rendered a bare name.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{;l}', ['l' => ['']]);
|
||||
|
||||
// 1.x: ;l
|
||||
// 2.0: ;l=
|
||||
```
|
||||
|
||||
A scalar empty string is unchanged and still renders a bare name under `;`.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{;x}', ['x' => '']);
|
||||
|
||||
// ;x
|
||||
```
|
||||
|
||||
#### Reserved Expansion
|
||||
|
||||
Reserved expansion (`{+var}`) and fragment expansion (`{#var}`) intentionally
|
||||
preserve URI reserved delimiters from variable values according to RFC 6570.
|
||||
Simple expansion encodes reserved delimiters.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/files/{path}', ['path' => 'a/b']);
|
||||
|
||||
// /files/a%2Fb
|
||||
|
||||
UriTemplate::expand('/files/{+path}', ['path' => 'a/b']);
|
||||
|
||||
// /files/a/b
|
||||
```
|
||||
|
||||
Reserved and fragment expansion also preserve existing valid pct-encoded
|
||||
triplets in variable values. Simple expansion encodes `%` as `%25`.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{id}', ['id' => 'admin%2F']);
|
||||
|
||||
// admin%252F
|
||||
|
||||
UriTemplate::expand('{+id}', ['id' => 'admin%2F']);
|
||||
|
||||
// admin%2F
|
||||
```
|
||||
|
||||
Reserved and fragment expansion now encode map keys with the operator's allow
|
||||
set, the same set used for values, so reserved characters in a key are preserved
|
||||
instead of percent-encoded. Guzzle URI Template 1.x always percent-encoded map
|
||||
keys, even under `{+var}` and `{#var}`. This applies to both exploded and joined
|
||||
maps.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{+x*}', ['x' => ['a/b' => 'v']]);
|
||||
|
||||
// 1.x: a%2Fb=v
|
||||
// 2.0: a/b=v
|
||||
|
||||
UriTemplate::expand('{+x}', ['x' => ['a/b' => 'v']]);
|
||||
|
||||
// 1.x: a%2Fb,v
|
||||
// 2.0: a/b,v
|
||||
```
|
||||
|
||||
Simple expansion continues to percent-encode reserved characters in map keys.
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{x}', ['x' => ['a/b' => 'v']]);
|
||||
|
||||
// a%2Fb,v
|
||||
```
|
||||
|
||||
Templates should generally be application-controlled. If templates come from
|
||||
users or remote systems, treat them as policy input because template syntax
|
||||
controls the structure of the expanded URI.
|
||||
|
||||
Values expanded with `{+var}` and `{#var}` keep the URI meaning of reserved
|
||||
characters, so untrusted values can inject scheme, authority, path, query, and
|
||||
fragment structure into the expanded URI. Use simple expansion for untrusted
|
||||
values, or validate them before expansion.
|
||||
|
||||
#### UriTemplate Instantiation
|
||||
|
||||
`UriTemplate` now has a private constructor. Use `UriTemplate::expand()`
|
||||
statically instead of instantiating the class.
|
||||
|
||||
#### Native PHP Serialization
|
||||
|
||||
`UriTemplate` no longer supports native PHP `serialize()` or `unserialize()`.
|
||||
The class is stateless; call `UriTemplate::expand()` statically instead of
|
||||
persisting instances.
|
||||
76
vendor/guzzlehttp/uri-template/composer.json
vendored
Normal file
76
vendor/guzzlehttp/uri-template/composer.json
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "guzzlehttp/uri-template",
|
||||
"description": "A polyfill class for uri_template of PHP",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"guzzlehttp",
|
||||
"uri-template"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
},
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "George Mponos",
|
||||
"email": "gmponos@gmail.com",
|
||||
"homepage": "https://github.com/gmponos"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/Nyholm"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"symfony/polyfill-php80": "^1.25"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"phpunit/phpunit": "^9.6.34",
|
||||
"uri-template/tests": "1.0.2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "uri-template/tests",
|
||||
"version": "1.0.2",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/uri-templates/uritemplate-test/archive/4171dac22aa67fc710b3f6df308a50bd08552986.zip"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\UriTemplate\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\UriTemplate\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"bamarni/composer-bin-plugin": true
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
}
|
||||
}
|
||||
}
|
||||
238
vendor/guzzlehttp/uri-template/docs/input-contract.md
vendored
Normal file
238
vendor/guzzlehttp/uri-template/docs/input-contract.md
vendored
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
# Input Contract
|
||||
|
||||
This document defines the template syntax and PHP value shapes accepted by
|
||||
`UriTemplate::expand()`. Use it when variables come from application data,
|
||||
request data, or another system and you need predictable validation behavior.
|
||||
|
||||
`UriTemplate::expand()` expects an RFC 6570 URI template and an array of
|
||||
variables. Invalid templates or unsupported referenced variable values throw
|
||||
`InvalidArgumentException`.
|
||||
|
||||
## Variables
|
||||
|
||||
Template variable names may contain ASCII letters, ASCII digits, `_`, valid
|
||||
percent-encoded triplets, and dot separators. Percent-encoded triplets are part
|
||||
of the variable name and are not decoded for variable lookup. Dot separators may
|
||||
separate name parts, but names cannot start with a dot, end with a dot, or
|
||||
contain empty dot-separated parts.
|
||||
|
||||
Array keys in the variables argument must match template variable names exactly:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/users/{user.id}', [
|
||||
'user.id' => 123,
|
||||
]);
|
||||
```
|
||||
|
||||
RFC 6570 variable names may consist entirely of digits, such as `{0}`. PHP
|
||||
coerces array keys that are canonical decimal integer strings to integers, so
|
||||
`['0' => 'x']` and `[0 => 'x']` are the same key. An all-numeric variable name
|
||||
is matched against that integer key and expands normally. A name that is not
|
||||
a canonical decimal integer string, such as `{01}`, is not coerced; it must
|
||||
appear under the exact string key `'01'`. Coercion follows the platform
|
||||
integer range: a numeric name beyond `PHP_INT_MAX`, such as `{2147483648}` on
|
||||
32-bit PHP, stays a string key and must match exactly.
|
||||
|
||||
## Values
|
||||
|
||||
Supported variable values are:
|
||||
|
||||
- `null`, which is treated as undefined and omitted
|
||||
- scalars, which are cast to strings before expansion
|
||||
- objects with `__toString()`
|
||||
- dense zero-indexed lists containing scalar or stringable values
|
||||
- maps containing scalar or stringable values
|
||||
- nested arrays in maps for exploded query-style expansions, with scalar leaves
|
||||
|
||||
Referenced variable values are detached from the variables array and formed
|
||||
before expansion begins. Definedness is bound and raw values are read before
|
||||
any `__toString()` method runs, so an object cannot change another referenced
|
||||
variable through a PHP reference. Stringable objects are then converted to
|
||||
strings once per value position, in template order, and scalars are converted
|
||||
to their expansion strings, so a repeated variable keeps a static value even
|
||||
when a `__toString()` method changes the float precision or the locale
|
||||
mid-expansion. String values and map keys are validated as UTF-8 while values
|
||||
are formed, so value errors surface in member order. Exceptions thrown by
|
||||
`__toString()` propagate unchanged; they surface while values are formed, after
|
||||
template syntax validation and before any part of the URI is produced, and may
|
||||
preempt validation errors for values formed later.
|
||||
|
||||
Booleans expand as `1` and `0` at every nesting level.
|
||||
|
||||
Floats expand using PHP's float-to-string conversion with the decimal separator
|
||||
normalized to `.`, so output does not depend on the process locale, including on
|
||||
PHP 7.4 where the plain cast honors `LC_NUMERIC`. The conversion rounds to the
|
||||
`precision` ini setting (`14` by default), so `0.1 + 0.2` expands as `0.3`, and
|
||||
uses scientific notation, such as `1.0E+20`, when fixed notation would need more
|
||||
significant digits than `precision` allows or the magnitude is below `0.0001`.
|
||||
The `+` in an exponent is percent-encoded as `%2B` except under reserved and
|
||||
fragment expansion. Non-finite floats are not supported: `INF`, `-INF`, and
|
||||
`NAN` throw `InvalidArgumentException`. Format floats yourself, for example
|
||||
with `number_format()` or `sprintf()`, when a specific decimal representation
|
||||
is required.
|
||||
|
||||
An empty string is a defined value and is expanded. An empty array is treated as
|
||||
undefined and omitted. Missing variables and variables set to `null` are treated
|
||||
as undefined and omitted.
|
||||
|
||||
`null` members inside lists and maps are treated as undefined members and
|
||||
omitted, like top-level `null`. A map whose members are all `null` is treated
|
||||
as undefined and omitted, like an empty array. A non-empty list whose members
|
||||
are all `null` is a defined variable with no defined members: the operator
|
||||
first string is still emitted, named forms render the name with the operator's
|
||||
empty-value form, and prefix modifiers are rejected as for any other list. A
|
||||
list or map with at least one defined member is a defined, non-empty value: in
|
||||
named non-exploded expansions, `=` follows the name even when every member
|
||||
expands to the empty string, so `{;l}` with `['l' => ['']]` expands to `;l=`.
|
||||
See the [conformance
|
||||
notes](uri-template-usage.md#specification-conformance-notes) for how the
|
||||
all-`null` rule maps to RFC 6570.
|
||||
|
||||
Arrays whose keys are exactly `0` through `n-1` in ascending insertion order
|
||||
expand as lists. All other arrays, including reordered, sparse, and mixed-key
|
||||
arrays, expand as maps. Map and list order follows PHP array insertion order.
|
||||
|
||||
Because these arrays always expand as lists, a map whose member names are
|
||||
exactly the integers `0` through `n-1` cannot be expressed as a single variable
|
||||
value; such an array expands as a list. Reference each member with its own
|
||||
numeric variable name, such as `{?0,1}`, when the expanded URI must carry those
|
||||
names.
|
||||
|
||||
Unsupported values include resources, closures, non-stringable objects,
|
||||
non-finite floats, recursive arrays, arrays nested more than 64 levels deep, and
|
||||
nested arrays outside exploded query-style expansions. Unsupported values are
|
||||
validated only when the template references that variable.
|
||||
|
||||
Variable values must be valid UTF-8. Invalid byte sequences throw
|
||||
`InvalidArgumentException`. Encode binary data, for example with base64, before
|
||||
expansion.
|
||||
|
||||
Values are expanded as given, without Unicode normalization. Canonically
|
||||
equivalent inputs expand to different URIs: the decomposed value `"e\u{0301}"`
|
||||
expands to `e%CC%81`, while the precomposed value `"\u{00E9}"` expands to
|
||||
`%C3%A9`. Normalize user-entered text, for example with ext-intl's
|
||||
`Normalizer::normalize($value, Normalizer::FORM_C)`, before expansion. See the
|
||||
[conformance notes](uri-template-usage.md#specification-conformance-notes) for
|
||||
the RFC 6570 section 1.6 background.
|
||||
|
||||
## Prefix Modifiers
|
||||
|
||||
Prefix modifiers select a character prefix from scalar and stringable values:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/dictionary/{term:1}/{term}', ['term' => 'cat']);
|
||||
|
||||
// /dictionary/c/cat
|
||||
```
|
||||
|
||||
Prefix lengths must be decimal integers from `1` through `9999`. Leading zeroes,
|
||||
zero, negative numbers, non-numeric values, and values greater than `9999` are
|
||||
invalid.
|
||||
|
||||
Prefix modifiers are not valid on composite values such as lists or maps, and a
|
||||
varspec cannot combine prefix and explode modifiers.
|
||||
|
||||
Prefix length counts Unicode characters and existing percent-encoded
|
||||
characters, not bytes. For example, `%2F` counts as one character before the
|
||||
selected prefix is encoded for the expression type, and consecutive
|
||||
percent-encoded triplets that encode one Unicode code point in UTF-8, such as
|
||||
`%C3%A9`, also count as one character. A combining mark is its own character,
|
||||
so a prefix can split a decomposed character sequence: `{x:1}` with the
|
||||
decomposed value `"e\u{0301}f"` selects only `e`, dropping the combining
|
||||
accent. Normalize values to NFC before expansion to keep user-perceived
|
||||
characters intact. Values must be valid UTF-8, as described in
|
||||
[values](#values).
|
||||
|
||||
## Nested Query Arrays
|
||||
|
||||
Nested arrays are accepted only as values inside map variables expanded with an
|
||||
exploded query or query-continuation expression, such as `{?filter*}` or
|
||||
`{&filter*}`.
|
||||
|
||||
Nested query arrays must have scalar leaves and can be nested at most 64 levels
|
||||
deep below the top-level map. Recursive arrays, arrays nested more deeply, and
|
||||
nested objects are rejected. Nested `null` values are treated as undefined
|
||||
members and omitted. Omission happens before member validation, so the keys of
|
||||
omitted `null` members are not validated. Stringable objects are accepted as
|
||||
direct map values, but not as leaves inside nested query arrays.
|
||||
|
||||
Nested query arrays use RFC 3986 query encoding with PHP bracket syntax:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter*}', [
|
||||
'filter' => [
|
||||
'author' => [
|
||||
'name' => 'Ada Lovelace',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// /search?author%5Bname%5D=Ada%20Lovelace
|
||||
```
|
||||
|
||||
Empty nested arrays are omitted from exploded query expansions. Empty scalar
|
||||
values are preserved.
|
||||
|
||||
Empty-string keys at nested levels of a nested query array produce PHP append
|
||||
syntax (`a%5B%5D=v`), which does not round-trip the key.
|
||||
|
||||
A top-level empty-string key whose value is a non-empty nested array produces
|
||||
bracket syntax with an empty root name (`%5Ba%5D=v`, decoded `[a]=v`), which
|
||||
drops the root pair name and does not round-trip. Deeper nesting keeps the
|
||||
empty root name (`%5Ba%5D%5Bb%5D=v`). This applies to `{?var*}` and `{&var*}`
|
||||
alike. A top-level empty-string key with a scalar value keeps the empty pair
|
||||
name in the output (`=v`), and one with an empty nested array is omitted, like
|
||||
other empty nested arrays.
|
||||
|
||||
## Validation Errors
|
||||
|
||||
Literal text outside expressions must already be valid URI template literal
|
||||
text. For example, use `/search%20terms/{id}` instead of `/search terms/{id}`.
|
||||
|
||||
`InvalidArgumentException` is thrown for invalid template syntax, unsupported
|
||||
operators, invalid variable names, invalid modifiers, invalid literal text, and
|
||||
unsupported shapes for variables referenced by the template.
|
||||
|
||||
Errors for invalid list and map members identify the member by path, such as
|
||||
`x[1]` or `filter[author][name]`. Member paths and expression text use
|
||||
diagnostic escaping. C0, DEL, and C1 controls are rendered as `\xHH`. If
|
||||
UTF-8-aware diagnostic escaping fails, every byte outside printable ASCII is
|
||||
rendered in the same form. The result is diagnostic text, not a reversible
|
||||
encoding.
|
||||
|
||||
`RuntimeException` is thrown when the PCRE engine fails while processing a
|
||||
template, for example when an extremely long variable name or very large
|
||||
literal text exhausts a PCRE resource limit. This indicates an environment
|
||||
limit, not invalid input; the threshold depends on the PCRE build and
|
||||
`pcre.jit` configuration.
|
||||
|
||||
Exceptions thrown by a value object's `__toString()` method propagate unchanged;
|
||||
they are not converted to `InvalidArgumentException`. They surface while values
|
||||
are formed, once per expansion, after template syntax validation and before any
|
||||
part of the URI is produced.
|
||||
|
||||
Catch `InvalidArgumentException` if templates or values come from outside your
|
||||
application:
|
||||
|
||||
```php
|
||||
try {
|
||||
$uri = UriTemplate::expand($template, $variables);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Reject or log the invalid template input.
|
||||
}
|
||||
```
|
||||
|
||||
Templates should generally be application-controlled. If templates come from
|
||||
users or remote systems, treat them as policy input and review them before
|
||||
expansion.
|
||||
|
||||
Values expanded with `{+var}` and `{#var}` keep the URI meaning of reserved
|
||||
characters, so untrusted values can inject scheme, authority, path, query, and
|
||||
fragment structure into the expanded URI. Use simple expansion for untrusted
|
||||
values, or validate them before expansion.
|
||||
|
||||
## Related
|
||||
|
||||
- [URI Template Usage](uri-template-usage.md)
|
||||
- [Upgrade Guide](../UPGRADING.md)
|
||||
- [Changelog](../CHANGELOG.md)
|
||||
274
vendor/guzzlehttp/uri-template/docs/uri-template-usage.md
vendored
Normal file
274
vendor/guzzlehttp/uri-template/docs/uri-template-usage.md
vendored
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
# URI Template Usage
|
||||
|
||||
This guide shows the supported URI template expansion forms and common value
|
||||
shapes for `UriTemplate::expand()`. For the complete rules for variable names,
|
||||
accepted PHP values, empty values, and validation errors, see the
|
||||
[input contract](input-contract.md).
|
||||
|
||||
```php
|
||||
use GuzzleHttp\UriTemplate\UriTemplate;
|
||||
|
||||
$uri = UriTemplate::expand('/users/{id}{?tab}', [
|
||||
'id' => 123,
|
||||
'tab' => 'settings',
|
||||
]);
|
||||
|
||||
// /users/123?tab=settings
|
||||
```
|
||||
|
||||
The first argument is an RFC 6570 URI template. The second argument is an array
|
||||
of [variables](input-contract.md#variables) to use during expansion. Variable
|
||||
map keys must match template variable names exactly.
|
||||
|
||||
This package supports RFC 6570 levels 1 through 4 for the standard operators
|
||||
listed below, including prefix and explode modifiers. RFC 6570 reserved
|
||||
extension operators are not supported and are rejected.
|
||||
|
||||
| Operator | Expansion | Status |
|
||||
|----------|-----------|--------|
|
||||
| none | Simple string expansion | Supported |
|
||||
| `+` | Reserved string expansion | Supported |
|
||||
| `#` | Fragment expansion | Supported |
|
||||
| `.` | Label expansion | Supported |
|
||||
| `/` | Path segment expansion | Supported |
|
||||
| `;` | Path-style parameter expansion | Supported |
|
||||
| `?` | Form-style query expansion | Supported |
|
||||
| `&` | Form-style query continuation | Supported |
|
||||
| `=`, `,`, `!`, `@`, `\|` | Reserved extension operators | Unsupported, rejected |
|
||||
|
||||
Simple expansion encodes reserved URI delimiters in variable values:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/files/{path}', ['path' => 'a/b']);
|
||||
|
||||
// /files/a%2Fb
|
||||
```
|
||||
|
||||
Use reserved expansion (`{+var}`) when the variable value intentionally contains
|
||||
URI delimiters that should remain delimiters in the expanded URI:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/files/{+path}', ['path' => 'a/b']);
|
||||
|
||||
// /files/a/b
|
||||
```
|
||||
|
||||
Values expanded with `{+var}` and `{#var}` keep the URI meaning of reserved
|
||||
characters, so untrusted values can inject scheme, authority, path, query, and
|
||||
fragment structure into the expanded URI. Use simple expansion for untrusted
|
||||
values, or validate them before expansion.
|
||||
|
||||
Fragment expansion (`{#var}`) prefixes the expanded value with `#` when the
|
||||
variable is defined:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/docs{#section}', ['section' => 'part 1']);
|
||||
|
||||
// /docs#part%201
|
||||
```
|
||||
|
||||
Other operators help build common URI components:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('www{.domain*}', [
|
||||
'domain' => ['example', 'com'],
|
||||
]);
|
||||
|
||||
// www.example.com
|
||||
|
||||
UriTemplate::expand('/users{/id}', ['id' => 123]);
|
||||
|
||||
// /users/123
|
||||
|
||||
UriTemplate::expand('/users{;role}', ['role' => 'admin']);
|
||||
|
||||
// /users;role=admin
|
||||
|
||||
UriTemplate::expand('/search{?q,page}', [
|
||||
'q' => 'uri templates',
|
||||
'page' => 2,
|
||||
]);
|
||||
|
||||
// /search?q=uri%20templates&page=2
|
||||
|
||||
UriTemplate::expand('/search?fixed=yes{&page}', ['page' => 2]);
|
||||
|
||||
// /search?fixed=yes&page=2
|
||||
```
|
||||
|
||||
Prefix modifiers select a prefix of a scalar value:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/dictionary/{term:1}/{term}', ['term' => 'cat']);
|
||||
|
||||
// /dictionary/c/cat
|
||||
```
|
||||
|
||||
Explode modifiers expand lists and maps item by item:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/tags{/tag*}', [
|
||||
'tag' => ['red', 'green', 'blue'],
|
||||
]);
|
||||
|
||||
// /tags/red/green/blue
|
||||
|
||||
UriTemplate::expand('/tags{?tag*}', [
|
||||
'tag' => ['red', 'green'],
|
||||
]);
|
||||
|
||||
// /tags?tag=red&tag=green
|
||||
```
|
||||
|
||||
[Arrays whose keys are exactly `0` through `n-1`](input-contract.md#values) in
|
||||
ascending insertion order expand as lists. All other arrays, including
|
||||
reordered, sparse, and mixed-key arrays, expand as maps. Map order follows PHP
|
||||
array insertion order:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter*}', [
|
||||
'filter' => [
|
||||
'status' => 'open',
|
||||
'sort' => 'created',
|
||||
],
|
||||
]);
|
||||
|
||||
// /search?status=open&sort=created
|
||||
```
|
||||
|
||||
If a sparse array is intended to expand as a list, reindex it before expansion:
|
||||
|
||||
```php
|
||||
$tag = [1 => 'red', 2 => 'green'];
|
||||
|
||||
UriTemplate::expand('/tags{/tag*}', ['tag' => array_values($tag)]);
|
||||
|
||||
// /tags/red/green
|
||||
```
|
||||
|
||||
Nested arrays are supported only for exploded query-style map expansions, such
|
||||
as `{?var*}` and `{&var*}`. They use RFC 3986 query encoding with PHP bracket
|
||||
syntax. See [nested query arrays](input-contract.md#nested-query-arrays) for the
|
||||
full contract:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('/search{?filter*}', [
|
||||
'filter' => [
|
||||
'author' => [
|
||||
'name' => 'Ada Lovelace',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// /search?author%5Bname%5D=Ada%20Lovelace
|
||||
```
|
||||
|
||||
Empty nested arrays are omitted from exploded query expansions. `null` members
|
||||
inside lists and maps are treated as undefined members and omitted, like
|
||||
top-level `null`. A map whose members are all `null` is treated as undefined,
|
||||
while a non-empty list whose members are all `null` is a defined variable with
|
||||
no defined members, as described in the [specification conformance
|
||||
notes](#specification-conformance-notes).
|
||||
|
||||
Variable values are encoded during expansion according to the expression type.
|
||||
Existing percent-encoded triplets in reserved and fragment expansions are
|
||||
preserved, while simple expansion encodes `%` as `%25`:
|
||||
|
||||
```php
|
||||
UriTemplate::expand('{id}', ['id' => 'admin%2F']);
|
||||
|
||||
// admin%252F
|
||||
|
||||
UriTemplate::expand('{+id}', ['id' => 'admin%2F']);
|
||||
|
||||
// admin%2F
|
||||
```
|
||||
|
||||
## Specification Conformance Notes
|
||||
|
||||
Prefix modifiers count existing percent-encoded characters as one character.
|
||||
RFC 6570 section 3.2.1 defines a prefix as the "first max-length characters of
|
||||
the decoded value" and forbids splitting a multi-octet or percent-encoded
|
||||
sequence, so a run of consecutive percent-encoded triplets that encodes one
|
||||
Unicode code point in UTF-8 also counts as one character. For example, `{id:1}`
|
||||
with the value `admin%2F` selects `a`, and `{+id:1}` with the value
|
||||
`%C3%A9clair` selects `%C3%A9`. Triplets that do not encode a single code
|
||||
point, such as a lone lead octet, count as one character each. Several other
|
||||
implementations count raw characters instead and can split percent-encoded
|
||||
triplets, so prefixed expansions of values containing triplets can differ
|
||||
between libraries.
|
||||
|
||||
Invalid templates and unsupported variable values throw
|
||||
`InvalidArgumentException`. RFC 6570 section 3 allows a template processor to
|
||||
recover from an error by copying the offending expression into the result, but
|
||||
describes such output as "only intended for diagnostic use". This library treats
|
||||
these conditions as errors instead of producing diagnostic output.
|
||||
|
||||
Booleans expand as `1` and `0` at every nesting level, as described in the
|
||||
[input contract](input-contract.md#values).
|
||||
|
||||
Floats are converted to strings by the library because RFC 6570 defines only
|
||||
string, list, and associative-array values. The conversion always uses `.` as
|
||||
the decimal separator, regardless of the process locale, and follows PHP's
|
||||
`precision` setting. Non-finite floats are rejected, as described in the
|
||||
[input contract](input-contract.md#values).
|
||||
|
||||
Variable values must be valid UTF-8, per RFC 6570 section 1.6. Invalid byte
|
||||
sequences throw `InvalidArgumentException`, as described in the [input
|
||||
contract](input-contract.md#values).
|
||||
|
||||
A defined composite value is empty in named non-exploded expansions only when
|
||||
it contains no defined members. RFC 6570 section 2.3 treats a list as undefined
|
||||
only when it contains zero members, and the appendix A algorithm tests the
|
||||
value for emptiness before its members are joined, so `{;l}` expanded with
|
||||
`['l' => ['']]` produces `;l=` rather than `;l`, while `{;l}` expanded with
|
||||
`['l' => [null]]` produces `;l`. Several other implementations test the
|
||||
comma-joined member string instead and omit the `=`, so path-style expansions
|
||||
of composite values whose members all expand empty can differ between
|
||||
libraries.
|
||||
|
||||
Exploded map members with empty-string values render as the bare name under the
|
||||
simple, reserved (`+`), fragment (`#`), label (`.`), and path segment (`/`)
|
||||
operators. RFC 6570 contradicts itself for these operators: the normative prose
|
||||
in section 3.2.1 appends each exploded pair as "name=value" or, "if the value is
|
||||
the empty string and the expression type does not indicate form-style
|
||||
parameters", simply "name", while the non-normative appendix A algorithm appends
|
||||
every pair with a defined value as "name=value", and no erratum resolves the
|
||||
conflict. This library follows the normative section 3.2.1 rendering, so other
|
||||
implementations that follow appendix A may render `name=` where this library
|
||||
renders the bare name. The named operators agree under both readings: `;`
|
||||
applies the same rule through its ifemp string, so `{;x*}` with an empty-string
|
||||
member produces a bare name, while the form-style `{?x*}` and `{&x*}` keep
|
||||
`name=`.
|
||||
|
||||
A map whose members are all `null` is treated as a wholly undefined variable,
|
||||
so it is omitted together with the operator's first character unless another
|
||||
variable in the expression is defined. RFC 6570 section 2.3 considers an
|
||||
associative array undefined "if the array contains zero members or if all
|
||||
member names in the array are associated with undefined values". A list whose
|
||||
members are all `null` is instead a defined variable with no defined members:
|
||||
RFC 6570 calls a list undefined only when it contains zero members and reserves
|
||||
the all-members-undefined rule for associative arrays. Such a list expands to
|
||||
an empty member list, so the operator first string is still emitted, named
|
||||
forms render the name with the operator's empty-value form, and prefix
|
||||
modifiers are rejected as for any other list. This is a revised conformance
|
||||
decision where the RFC is ambiguous; there is no ecosystem consensus for these
|
||||
inputs, and some implementations, such as std-uritemplate, reject them
|
||||
outright.
|
||||
|
||||
No Unicode normalization is applied to templates or variable values. RFC 6570
|
||||
section 1.6 states that a value provided by a user "SHOULD be normalized as
|
||||
Normalization Form C" (NFC) prior to expansion, while a server-provided value
|
||||
can be assumed to already be in the form the server expects. This library
|
||||
cannot know where a value came from, so normalization is left to the caller,
|
||||
and canonically equivalent inputs expand to different URIs: the decomposed
|
||||
value `"e\u{0301}"` expands to `e%CC%81`, while the precomposed value
|
||||
`"\u{00E9}"` expands to `%C3%A9`. Normalize user-entered text, for example
|
||||
with ext-intl's `Normalizer::normalize($value, Normalizer::FORM_C)`, before
|
||||
expansion.
|
||||
|
||||
## Related
|
||||
|
||||
- [Input Contract](input-contract.md)
|
||||
- [Upgrade Guide](../UPGRADING.md)
|
||||
- [Changelog](../CHANGELOG.md)
|
||||
1594
vendor/guzzlehttp/uri-template/src/UriTemplate.php
vendored
Normal file
1594
vendor/guzzlehttp/uri-template/src/UriTemplate.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue