first commit
This commit is contained in:
227
vendor/symfony/polyfill-ctype/Ctype.php
vendored
Normal file
227
vendor/symfony/polyfill-ctype/Ctype.php
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Ctype;
|
||||
|
||||
/**
|
||||
* Ctype implementation through regex.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @author Gert de Pagter <BackEndTea@gmail.com>
|
||||
*/
|
||||
final class Ctype
|
||||
{
|
||||
/**
|
||||
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-alnum
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_alnum($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a letter, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-alpha
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_alpha($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-cntrl
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_cntrl($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-digit
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_digit($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-graph
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_graph($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a lowercase letter.
|
||||
*
|
||||
* @see https://php.net/ctype-lower
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_lower($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
|
||||
*
|
||||
* @see https://php.net/ctype-print
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_print($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-punct
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_punct($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
|
||||
*
|
||||
* @see https://php.net/ctype-space
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_space($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is an uppercase letter.
|
||||
*
|
||||
* @see https://php.net/ctype-upper
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_upper($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-xdigit
|
||||
*
|
||||
* @param string|int $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_xdigit($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts integers to their char versions according to normal ctype behaviour, if needed.
|
||||
*
|
||||
* If an integer between -128 and 255 inclusive is provided,
|
||||
* it is interpreted as the ASCII value of a single character
|
||||
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
|
||||
* Any other integer is interpreted as a string containing the decimal digits of the integer.
|
||||
*
|
||||
* @param string|int $int
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function convert_int_to_char_for_ctype($int)
|
||||
{
|
||||
if (!\is_int($int)) {
|
||||
return $int;
|
||||
}
|
||||
|
||||
if ($int < -128 || $int > 255) {
|
||||
return (string) $int;
|
||||
}
|
||||
|
||||
if ($int < 0) {
|
||||
$int += 256;
|
||||
}
|
||||
|
||||
return \chr($int);
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/polyfill-ctype/LICENSE
vendored
Normal file
19
vendor/symfony/polyfill-ctype/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018-2019 Fabien Potencier
|
||||
|
||||
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.
|
||||
12
vendor/symfony/polyfill-ctype/README.md
vendored
Normal file
12
vendor/symfony/polyfill-ctype/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Symfony Polyfill / Ctype
|
||||
========================
|
||||
|
||||
This component provides `ctype_*` functions to users who run php versions without the ctype extension.
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
26
vendor/symfony/polyfill-ctype/bootstrap.php
vendored
Normal file
26
vendor/symfony/polyfill-ctype/bootstrap.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Polyfill\Ctype as p;
|
||||
|
||||
if (!function_exists('ctype_alnum')) {
|
||||
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
|
||||
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
|
||||
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
|
||||
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
|
||||
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
|
||||
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
|
||||
function ctype_print($text) { return p\Ctype::ctype_print($text); }
|
||||
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
|
||||
function ctype_space($text) { return p\Ctype::ctype_space($text); }
|
||||
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
|
||||
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
|
||||
}
|
||||
34
vendor/symfony/polyfill-ctype/composer.json
vendored
Normal file
34
vendor/symfony/polyfill-ctype/composer.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"type": "library",
|
||||
"description": "Symfony polyfill for ctype functions",
|
||||
"keywords": ["polyfill", "compatibility", "portable", "ctype"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gert de Pagter",
|
||||
"email": "BackEndTea@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Polyfill\\Ctype\\": "" },
|
||||
"files": [ "bootstrap.php" ]
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "For best performance"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/polyfill-mbstring/LICENSE
vendored
Normal file
19
vendor/symfony/polyfill-mbstring/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
|
||||
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.
|
||||
847
vendor/symfony/polyfill-mbstring/Mbstring.php
vendored
Normal file
847
vendor/symfony/polyfill-mbstring/Mbstring.php
vendored
Normal file
@@ -0,0 +1,847 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Mbstring;
|
||||
|
||||
/**
|
||||
* Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
|
||||
*
|
||||
* Implemented:
|
||||
* - mb_chr - Returns a specific character from its Unicode code point
|
||||
* - mb_convert_encoding - Convert character encoding
|
||||
* - mb_convert_variables - Convert character code in variable(s)
|
||||
* - mb_decode_mimeheader - Decode string in MIME header field
|
||||
* - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED
|
||||
* - mb_decode_numericentity - Decode HTML numeric string reference to character
|
||||
* - mb_encode_numericentity - Encode character to HTML numeric string reference
|
||||
* - mb_convert_case - Perform case folding on a string
|
||||
* - mb_detect_encoding - Detect character encoding
|
||||
* - mb_get_info - Get internal settings of mbstring
|
||||
* - mb_http_input - Detect HTTP input character encoding
|
||||
* - mb_http_output - Set/Get HTTP output character encoding
|
||||
* - mb_internal_encoding - Set/Get internal character encoding
|
||||
* - mb_list_encodings - Returns an array of all supported encodings
|
||||
* - mb_ord - Returns the Unicode code point of a character
|
||||
* - mb_output_handler - Callback function converts character encoding in output buffer
|
||||
* - mb_scrub - Replaces ill-formed byte sequences with substitute characters
|
||||
* - mb_strlen - Get string length
|
||||
* - mb_strpos - Find position of first occurrence of string in a string
|
||||
* - mb_strrpos - Find position of last occurrence of a string in a string
|
||||
* - mb_str_split - Convert a string to an array
|
||||
* - mb_strtolower - Make a string lowercase
|
||||
* - mb_strtoupper - Make a string uppercase
|
||||
* - mb_substitute_character - Set/Get substitution character
|
||||
* - mb_substr - Get part of string
|
||||
* - mb_stripos - Finds position of first occurrence of a string within another, case insensitive
|
||||
* - mb_stristr - Finds first occurrence of a string within another, case insensitive
|
||||
* - mb_strrchr - Finds the last occurrence of a character in a string within another
|
||||
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
|
||||
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
|
||||
* - mb_strstr - Finds first occurrence of a string within another
|
||||
* - mb_strwidth - Return width of string
|
||||
* - mb_substr_count - Count the number of substring occurrences
|
||||
*
|
||||
* Not implemented:
|
||||
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
||||
* - mb_ereg_* - Regular expression with multibyte support
|
||||
* - mb_parse_str - Parse GET/POST/COOKIE data and set global variable
|
||||
* - mb_preferred_mime_name - Get MIME charset string
|
||||
* - mb_regex_encoding - Returns current encoding for multibyte regex as string
|
||||
* - mb_regex_set_options - Set/Get the default options for mbregex functions
|
||||
* - mb_send_mail - Send encoded mail
|
||||
* - mb_split - Split multibyte string using regular expression
|
||||
* - mb_strcut - Get part of string
|
||||
* - mb_strimwidth - Get truncated string with specified width
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Mbstring
|
||||
{
|
||||
const MB_CASE_FOLD = PHP_INT_MAX;
|
||||
|
||||
private static $encodingList = array('ASCII', 'UTF-8');
|
||||
private static $language = 'neutral';
|
||||
private static $internalEncoding = 'UTF-8';
|
||||
private static $caseFold = array(
|
||||
array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
|
||||
array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'),
|
||||
);
|
||||
|
||||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
||||
{
|
||||
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
|
||||
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
||||
} else {
|
||||
$fromEncoding = self::getEncoding($fromEncoding);
|
||||
}
|
||||
|
||||
$toEncoding = self::getEncoding($toEncoding);
|
||||
|
||||
if ('BASE64' === $fromEncoding) {
|
||||
$s = base64_decode($s);
|
||||
$fromEncoding = $toEncoding;
|
||||
}
|
||||
|
||||
if ('BASE64' === $toEncoding) {
|
||||
return base64_encode($s);
|
||||
}
|
||||
|
||||
if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
|
||||
if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
|
||||
$fromEncoding = 'Windows-1252';
|
||||
}
|
||||
if ('UTF-8' !== $fromEncoding) {
|
||||
$s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
|
||||
}
|
||||
|
||||
if ('HTML-ENTITIES' === $fromEncoding) {
|
||||
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
|
||||
$fromEncoding = 'UTF-8';
|
||||
}
|
||||
|
||||
return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
|
||||
}
|
||||
|
||||
public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
|
||||
{
|
||||
$vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
|
||||
|
||||
$ok = true;
|
||||
array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
|
||||
if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
|
||||
$ok = false;
|
||||
}
|
||||
});
|
||||
|
||||
return $ok ? $fromEncoding : false;
|
||||
}
|
||||
|
||||
public static function mb_decode_mimeheader($s)
|
||||
{
|
||||
return iconv_mime_decode($s, 2, self::$internalEncoding);
|
||||
}
|
||||
|
||||
public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
|
||||
{
|
||||
trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
|
||||
}
|
||||
|
||||
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
|
||||
{
|
||||
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
|
||||
trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
||||
|
||||
return ''; // Instead of null (cf. mb_encode_numericentity).
|
||||
}
|
||||
|
||||
$s = (string) $s;
|
||||
if ('' === $s) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$encoding = self::getEncoding($encoding);
|
||||
|
||||
if ('UTF-8' === $encoding) {
|
||||
$encoding = null;
|
||||
if (!preg_match('//u', $s)) {
|
||||
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
} else {
|
||||
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
$cnt = floor(\count($convmap) / 4) * 4;
|
||||
|
||||
for ($i = 0; $i < $cnt; $i += 4) {
|
||||
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
|
||||
$convmap[$i] += $convmap[$i + 2];
|
||||
$convmap[$i + 1] += $convmap[$i + 2];
|
||||
}
|
||||
|
||||
$s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
|
||||
$c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
|
||||
for ($i = 0; $i < $cnt; $i += 4) {
|
||||
if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
|
||||
return Mbstring::mb_chr($c - $convmap[$i + 2]);
|
||||
}
|
||||
}
|
||||
|
||||
return $m[0];
|
||||
}, $s);
|
||||
|
||||
if (null === $encoding) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
return iconv('UTF-8', $encoding.'//IGNORE', $s);
|
||||
}
|
||||
|
||||
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
|
||||
{
|
||||
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
|
||||
|
||||
return null; // Instead of '' (cf. mb_decode_numericentity).
|
||||
}
|
||||
|
||||
if (null !== $is_hex && !\is_scalar($is_hex)) {
|
||||
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$s = (string) $s;
|
||||
if ('' === $s) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$encoding = self::getEncoding($encoding);
|
||||
|
||||
if ('UTF-8' === $encoding) {
|
||||
$encoding = null;
|
||||
if (!preg_match('//u', $s)) {
|
||||
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
} else {
|
||||
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
||||
|
||||
$cnt = floor(\count($convmap) / 4) * 4;
|
||||
$i = 0;
|
||||
$len = \strlen($s);
|
||||
$result = '';
|
||||
|
||||
while ($i < $len) {
|
||||
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
||||
$uchr = substr($s, $i, $ulen);
|
||||
$i += $ulen;
|
||||
$c = self::mb_ord($uchr);
|
||||
|
||||
for ($j = 0; $j < $cnt; $j += 4) {
|
||||
if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
|
||||
$cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
|
||||
$result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$result .= $uchr;
|
||||
}
|
||||
|
||||
if (null === $encoding) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return iconv('UTF-8', $encoding.'//IGNORE', $result);
|
||||
}
|
||||
|
||||
public static function mb_convert_case($s, $mode, $encoding = null)
|
||||
{
|
||||
$s = (string) $s;
|
||||
if ('' === $s) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$encoding = self::getEncoding($encoding);
|
||||
|
||||
if ('UTF-8' === $encoding) {
|
||||
$encoding = null;
|
||||
if (!preg_match('//u', $s)) {
|
||||
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
} else {
|
||||
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
if (MB_CASE_TITLE == $mode) {
|
||||
static $titleRegexp = null;
|
||||
if (null === $titleRegexp) {
|
||||
$titleRegexp = self::getData('titleCaseRegexp');
|
||||
}
|
||||
$s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
|
||||
} else {
|
||||
if (MB_CASE_UPPER == $mode) {
|
||||
static $upper = null;
|
||||
if (null === $upper) {
|
||||
$upper = self::getData('upperCase');
|
||||
}
|
||||
$map = $upper;
|
||||
} else {
|
||||
if (self::MB_CASE_FOLD === $mode) {
|
||||
$s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
|
||||
}
|
||||
|
||||
static $lower = null;
|
||||
if (null === $lower) {
|
||||
$lower = self::getData('lowerCase');
|
||||
}
|
||||
$map = $lower;
|
||||
}
|
||||
|
||||
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
|
||||
|
||||
$i = 0;
|
||||
$len = \strlen($s);
|
||||
|
||||
while ($i < $len) {
|
||||
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
||||
$uchr = substr($s, $i, $ulen);
|
||||
$i += $ulen;
|
||||
|
||||
if (isset($map[$uchr])) {
|
||||
$uchr = $map[$uchr];
|
||||
$nlen = \strlen($uchr);
|
||||
|
||||
if ($nlen == $ulen) {
|
||||
$nlen = $i;
|
||||
do {
|
||||
$s[--$nlen] = $uchr[--$ulen];
|
||||
} while ($ulen);
|
||||
} else {
|
||||
$s = substr_replace($s, $uchr, $i - $ulen, $ulen);
|
||||
$len += $nlen - $ulen;
|
||||
$i += $nlen - $ulen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $encoding) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
return iconv('UTF-8', $encoding.'//IGNORE', $s);
|
||||
}
|
||||
|
||||
public static function mb_internal_encoding($encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
return self::$internalEncoding;
|
||||
}
|
||||
|
||||
$encoding = self::getEncoding($encoding);
|
||||
|
||||
if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
|
||||
self::$internalEncoding = $encoding;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_language($lang = null)
|
||||
{
|
||||
if (null === $lang) {
|
||||
return self::$language;
|
||||
}
|
||||
|
||||
switch ($lang = strtolower($lang)) {
|
||||
case 'uni':
|
||||
case 'neutral':
|
||||
self::$language = $lang;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_list_encodings()
|
||||
{
|
||||
return array('UTF-8');
|
||||
}
|
||||
|
||||
public static function mb_encoding_aliases($encoding)
|
||||
{
|
||||
switch (strtoupper($encoding)) {
|
||||
case 'UTF8':
|
||||
case 'UTF-8':
|
||||
return array('utf8');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_check_encoding($var = null, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
if (null === $var) {
|
||||
return false;
|
||||
}
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
|
||||
return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
|
||||
}
|
||||
|
||||
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
|
||||
{
|
||||
if (null === $encodingList) {
|
||||
$encodingList = self::$encodingList;
|
||||
} else {
|
||||
if (!\is_array($encodingList)) {
|
||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
||||
}
|
||||
$encodingList = array_map('strtoupper', $encodingList);
|
||||
}
|
||||
|
||||
foreach ($encodingList as $enc) {
|
||||
switch ($enc) {
|
||||
case 'ASCII':
|
||||
if (!preg_match('/[\x80-\xFF]/', $str)) {
|
||||
return $enc;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'UTF8':
|
||||
case 'UTF-8':
|
||||
if (preg_match('//u', $str)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (0 === strncmp($enc, 'ISO-8859-', 9)) {
|
||||
return $enc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_detect_order($encodingList = null)
|
||||
{
|
||||
if (null === $encodingList) {
|
||||
return self::$encodingList;
|
||||
}
|
||||
|
||||
if (!\is_array($encodingList)) {
|
||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
||||
}
|
||||
$encodingList = array_map('strtoupper', $encodingList);
|
||||
|
||||
foreach ($encodingList as $enc) {
|
||||
switch ($enc) {
|
||||
default:
|
||||
if (strncmp($enc, 'ISO-8859-', 9)) {
|
||||
return false;
|
||||
}
|
||||
// no break
|
||||
case 'ASCII':
|
||||
case 'UTF8':
|
||||
case 'UTF-8':
|
||||
}
|
||||
}
|
||||
|
||||
self::$encodingList = $encodingList;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function mb_strlen($s, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return \strlen($s);
|
||||
}
|
||||
|
||||
return @iconv_strlen($s, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
$needle = (string) $needle;
|
||||
if ('' === $needle) {
|
||||
trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return iconv_strpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return strrpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
if ($offset != (int) $offset) {
|
||||
$offset = 0;
|
||||
} elseif ($offset = (int) $offset) {
|
||||
if ($offset < 0) {
|
||||
if (0 > $offset += self::mb_strlen($needle)) {
|
||||
$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
|
||||
}
|
||||
$offset = 0;
|
||||
} else {
|
||||
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
|
||||
}
|
||||
}
|
||||
|
||||
$pos = iconv_strrpos($haystack, $needle, $encoding);
|
||||
|
||||
return false !== $pos ? $offset + $pos : false;
|
||||
}
|
||||
|
||||
public static function mb_str_split($string, $split_length = 1, $encoding = null)
|
||||
{
|
||||
if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
|
||||
trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (1 > $split_length = (int) $split_length) {
|
||||
trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null === $encoding) {
|
||||
$encoding = mb_internal_encoding();
|
||||
}
|
||||
|
||||
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
|
||||
$rx = '/(';
|
||||
while (65535 < $split_length) {
|
||||
$rx .= '.{65535}';
|
||||
$split_length -= 65535;
|
||||
}
|
||||
$rx .= '.{'.$split_length.'})/us';
|
||||
|
||||
return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$length = mb_strlen($string, $encoding);
|
||||
|
||||
for ($i = 0; $i < $length; $i += $split_length) {
|
||||
$result[] = mb_substr($string, $i, $split_length, $encoding);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function mb_strtolower($s, $encoding = null)
|
||||
{
|
||||
return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strtoupper($s, $encoding = null)
|
||||
{
|
||||
return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_substitute_character($c = null)
|
||||
{
|
||||
if (0 === strcasecmp($c, 'none')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return null !== $c ? false : 'none';
|
||||
}
|
||||
|
||||
public static function mb_substr($s, $start, $length = null, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return (string) substr($s, $start, null === $length ? 2147483647 : $length);
|
||||
}
|
||||
|
||||
if ($start < 0) {
|
||||
$start = iconv_strlen($s, $encoding) + $start;
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $length) {
|
||||
$length = 2147483647;
|
||||
} elseif ($length < 0) {
|
||||
$length = iconv_strlen($s, $encoding) + $length - $start;
|
||||
if ($length < 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return (string) iconv_substr($s, $start, $length, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
||||
|
||||
return self::mb_strpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
|
||||
{
|
||||
$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
|
||||
|
||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
||||
return strrchr($haystack, $needle, $part);
|
||||
}
|
||||
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
||||
$pos = iconv_strrpos($haystack, $needle, $encoding);
|
||||
|
||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
|
||||
{
|
||||
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
||||
$pos = self::mb_strripos($haystack, $needle, $encoding);
|
||||
|
||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
||||
|
||||
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
|
||||
public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
|
||||
{
|
||||
$pos = strpos($haystack, $needle);
|
||||
if (false === $pos) {
|
||||
return false;
|
||||
}
|
||||
if ($part) {
|
||||
return substr($haystack, 0, $pos);
|
||||
}
|
||||
|
||||
return substr($haystack, $pos);
|
||||
}
|
||||
|
||||
public static function mb_get_info($type = 'all')
|
||||
{
|
||||
$info = array(
|
||||
'internal_encoding' => self::$internalEncoding,
|
||||
'http_output' => 'pass',
|
||||
'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
|
||||
'func_overload' => 0,
|
||||
'func_overload_list' => 'no overload',
|
||||
'mail_charset' => 'UTF-8',
|
||||
'mail_header_encoding' => 'BASE64',
|
||||
'mail_body_encoding' => 'BASE64',
|
||||
'illegal_chars' => 0,
|
||||
'encoding_translation' => 'Off',
|
||||
'language' => self::$language,
|
||||
'detect_order' => self::$encodingList,
|
||||
'substitute_character' => 'none',
|
||||
'strict_detection' => 'Off',
|
||||
);
|
||||
|
||||
if ('all' === $type) {
|
||||
return $info;
|
||||
}
|
||||
if (isset($info[$type])) {
|
||||
return $info[$type];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_http_input($type = '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function mb_http_output($encoding = null)
|
||||
{
|
||||
return null !== $encoding ? 'pass' === $encoding : 'pass';
|
||||
}
|
||||
|
||||
public static function mb_strwidth($s, $encoding = null)
|
||||
{
|
||||
$encoding = self::getEncoding($encoding);
|
||||
|
||||
if ('UTF-8' !== $encoding) {
|
||||
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
|
||||
$s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
|
||||
|
||||
return ($wide << 1) + iconv_strlen($s, 'UTF-8');
|
||||
}
|
||||
|
||||
public static function mb_substr_count($haystack, $needle, $encoding = null)
|
||||
{
|
||||
return substr_count($haystack, $needle);
|
||||
}
|
||||
|
||||
public static function mb_output_handler($contents, $status)
|
||||
{
|
||||
return $contents;
|
||||
}
|
||||
|
||||
public static function mb_chr($code, $encoding = null)
|
||||
{
|
||||
if (0x80 > $code %= 0x200000) {
|
||||
$s = \chr($code);
|
||||
} elseif (0x800 > $code) {
|
||||
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
|
||||
} elseif (0x10000 > $code) {
|
||||
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
||||
} else {
|
||||
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
||||
}
|
||||
|
||||
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
||||
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
public static function mb_ord($s, $encoding = null)
|
||||
{
|
||||
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
||||
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
|
||||
}
|
||||
|
||||
if (1 === \strlen($s)) {
|
||||
return \ord($s);
|
||||
}
|
||||
|
||||
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
|
||||
if (0xF0 <= $code) {
|
||||
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
|
||||
}
|
||||
if (0xE0 <= $code) {
|
||||
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
|
||||
}
|
||||
if (0xC0 <= $code) {
|
||||
return (($code - 0xC0) << 6) + $s[2] - 0x80;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
private static function getSubpart($pos, $part, $haystack, $encoding)
|
||||
{
|
||||
if (false === $pos) {
|
||||
return false;
|
||||
}
|
||||
if ($part) {
|
||||
return self::mb_substr($haystack, 0, $pos, $encoding);
|
||||
}
|
||||
|
||||
return self::mb_substr($haystack, $pos, null, $encoding);
|
||||
}
|
||||
|
||||
private static function html_encoding_callback(array $m)
|
||||
{
|
||||
$i = 1;
|
||||
$entities = '';
|
||||
$m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
|
||||
|
||||
while (isset($m[$i])) {
|
||||
if (0x80 > $m[$i]) {
|
||||
$entities .= \chr($m[$i++]);
|
||||
continue;
|
||||
}
|
||||
if (0xF0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} elseif (0xE0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} else {
|
||||
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
|
||||
}
|
||||
|
||||
$entities .= '&#'.$c.';';
|
||||
}
|
||||
|
||||
return $entities;
|
||||
}
|
||||
|
||||
private static function title_case(array $s)
|
||||
{
|
||||
return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
|
||||
}
|
||||
|
||||
private static function getData($file)
|
||||
{
|
||||
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
|
||||
return require $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function getEncoding($encoding)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
return self::$internalEncoding;
|
||||
}
|
||||
|
||||
if ('UTF-8' === $encoding) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
$encoding = strtoupper($encoding);
|
||||
|
||||
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
|
||||
return 'CP850';
|
||||
}
|
||||
|
||||
if ('UTF8' === $encoding) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
return $encoding;
|
||||
}
|
||||
}
|
||||
13
vendor/symfony/polyfill-mbstring/README.md
vendored
Normal file
13
vendor/symfony/polyfill-mbstring/README.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Symfony Polyfill / Mbstring
|
||||
===========================
|
||||
|
||||
This component provides a partial, native PHP implementation for the
|
||||
[Mbstring](https://php.net/mbstring) extension.
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
1096
vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php
vendored
Normal file
1096
vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php
vendored
Normal file
5
vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php
vendored
Normal file
File diff suppressed because one or more lines are too long
1104
vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php
vendored
Normal file
1104
vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
64
vendor/symfony/polyfill-mbstring/bootstrap.php
vendored
Normal file
64
vendor/symfony/polyfill-mbstring/bootstrap.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Symfony\Polyfill\Mbstring as p;
|
||||
|
||||
if (!defined('MB_CASE_UPPER')) {
|
||||
define('MB_CASE_UPPER', 0);
|
||||
define('MB_CASE_LOWER', 1);
|
||||
define('MB_CASE_TITLE', 2);
|
||||
}
|
||||
|
||||
if (!function_exists('mb_strlen')) {
|
||||
function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); }
|
||||
function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); }
|
||||
function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); }
|
||||
function mb_decode_numericentity($s, $convmap, $enc = null) { return p\Mbstring::mb_decode_numericentity($s, $convmap, $enc); }
|
||||
function mb_encode_numericentity($s, $convmap, $enc = null, $is_hex = false) { return p\Mbstring::mb_encode_numericentity($s, $convmap, $enc, $is_hex); }
|
||||
function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
|
||||
function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); }
|
||||
function mb_language($lang = null) { return p\Mbstring::mb_language($lang); }
|
||||
function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
|
||||
function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
|
||||
function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); }
|
||||
function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); }
|
||||
function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); }
|
||||
function mb_parse_str($s, &$result = array()) { parse_str($s, $result); }
|
||||
function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
|
||||
function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); }
|
||||
function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
|
||||
function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
|
||||
function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); }
|
||||
function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
|
||||
function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); }
|
||||
function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); }
|
||||
function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); }
|
||||
function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); }
|
||||
function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); }
|
||||
function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); }
|
||||
function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); }
|
||||
function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
|
||||
function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); }
|
||||
function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
|
||||
function mb_substr_count($haystack, $needle, $enc = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $enc); }
|
||||
function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); }
|
||||
function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
|
||||
function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) { return p\Mbstring::mb_convert_variables($toEncoding, $fromEncoding, $a, $b, $c, $d, $e, $f); }
|
||||
}
|
||||
if (!function_exists('mb_chr')) {
|
||||
function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); }
|
||||
function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); }
|
||||
function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_str_split')) {
|
||||
function mb_str_split($string, $split_length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $split_length, $encoding); }
|
||||
}
|
||||
34
vendor/symfony/polyfill-mbstring/composer.json
vendored
Normal file
34
vendor/symfony/polyfill-mbstring/composer.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"type": "library",
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"keywords": ["polyfill", "shim", "compatibility", "portable", "mbstring"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" },
|
||||
"files": [ "bootstrap.php" ]
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
3
vendor/symfony/property-access/.gitignore
vendored
Normal file
3
vendor/symfony/property-access/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
29
vendor/symfony/property-access/CHANGELOG.md
vendored
Normal file
29
vendor/symfony/property-access/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.7.0
|
||||
------
|
||||
|
||||
* `UnexpectedTypeException` now expects three constructor arguments: The invalid property value,
|
||||
the `PropertyPathInterface` object and the current index of the property path.
|
||||
|
||||
2.5.0
|
||||
------
|
||||
|
||||
* allowed non alpha numeric characters in second level and deeper object properties names
|
||||
* [BC BREAK] when accessing an index on an object that does not implement
|
||||
ArrayAccess, a NoSuchIndexException is now thrown instead of the
|
||||
semantically wrong NoSuchPropertyException
|
||||
* [BC BREAK] added isReadable() and isWritable() to PropertyAccessorInterface
|
||||
|
||||
2.3.0
|
||||
------
|
||||
|
||||
* added PropertyAccessorBuilder, to enable or disable the support of "__call"
|
||||
* added support for "__call" in the PropertyAccessor (disabled by default)
|
||||
* [BC BREAK] changed PropertyAccessor to continue its search for a property or
|
||||
method even if a non-public match was found. Before, a PropertyAccessDeniedException
|
||||
was thrown in this case. Class PropertyAccessDeniedException was removed
|
||||
now.
|
||||
* deprecated PropertyAccess::getPropertyAccessor
|
||||
* added PropertyAccess::createPropertyAccessor and PropertyAccess::createPropertyAccessorBuilder
|
||||
21
vendor/symfony/property-access/Exception/AccessException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/AccessException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a property path is not available.
|
||||
*
|
||||
* @author Stéphane Escandell <stephane.escandell@gmail.com>
|
||||
*/
|
||||
class AccessException extends RuntimeException
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/ExceptionInterface.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Marker interface for the PropertyAccess component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/InvalidArgumentException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Base InvalidArgumentException for the PropertyAccess component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/InvalidPropertyPathException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/InvalidPropertyPathException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a property path is malformed.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class InvalidPropertyPathException extends RuntimeException
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/NoSuchIndexException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/NoSuchIndexException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when an index cannot be found.
|
||||
*
|
||||
* @author Stéphane Escandell <stephane.escandell@gmail.com>
|
||||
*/
|
||||
class NoSuchIndexException extends AccessException
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/NoSuchPropertyException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/NoSuchPropertyException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a property cannot be found.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class NoSuchPropertyException extends AccessException
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/OutOfBoundsException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/OutOfBoundsException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Base OutOfBoundsException for the PropertyAccess component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
vendor/symfony/property-access/Exception/RuntimeException.php
vendored
Normal file
21
vendor/symfony/property-access/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
/**
|
||||
* Base RuntimeException for the PropertyAccess component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
50
vendor/symfony/property-access/Exception/UnexpectedTypeException.php
vendored
Normal file
50
vendor/symfony/property-access/Exception/UnexpectedTypeException.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Exception;
|
||||
|
||||
use Symfony\Component\PropertyAccess\PropertyPathInterface;
|
||||
|
||||
/**
|
||||
* Thrown when a value does not match an expected type.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class UnexpectedTypeException extends RuntimeException
|
||||
{
|
||||
/**
|
||||
* @param mixed $value The unexpected value found while traversing property path
|
||||
* @param PropertyPathInterface $path The property path
|
||||
* @param int $pathIndex The property path index when the unexpected value was found
|
||||
*/
|
||||
public function __construct($value, $path, $pathIndex = null)
|
||||
{
|
||||
if (3 === \func_num_args() && $path instanceof PropertyPathInterface) {
|
||||
$message = sprintf(
|
||||
'PropertyAccessor requires a graph of objects or arrays to operate on, '.
|
||||
'but it found type "%s" while trying to traverse path "%s" at property "%s".',
|
||||
\gettype($value),
|
||||
(string) $path,
|
||||
$path->getElement($pathIndex)
|
||||
);
|
||||
} else {
|
||||
@trigger_error('The '.__CLASS__.' constructor now expects 3 arguments: the invalid property value, the '.__NAMESPACE__.'\PropertyPathInterface object and the current index of the property path.', E_USER_DEPRECATED);
|
||||
|
||||
$message = sprintf(
|
||||
'Expected argument of type "%s", "%s" given',
|
||||
$path,
|
||||
\is_object($value) ? \get_class($value) : \gettype($value)
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/property-access/LICENSE
vendored
Normal file
19
vendor/symfony/property-access/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
|
||||
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.
|
||||
62
vendor/symfony/property-access/PropertyAccess.php
vendored
Normal file
62
vendor/symfony/property-access/PropertyAccess.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* Entry point of the PropertyAccess component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
final class PropertyAccess
|
||||
{
|
||||
/**
|
||||
* Creates a property accessor with the default configuration.
|
||||
*
|
||||
* @return PropertyAccessor
|
||||
*/
|
||||
public static function createPropertyAccessor()
|
||||
{
|
||||
return self::createPropertyAccessorBuilder()->getPropertyAccessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a property accessor builder.
|
||||
*
|
||||
* @return PropertyAccessorBuilder
|
||||
*/
|
||||
public static function createPropertyAccessorBuilder()
|
||||
{
|
||||
return new PropertyAccessorBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of {@link createPropertyAccessor}.
|
||||
*
|
||||
* @return PropertyAccessor
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
* Use {@link createPropertyAccessor()} instead.
|
||||
*/
|
||||
public static function getPropertyAccessor()
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0. Use the createPropertyAccessor() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
return self::createPropertyAccessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class cannot be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
812
vendor/symfony/property-access/PropertyAccessor.php
vendored
Normal file
812
vendor/symfony/property-access/PropertyAccessor.php
vendored
Normal file
@@ -0,0 +1,812 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\AccessException;
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
|
||||
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
|
||||
use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link PropertyAccessorInterface}.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class PropertyAccessor implements PropertyAccessorInterface
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const VALUE = 0;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const REF = 1;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const IS_REF_CHAINED = 2;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_HAS_PROPERTY = 0;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE = 1;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_NAME = 2;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_REF = 3;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_ADDER = 4;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_REMOVER = 5;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE_METHOD = 0;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE_PROPERTY = 1;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE_MAGIC = 2;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE_ADDER_AND_REMOVER = 3;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ACCESS_TYPE_NOT_FOUND = 4;
|
||||
|
||||
private $magicCall;
|
||||
private $ignoreInvalidIndices;
|
||||
private $readPropertyCache = array();
|
||||
private $writePropertyCache = array();
|
||||
|
||||
private static $previousErrorHandler = false;
|
||||
private static $errorHandler = array(__CLASS__, 'handleError');
|
||||
private static $resultProto = array(self::VALUE => null);
|
||||
|
||||
/**
|
||||
* Should not be used by application code. Use
|
||||
* {@link PropertyAccess::createPropertyAccessor()} instead.
|
||||
*
|
||||
* @param bool $magicCall
|
||||
* @param bool $throwExceptionOnInvalidIndex
|
||||
*/
|
||||
public function __construct($magicCall = false, $throwExceptionOnInvalidIndex = false)
|
||||
{
|
||||
$this->magicCall = $magicCall;
|
||||
$this->ignoreInvalidIndices = !$throwExceptionOnInvalidIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getValue($objectOrArray, $propertyPath)
|
||||
{
|
||||
if (!$propertyPath instanceof PropertyPathInterface) {
|
||||
$propertyPath = new PropertyPath($propertyPath);
|
||||
}
|
||||
|
||||
$zval = array(
|
||||
self::VALUE => $objectOrArray,
|
||||
);
|
||||
$propertyValues = $this->readPropertiesUntil($zval, $propertyPath, $propertyPath->getLength(), $this->ignoreInvalidIndices);
|
||||
|
||||
return $propertyValues[\count($propertyValues) - 1][self::VALUE];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue(&$objectOrArray, $propertyPath, $value)
|
||||
{
|
||||
if (!$propertyPath instanceof PropertyPathInterface) {
|
||||
$propertyPath = new PropertyPath($propertyPath);
|
||||
}
|
||||
|
||||
$zval = array(
|
||||
self::VALUE => $objectOrArray,
|
||||
self::REF => &$objectOrArray,
|
||||
);
|
||||
$propertyValues = $this->readPropertiesUntil($zval, $propertyPath, $propertyPath->getLength() - 1);
|
||||
$overwrite = true;
|
||||
|
||||
try {
|
||||
if (\PHP_VERSION_ID < 70000 && false === self::$previousErrorHandler) {
|
||||
self::$previousErrorHandler = set_error_handler(self::$errorHandler);
|
||||
}
|
||||
|
||||
for ($i = \count($propertyValues) - 1; 0 <= $i; --$i) {
|
||||
$zval = $propertyValues[$i];
|
||||
unset($propertyValues[$i]);
|
||||
|
||||
// You only need set value for current element if:
|
||||
// 1. it's the parent of the last index element
|
||||
// OR
|
||||
// 2. its child is not passed by reference
|
||||
//
|
||||
// This may avoid uncessary value setting process for array elements.
|
||||
// For example:
|
||||
// '[a][b][c]' => 'old-value'
|
||||
// If you want to change its value to 'new-value',
|
||||
// you only need set value for '[a][b][c]' and it's safe to ignore '[a][b]' and '[a]'
|
||||
if ($overwrite) {
|
||||
$property = $propertyPath->getElement($i);
|
||||
|
||||
if ($propertyPath->isIndex($i)) {
|
||||
if ($overwrite = !isset($zval[self::REF])) {
|
||||
$ref = &$zval[self::REF];
|
||||
$ref = $zval[self::VALUE];
|
||||
}
|
||||
$this->writeIndex($zval, $property, $value);
|
||||
if ($overwrite) {
|
||||
$zval[self::VALUE] = $zval[self::REF];
|
||||
}
|
||||
} else {
|
||||
$this->writeProperty($zval, $property, $value);
|
||||
}
|
||||
|
||||
// if current element is an object
|
||||
// OR
|
||||
// if current element's reference chain is not broken - current element
|
||||
// as well as all its ancients in the property path are all passed by reference,
|
||||
// then there is no need to continue the value setting process
|
||||
if (\is_object($zval[self::VALUE]) || isset($zval[self::IS_REF_CHAINED])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$value = $zval[self::VALUE];
|
||||
}
|
||||
} catch (\TypeError $e) {
|
||||
try {
|
||||
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
|
||||
restore_error_handler();
|
||||
self::$previousErrorHandler = false;
|
||||
}
|
||||
if (isset($e)) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function handleError($type, $message, $file, $line, $context)
|
||||
{
|
||||
if (E_RECOVERABLE_ERROR === $type) {
|
||||
self::throwInvalidArgumentException($message, debug_backtrace(false), 1);
|
||||
}
|
||||
|
||||
return null !== self::$previousErrorHandler && false !== \call_user_func(self::$previousErrorHandler, $type, $message, $file, $line, $context);
|
||||
}
|
||||
|
||||
private static function throwInvalidArgumentException($message, $trace, $i)
|
||||
{
|
||||
// the type mismatch is not caused by invalid arguments (but e.g. by an incompatible return type hint of the writer method)
|
||||
if (0 !== strpos($message, 'Argument ')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file'] && array_key_exists(0, $trace[$i]['args'])) {
|
||||
$pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface '));
|
||||
$pos += \strlen($delim);
|
||||
$type = $trace[$i]['args'][0];
|
||||
$type = \is_object($type) ? \get_class($type) : \gettype($type);
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given', substr($message, $pos, strpos($message, ',', $pos) - $pos), $type));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isReadable($objectOrArray, $propertyPath)
|
||||
{
|
||||
if (!$propertyPath instanceof PropertyPathInterface) {
|
||||
$propertyPath = new PropertyPath($propertyPath);
|
||||
}
|
||||
|
||||
try {
|
||||
$zval = array(
|
||||
self::VALUE => $objectOrArray,
|
||||
);
|
||||
$this->readPropertiesUntil($zval, $propertyPath, $propertyPath->getLength(), $this->ignoreInvalidIndices);
|
||||
|
||||
return true;
|
||||
} catch (AccessException $e) {
|
||||
return false;
|
||||
} catch (UnexpectedTypeException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isWritable($objectOrArray, $propertyPath)
|
||||
{
|
||||
if (!$propertyPath instanceof PropertyPathInterface) {
|
||||
$propertyPath = new PropertyPath($propertyPath);
|
||||
}
|
||||
|
||||
try {
|
||||
$zval = array(
|
||||
self::VALUE => $objectOrArray,
|
||||
);
|
||||
$propertyValues = $this->readPropertiesUntil($zval, $propertyPath, $propertyPath->getLength() - 1);
|
||||
|
||||
for ($i = \count($propertyValues) - 1; 0 <= $i; --$i) {
|
||||
$zval = $propertyValues[$i];
|
||||
unset($propertyValues[$i]);
|
||||
|
||||
if ($propertyPath->isIndex($i)) {
|
||||
if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!$this->isPropertyWritable($zval[self::VALUE], $propertyPath->getElement($i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (\is_object($zval[self::VALUE])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (AccessException $e) {
|
||||
return false;
|
||||
} catch (UnexpectedTypeException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the path from an object up to a given path index.
|
||||
*
|
||||
* @param array $zval The array containing the object or array to read from
|
||||
* @param PropertyPathInterface $propertyPath The property path to read
|
||||
* @param int $lastIndex The index up to which should be read
|
||||
* @param bool $ignoreInvalidIndices Whether to ignore invalid indices or throw an exception
|
||||
*
|
||||
* @return array The values read in the path
|
||||
*
|
||||
* @throws UnexpectedTypeException if a value within the path is neither object nor array
|
||||
* @throws NoSuchIndexException If a non-existing index is accessed
|
||||
*/
|
||||
private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath, $lastIndex, $ignoreInvalidIndices = true)
|
||||
{
|
||||
if (!\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
|
||||
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, 0);
|
||||
}
|
||||
|
||||
// Add the root object to the list
|
||||
$propertyValues = array($zval);
|
||||
|
||||
for ($i = 0; $i < $lastIndex; ++$i) {
|
||||
$property = $propertyPath->getElement($i);
|
||||
$isIndex = $propertyPath->isIndex($i);
|
||||
|
||||
if ($isIndex) {
|
||||
// Create missing nested arrays on demand
|
||||
if (($zval[self::VALUE] instanceof \ArrayAccess && !$zval[self::VALUE]->offsetExists($property)) ||
|
||||
(\is_array($zval[self::VALUE]) && !isset($zval[self::VALUE][$property]) && !array_key_exists($property, $zval[self::VALUE]))
|
||||
) {
|
||||
if (!$ignoreInvalidIndices) {
|
||||
if (!\is_array($zval[self::VALUE])) {
|
||||
if (!$zval[self::VALUE] instanceof \Traversable) {
|
||||
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s".', $property, (string) $propertyPath));
|
||||
}
|
||||
|
||||
$zval[self::VALUE] = iterator_to_array($zval[self::VALUE]);
|
||||
}
|
||||
|
||||
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s". Available indices are "%s".', $property, (string) $propertyPath, print_r(array_keys($zval[self::VALUE]), true)));
|
||||
}
|
||||
|
||||
if ($i + 1 < $propertyPath->getLength()) {
|
||||
if (isset($zval[self::REF])) {
|
||||
$zval[self::VALUE][$property] = array();
|
||||
$zval[self::REF] = $zval[self::VALUE];
|
||||
} else {
|
||||
$zval[self::VALUE] = array($property => array());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$zval = $this->readIndex($zval, $property);
|
||||
} else {
|
||||
$zval = $this->readProperty($zval, $property);
|
||||
}
|
||||
|
||||
// the final value of the path must not be validated
|
||||
if ($i + 1 < $propertyPath->getLength() && !\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
|
||||
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, $i + 1);
|
||||
}
|
||||
|
||||
if (isset($zval[self::REF]) && (0 === $i || isset($propertyValues[$i - 1][self::IS_REF_CHAINED]))) {
|
||||
// Set the IS_REF_CHAINED flag to true if:
|
||||
// current property is passed by reference and
|
||||
// it is the first element in the property path or
|
||||
// the IS_REF_CHAINED flag of its parent element is true
|
||||
// Basically, this flag is true only when the reference chain from the top element to current element is not broken
|
||||
$zval[self::IS_REF_CHAINED] = true;
|
||||
}
|
||||
|
||||
$propertyValues[] = $zval;
|
||||
}
|
||||
|
||||
return $propertyValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a key from an array-like structure.
|
||||
*
|
||||
* @param array $zval The array containing the array or \ArrayAccess object to read from
|
||||
* @param string|int $index The key to read
|
||||
*
|
||||
* @return array The array containing the value of the key
|
||||
*
|
||||
* @throws NoSuchIndexException If the array does not implement \ArrayAccess or it is not an array
|
||||
*/
|
||||
private function readIndex($zval, $index)
|
||||
{
|
||||
if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
|
||||
throw new NoSuchIndexException(sprintf('Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, \get_class($zval[self::VALUE])));
|
||||
}
|
||||
|
||||
$result = self::$resultProto;
|
||||
|
||||
if (isset($zval[self::VALUE][$index])) {
|
||||
$result[self::VALUE] = $zval[self::VALUE][$index];
|
||||
|
||||
if (!isset($zval[self::REF])) {
|
||||
// Save creating references when doing read-only lookups
|
||||
} elseif (\is_array($zval[self::VALUE])) {
|
||||
$result[self::REF] = &$zval[self::REF][$index];
|
||||
} elseif (\is_object($result[self::VALUE])) {
|
||||
$result[self::REF] = $result[self::VALUE];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the a property from an object.
|
||||
*
|
||||
* @param array $zval The array containing the object to read from
|
||||
* @param string $property The property to read
|
||||
*
|
||||
* @return array The array containing the value of the property
|
||||
*
|
||||
* @throws NoSuchPropertyException if the property does not exist or is not public
|
||||
*/
|
||||
private function readProperty($zval, $property)
|
||||
{
|
||||
if (!\is_object($zval[self::VALUE])) {
|
||||
throw new NoSuchPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you intended to write the property path as "[%1$s]" instead.', $property));
|
||||
}
|
||||
|
||||
$result = self::$resultProto;
|
||||
$object = $zval[self::VALUE];
|
||||
$access = $this->getReadAccessInfo(\get_class($object), $property);
|
||||
|
||||
if (self::ACCESS_TYPE_METHOD === $access[self::ACCESS_TYPE]) {
|
||||
$result[self::VALUE] = $object->{$access[self::ACCESS_NAME]}();
|
||||
} elseif (self::ACCESS_TYPE_PROPERTY === $access[self::ACCESS_TYPE]) {
|
||||
$result[self::VALUE] = $object->{$access[self::ACCESS_NAME]};
|
||||
|
||||
if ($access[self::ACCESS_REF] && isset($zval[self::REF])) {
|
||||
$result[self::REF] = &$object->{$access[self::ACCESS_NAME]};
|
||||
}
|
||||
} elseif (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property)) {
|
||||
// Needed to support \stdClass instances. We need to explicitly
|
||||
// exclude $access[self::ACCESS_HAS_PROPERTY], otherwise if
|
||||
// a *protected* property was found on the class, property_exists()
|
||||
// returns true, consequently the following line will result in a
|
||||
// fatal error.
|
||||
|
||||
$result[self::VALUE] = $object->$property;
|
||||
if (isset($zval[self::REF])) {
|
||||
$result[self::REF] = &$object->$property;
|
||||
}
|
||||
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
|
||||
// we call the getter and hope the __call do the job
|
||||
$result[self::VALUE] = $object->{$access[self::ACCESS_NAME]}();
|
||||
} else {
|
||||
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
|
||||
}
|
||||
|
||||
// Objects are always passed around by reference
|
||||
if (isset($zval[self::REF]) && \is_object($result[self::VALUE])) {
|
||||
$result[self::REF] = $result[self::VALUE];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses how to read the property value.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $property
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getReadAccessInfo($class, $property)
|
||||
{
|
||||
$key = $class.'::'.$property;
|
||||
|
||||
if (isset($this->readPropertyCache[$key])) {
|
||||
$access = $this->readPropertyCache[$key];
|
||||
} else {
|
||||
$access = array();
|
||||
|
||||
$reflClass = new \ReflectionClass($class);
|
||||
$access[self::ACCESS_HAS_PROPERTY] = $reflClass->hasProperty($property);
|
||||
$camelProp = $this->camelize($property);
|
||||
$getter = 'get'.$camelProp;
|
||||
$getsetter = lcfirst($camelProp); // jQuery style, e.g. read: last(), write: last($item)
|
||||
$isser = 'is'.$camelProp;
|
||||
$hasser = 'has'.$camelProp;
|
||||
|
||||
if ($reflClass->hasMethod($getter) && $reflClass->getMethod($getter)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $getter;
|
||||
} elseif ($reflClass->hasMethod($getsetter) && $reflClass->getMethod($getsetter)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $getsetter;
|
||||
} elseif ($reflClass->hasMethod($isser) && $reflClass->getMethod($isser)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $isser;
|
||||
} elseif ($reflClass->hasMethod($hasser) && $reflClass->getMethod($hasser)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $hasser;
|
||||
} elseif ($reflClass->hasMethod('__get') && $reflClass->getMethod('__get')->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY;
|
||||
$access[self::ACCESS_NAME] = $property;
|
||||
$access[self::ACCESS_REF] = false;
|
||||
} elseif ($access[self::ACCESS_HAS_PROPERTY] && $reflClass->getProperty($property)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY;
|
||||
$access[self::ACCESS_NAME] = $property;
|
||||
$access[self::ACCESS_REF] = true;
|
||||
} elseif ($this->magicCall && $reflClass->hasMethod('__call') && $reflClass->getMethod('__call')->isPublic()) {
|
||||
// we call the getter and hope the __call do the job
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_MAGIC;
|
||||
$access[self::ACCESS_NAME] = $getter;
|
||||
} else {
|
||||
$methods = array($getter, $getsetter, $isser, $hasser, '__get');
|
||||
if ($this->magicCall) {
|
||||
$methods[] = '__call';
|
||||
}
|
||||
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_NOT_FOUND;
|
||||
$access[self::ACCESS_NAME] = sprintf(
|
||||
'Neither the property "%s" nor one of the methods "%s()" '.
|
||||
'exist and have public access in class "%s".',
|
||||
$property,
|
||||
implode('()", "', $methods),
|
||||
$reflClass->name
|
||||
);
|
||||
}
|
||||
|
||||
$this->readPropertyCache[$key] = $access;
|
||||
}
|
||||
|
||||
return $access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of an index in a given array-accessible value.
|
||||
*
|
||||
* @param array $zval The array containing the array or \ArrayAccess object to write to
|
||||
* @param string|int $index The index to write at
|
||||
* @param mixed $value The value to write
|
||||
*
|
||||
* @throws NoSuchIndexException If the array does not implement \ArrayAccess or it is not an array
|
||||
*/
|
||||
private function writeIndex($zval, $index, $value)
|
||||
{
|
||||
if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
|
||||
throw new NoSuchIndexException(sprintf('Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess', $index, \get_class($zval[self::VALUE])));
|
||||
}
|
||||
|
||||
$zval[self::REF][$index] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a property in the given object.
|
||||
*
|
||||
* @param array $zval The array containing the object to write to
|
||||
* @param string $property The property to write
|
||||
* @param mixed $value The value to write
|
||||
*
|
||||
* @throws NoSuchPropertyException if the property does not exist or is not public
|
||||
*/
|
||||
private function writeProperty($zval, $property, $value)
|
||||
{
|
||||
if (!\is_object($zval[self::VALUE])) {
|
||||
throw new NoSuchPropertyException(sprintf('Cannot write property "%s" to an array. Maybe you should write the property path as "[%1$s]" instead?', $property));
|
||||
}
|
||||
|
||||
$object = $zval[self::VALUE];
|
||||
$access = $this->getWriteAccessInfo(\get_class($object), $property, $value);
|
||||
|
||||
if (self::ACCESS_TYPE_METHOD === $access[self::ACCESS_TYPE]) {
|
||||
$object->{$access[self::ACCESS_NAME]}($value);
|
||||
} elseif (self::ACCESS_TYPE_PROPERTY === $access[self::ACCESS_TYPE]) {
|
||||
$object->{$access[self::ACCESS_NAME]} = $value;
|
||||
} elseif (self::ACCESS_TYPE_ADDER_AND_REMOVER === $access[self::ACCESS_TYPE]) {
|
||||
$this->writeCollection($zval, $property, $value, $access[self::ACCESS_ADDER], $access[self::ACCESS_REMOVER]);
|
||||
} elseif (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property)) {
|
||||
// Needed to support \stdClass instances. We need to explicitly
|
||||
// exclude $access[self::ACCESS_HAS_PROPERTY], otherwise if
|
||||
// a *protected* property was found on the class, property_exists()
|
||||
// returns true, consequently the following line will result in a
|
||||
// fatal error.
|
||||
|
||||
$object->$property = $value;
|
||||
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
|
||||
$object->{$access[self::ACCESS_NAME]}($value);
|
||||
} else {
|
||||
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts a collection-valued property by calling add*() and remove*() methods.
|
||||
*
|
||||
* @param array $zval The array containing the object to write to
|
||||
* @param string $property The property to write
|
||||
* @param iterable $collection The collection to write
|
||||
* @param string $addMethod The add*() method
|
||||
* @param string $removeMethod The remove*() method
|
||||
*/
|
||||
private function writeCollection($zval, $property, $collection, $addMethod, $removeMethod)
|
||||
{
|
||||
// At this point the add and remove methods have been found
|
||||
$previousValue = $this->readProperty($zval, $property);
|
||||
$previousValue = $previousValue[self::VALUE];
|
||||
|
||||
if ($previousValue instanceof \Traversable) {
|
||||
$previousValue = iterator_to_array($previousValue);
|
||||
}
|
||||
if ($previousValue && \is_array($previousValue)) {
|
||||
if (\is_object($collection)) {
|
||||
$collection = iterator_to_array($collection);
|
||||
}
|
||||
foreach ($previousValue as $key => $item) {
|
||||
if (!\in_array($item, $collection, true)) {
|
||||
unset($previousValue[$key]);
|
||||
$zval[self::VALUE]->{$removeMethod}($item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$previousValue = false;
|
||||
}
|
||||
|
||||
foreach ($collection as $item) {
|
||||
if (!$previousValue || !\in_array($item, $previousValue, true)) {
|
||||
$zval[self::VALUE]->{$addMethod}($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses how to write the property value.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getWriteAccessInfo($class, $property, $value)
|
||||
{
|
||||
$key = $class.'::'.$property;
|
||||
|
||||
if (isset($this->writePropertyCache[$key])) {
|
||||
$access = $this->writePropertyCache[$key];
|
||||
} else {
|
||||
$access = array();
|
||||
|
||||
$reflClass = new \ReflectionClass($class);
|
||||
$access[self::ACCESS_HAS_PROPERTY] = $reflClass->hasProperty($property);
|
||||
$camelized = $this->camelize($property);
|
||||
$singulars = (array) StringUtil::singularify($camelized);
|
||||
|
||||
if (\is_array($value) || $value instanceof \Traversable) {
|
||||
$methods = $this->findAdderAndRemover($reflClass, $singulars);
|
||||
|
||||
if (null !== $methods) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_ADDER_AND_REMOVER;
|
||||
$access[self::ACCESS_ADDER] = $methods[0];
|
||||
$access[self::ACCESS_REMOVER] = $methods[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($access[self::ACCESS_TYPE])) {
|
||||
$setter = 'set'.$camelized;
|
||||
$getsetter = lcfirst($camelized); // jQuery style, e.g. read: last(), write: last($item)
|
||||
|
||||
if ($this->isMethodAccessible($reflClass, $setter, 1)) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $setter;
|
||||
} elseif ($this->isMethodAccessible($reflClass, $getsetter, 1)) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD;
|
||||
$access[self::ACCESS_NAME] = $getsetter;
|
||||
} elseif ($this->isMethodAccessible($reflClass, '__set', 2)) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY;
|
||||
$access[self::ACCESS_NAME] = $property;
|
||||
} elseif ($access[self::ACCESS_HAS_PROPERTY] && $reflClass->getProperty($property)->isPublic()) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY;
|
||||
$access[self::ACCESS_NAME] = $property;
|
||||
} elseif ($this->magicCall && $this->isMethodAccessible($reflClass, '__call', 2)) {
|
||||
// we call the getter and hope the __call do the job
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_MAGIC;
|
||||
$access[self::ACCESS_NAME] = $setter;
|
||||
} elseif (null !== $methods = $this->findAdderAndRemover($reflClass, $singulars)) {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_NOT_FOUND;
|
||||
$access[self::ACCESS_NAME] = sprintf(
|
||||
'The property "%s" in class "%s" can be defined with the methods "%s()" but '.
|
||||
'the new value must be an array or an instance of \Traversable, '.
|
||||
'"%s" given.',
|
||||
$property,
|
||||
$reflClass->name,
|
||||
implode('()", "', $methods),
|
||||
\is_object($value) ? \get_class($value) : \gettype($value)
|
||||
);
|
||||
} else {
|
||||
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_NOT_FOUND;
|
||||
$access[self::ACCESS_NAME] = sprintf(
|
||||
'Neither the property "%s" nor one of the methods %s"%s()", "%s()", '.
|
||||
'"__set()" or "__call()" exist and have public access in class "%s".',
|
||||
$property,
|
||||
implode('', array_map(function ($singular) {
|
||||
return '"add'.$singular.'()"/"remove'.$singular.'()", ';
|
||||
}, $singulars)),
|
||||
$setter,
|
||||
$getsetter,
|
||||
$reflClass->name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writePropertyCache[$key] = $access;
|
||||
}
|
||||
|
||||
return $access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a property is writable in the given object.
|
||||
*
|
||||
* @param object $object The object to write to
|
||||
* @param string $property The property to write
|
||||
*
|
||||
* @return bool Whether the property is writable
|
||||
*/
|
||||
private function isPropertyWritable($object, $property)
|
||||
{
|
||||
if (!\is_object($object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$access = $this->getWriteAccessInfo(\get_class($object), $property, array());
|
||||
|
||||
return self::ACCESS_TYPE_METHOD === $access[self::ACCESS_TYPE]
|
||||
|| self::ACCESS_TYPE_PROPERTY === $access[self::ACCESS_TYPE]
|
||||
|| self::ACCESS_TYPE_ADDER_AND_REMOVER === $access[self::ACCESS_TYPE]
|
||||
|| (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property))
|
||||
|| self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Camelizes a given string.
|
||||
*
|
||||
* @param string $string Some string
|
||||
*
|
||||
* @return string The camelized version of the string
|
||||
*/
|
||||
private function camelize($string)
|
||||
{
|
||||
return str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for add and remove methods.
|
||||
*
|
||||
* @param \ReflectionClass $reflClass The reflection class for the given object
|
||||
* @param array $singulars The singular form of the property name or null
|
||||
*
|
||||
* @return array|null An array containing the adder and remover when found, null otherwise
|
||||
*/
|
||||
private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars)
|
||||
{
|
||||
foreach ($singulars as $singular) {
|
||||
$addMethod = 'add'.$singular;
|
||||
$removeMethod = 'remove'.$singular;
|
||||
|
||||
$addMethodFound = $this->isMethodAccessible($reflClass, $addMethod, 1);
|
||||
$removeMethodFound = $this->isMethodAccessible($reflClass, $removeMethod, 1);
|
||||
|
||||
if ($addMethodFound && $removeMethodFound) {
|
||||
return array($addMethod, $removeMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a method is public and has the number of required parameters.
|
||||
*
|
||||
* @param \ReflectionClass $class The class of the method
|
||||
* @param string $methodName The method name
|
||||
* @param int $parameters The number of parameters
|
||||
*
|
||||
* @return bool Whether the method is public and has $parameters required parameters
|
||||
*/
|
||||
private function isMethodAccessible(\ReflectionClass $class, $methodName, $parameters)
|
||||
{
|
||||
if ($class->hasMethod($methodName)) {
|
||||
$method = $class->getMethod($methodName);
|
||||
|
||||
if ($method->isPublic()
|
||||
&& $method->getNumberOfRequiredParameters() <= $parameters
|
||||
&& $method->getNumberOfParameters() >= $parameters) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
102
vendor/symfony/property-access/PropertyAccessorBuilder.php
vendored
Normal file
102
vendor/symfony/property-access/PropertyAccessorBuilder.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* A configurable builder to create a PropertyAccessor.
|
||||
*
|
||||
* @author Jérémie Augustin <jeremie.augustin@pixel-cookers.com>
|
||||
*/
|
||||
class PropertyAccessorBuilder
|
||||
{
|
||||
private $magicCall = false;
|
||||
private $throwExceptionOnInvalidIndex = false;
|
||||
|
||||
/**
|
||||
* Enables the use of "__call" by the PropertyAccessor.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function enableMagicCall()
|
||||
{
|
||||
$this->magicCall = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the use of "__call" by the PropertyAccessor.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function disableMagicCall()
|
||||
{
|
||||
$this->magicCall = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool whether the use of "__call" by the PropertyAccessor is enabled
|
||||
*/
|
||||
public function isMagicCallEnabled()
|
||||
{
|
||||
return $this->magicCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables exceptions when reading a non-existing index.
|
||||
*
|
||||
* This has no influence on writing non-existing indices with PropertyAccessorInterface::setValue()
|
||||
* which are always created on-the-fly.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function enableExceptionOnInvalidIndex()
|
||||
{
|
||||
$this->throwExceptionOnInvalidIndex = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables exceptions when reading a non-existing index.
|
||||
*
|
||||
* Instead, null is returned when calling PropertyAccessorInterface::getValue() on a non-existing index.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function disableExceptionOnInvalidIndex()
|
||||
{
|
||||
$this->throwExceptionOnInvalidIndex = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool whether an exception is thrown or null is returned when reading a non-existing index
|
||||
*/
|
||||
public function isExceptionOnInvalidIndexEnabled()
|
||||
{
|
||||
return $this->throwExceptionOnInvalidIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a new PropertyAccessor object.
|
||||
*
|
||||
* @return PropertyAccessorInterface The built PropertyAccessor
|
||||
*/
|
||||
public function getPropertyAccessor()
|
||||
{
|
||||
return new PropertyAccessor($this->magicCall, $this->throwExceptionOnInvalidIndex);
|
||||
}
|
||||
}
|
||||
114
vendor/symfony/property-access/PropertyAccessorInterface.php
vendored
Normal file
114
vendor/symfony/property-access/PropertyAccessorInterface.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* Writes and reads values to/from an object/array graph.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface PropertyAccessorInterface
|
||||
{
|
||||
/**
|
||||
* Sets the value at the end of the property path of the object graph.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
*
|
||||
* $propertyAccessor = PropertyAccess::createPropertyAccessor();
|
||||
*
|
||||
* echo $propertyAccessor->setValue($object, 'child.name', 'Fabien');
|
||||
* // equals echo $object->getChild()->setName('Fabien');
|
||||
*
|
||||
* This method first tries to find a public setter for each property in the
|
||||
* path. The name of the setter must be the camel-cased property name
|
||||
* prefixed with "set".
|
||||
*
|
||||
* If the setter does not exist, this method tries to find a public
|
||||
* property. The value of the property is then changed.
|
||||
*
|
||||
* If neither is found, an exception is thrown.
|
||||
*
|
||||
* @param object|array $objectOrArray The object or array to modify
|
||||
* @param string|PropertyPathInterface $propertyPath The property path to modify
|
||||
* @param mixed $value The value to set at the end of the property path
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException If the property path is invalid
|
||||
* @throws Exception\AccessException If a property/index does not exist or is not public
|
||||
* @throws Exception\UnexpectedTypeException If a value within the path is neither object nor array
|
||||
*/
|
||||
public function setValue(&$objectOrArray, $propertyPath, $value);
|
||||
|
||||
/**
|
||||
* Returns the value at the end of the property path of the object graph.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
*
|
||||
* $propertyAccessor = PropertyAccess::createPropertyAccessor();
|
||||
*
|
||||
* echo $propertyAccessor->getValue($object, 'child.name);
|
||||
* // equals echo $object->getChild()->getName();
|
||||
*
|
||||
* This method first tries to find a public getter for each property in the
|
||||
* path. The name of the getter must be the camel-cased property name
|
||||
* prefixed with "get", "is", or "has".
|
||||
*
|
||||
* If the getter does not exist, this method tries to find a public
|
||||
* property. The value of the property is then returned.
|
||||
*
|
||||
* If none of them are found, an exception is thrown.
|
||||
*
|
||||
* @param object|array $objectOrArray The object or array to traverse
|
||||
* @param string|PropertyPathInterface $propertyPath The property path to read
|
||||
*
|
||||
* @return mixed The value at the end of the property path
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException If the property path is invalid
|
||||
* @throws Exception\AccessException If a property/index does not exist or is not public
|
||||
* @throws Exception\UnexpectedTypeException If a value within the path is neither object
|
||||
* nor array
|
||||
*/
|
||||
public function getValue($objectOrArray, $propertyPath);
|
||||
|
||||
/**
|
||||
* Returns whether a value can be written at a given property path.
|
||||
*
|
||||
* Whenever this method returns true, {@link setValue()} is guaranteed not
|
||||
* to throw an exception when called with the same arguments.
|
||||
*
|
||||
* @param object|array $objectOrArray The object or array to check
|
||||
* @param string|PropertyPathInterface $propertyPath The property path to check
|
||||
*
|
||||
* @return bool Whether the value can be set
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException If the property path is invalid
|
||||
*/
|
||||
public function isWritable($objectOrArray, $propertyPath);
|
||||
|
||||
/**
|
||||
* Returns whether a property path can be read from an object graph.
|
||||
*
|
||||
* Whenever this method returns true, {@link getValue()} is guaranteed not
|
||||
* to throw an exception when called with the same arguments.
|
||||
*
|
||||
* @param object|array $objectOrArray The object or array to check
|
||||
* @param string|PropertyPathInterface $propertyPath The property path to check
|
||||
*
|
||||
* @return bool Whether the property path can be read
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException If the property path is invalid
|
||||
*/
|
||||
public function isReadable($objectOrArray, $propertyPath);
|
||||
}
|
||||
205
vendor/symfony/property-access/PropertyPath.php
vendored
Normal file
205
vendor/symfony/property-access/PropertyPath.php
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
|
||||
use Symfony\Component\PropertyAccess\Exception\OutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link PropertyPathInterface}.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
||||
{
|
||||
/**
|
||||
* Character used for separating between plural and singular of an element.
|
||||
*/
|
||||
const SINGULAR_SEPARATOR = '|';
|
||||
|
||||
/**
|
||||
* The elements of the property path.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $elements = array();
|
||||
|
||||
/**
|
||||
* The number of elements in the property path.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $length;
|
||||
|
||||
/**
|
||||
* Contains a Boolean for each property in $elements denoting whether this
|
||||
* element is an index. It is a property otherwise.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $isIndex = array();
|
||||
|
||||
/**
|
||||
* String representation of the path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $pathAsString;
|
||||
|
||||
/**
|
||||
* Constructs a property path from a string.
|
||||
*
|
||||
* @param PropertyPath|string $propertyPath The property path as string or instance
|
||||
*
|
||||
* @throws InvalidArgumentException If the given path is not a string
|
||||
* @throws InvalidPropertyPathException If the syntax of the property path is not valid
|
||||
*/
|
||||
public function __construct($propertyPath)
|
||||
{
|
||||
// Can be used as copy constructor
|
||||
if ($propertyPath instanceof self) {
|
||||
/* @var PropertyPath $propertyPath */
|
||||
$this->elements = $propertyPath->elements;
|
||||
$this->length = $propertyPath->length;
|
||||
$this->isIndex = $propertyPath->isIndex;
|
||||
$this->pathAsString = $propertyPath->pathAsString;
|
||||
|
||||
return;
|
||||
}
|
||||
if (!\is_string($propertyPath)) {
|
||||
throw new InvalidArgumentException(sprintf('The property path constructor needs a string or an instance of "Symfony\Component\PropertyAccess\PropertyPath". Got: "%s"', \is_object($propertyPath) ? \get_class($propertyPath) : \gettype($propertyPath)));
|
||||
}
|
||||
|
||||
if ('' === $propertyPath) {
|
||||
throw new InvalidPropertyPathException('The property path should not be empty.');
|
||||
}
|
||||
|
||||
$this->pathAsString = $propertyPath;
|
||||
$position = 0;
|
||||
$remaining = $propertyPath;
|
||||
|
||||
// first element is evaluated differently - no leading dot for properties
|
||||
$pattern = '/^(([^\.\[]++)|\[([^\]]++)\])(.*)/';
|
||||
|
||||
while (preg_match($pattern, $remaining, $matches)) {
|
||||
if ('' !== $matches[2]) {
|
||||
$element = $matches[2];
|
||||
$this->isIndex[] = false;
|
||||
} else {
|
||||
$element = $matches[3];
|
||||
$this->isIndex[] = true;
|
||||
}
|
||||
|
||||
$this->elements[] = $element;
|
||||
|
||||
$position += \strlen($matches[1]);
|
||||
$remaining = $matches[4];
|
||||
$pattern = '/^(\.([^\.|\[]++)|\[([^\]]++)\])(.*)/';
|
||||
}
|
||||
|
||||
if ('' !== $remaining) {
|
||||
throw new InvalidPropertyPathException(sprintf('Could not parse property path "%s". Unexpected token "%s" at position %d', $propertyPath, $remaining[0], $position));
|
||||
}
|
||||
|
||||
$this->length = \count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->pathAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
if ($this->length <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parent = clone $this;
|
||||
|
||||
--$parent->length;
|
||||
$parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '[')));
|
||||
array_pop($parent->elements);
|
||||
array_pop($parent->isIndex);
|
||||
|
||||
return $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new iterator for this path.
|
||||
*
|
||||
* @return PropertyPathIteratorInterface
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new PropertyPathIterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getElement($index)
|
||||
{
|
||||
if (!isset($this->elements[$index])) {
|
||||
throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index));
|
||||
}
|
||||
|
||||
return $this->elements[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isProperty($index)
|
||||
{
|
||||
if (!isset($this->isIndex[$index])) {
|
||||
throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index));
|
||||
}
|
||||
|
||||
return !$this->isIndex[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isIndex($index)
|
||||
{
|
||||
if (!isset($this->isIndex[$index])) {
|
||||
throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index));
|
||||
}
|
||||
|
||||
return $this->isIndex[$index];
|
||||
}
|
||||
}
|
||||
299
vendor/symfony/property-access/PropertyPathBuilder.php
vendored
Normal file
299
vendor/symfony/property-access/PropertyPathBuilder.php
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\OutOfBoundsException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class PropertyPathBuilder
|
||||
{
|
||||
private $elements = array();
|
||||
private $isIndex = array();
|
||||
|
||||
/**
|
||||
* Creates a new property path builder.
|
||||
*
|
||||
* @param PropertyPathInterface|string|null $path The path to initially store
|
||||
* in the builder. Optional.
|
||||
*/
|
||||
public function __construct($path = null)
|
||||
{
|
||||
if (null !== $path) {
|
||||
$this->append($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a (sub-) path to the current path.
|
||||
*
|
||||
* @param PropertyPathInterface|string $path The path to append
|
||||
* @param int $offset The offset where the appended
|
||||
* piece starts in $path
|
||||
* @param int $length The length of the appended piece
|
||||
* If 0, the full path is appended
|
||||
*/
|
||||
public function append($path, $offset = 0, $length = 0)
|
||||
{
|
||||
if (\is_string($path)) {
|
||||
$path = new PropertyPath($path);
|
||||
}
|
||||
|
||||
if (0 === $length) {
|
||||
$end = $path->getLength();
|
||||
} else {
|
||||
$end = $offset + $length;
|
||||
}
|
||||
|
||||
for (; $offset < $end; ++$offset) {
|
||||
$this->elements[] = $path->getElement($offset);
|
||||
$this->isIndex[] = $path->isIndex($offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an index element to the current path.
|
||||
*
|
||||
* @param string $name The name of the appended index
|
||||
*/
|
||||
public function appendIndex($name)
|
||||
{
|
||||
$this->elements[] = $name;
|
||||
$this->isIndex[] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a property element to the current path.
|
||||
*
|
||||
* @param string $name The name of the appended property
|
||||
*/
|
||||
public function appendProperty($name)
|
||||
{
|
||||
$this->elements[] = $name;
|
||||
$this->isIndex[] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes elements from the current path.
|
||||
*
|
||||
* @param int $offset The offset at which to remove
|
||||
* @param int $length The length of the removed piece
|
||||
*
|
||||
* @throws OutOfBoundsException if offset is invalid
|
||||
*/
|
||||
public function remove($offset, $length = 1)
|
||||
{
|
||||
if (!isset($this->elements[$offset])) {
|
||||
throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
|
||||
}
|
||||
|
||||
$this->resize($offset, $length, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a sub-path by a different (sub-) path.
|
||||
*
|
||||
* @param int $offset The offset at which to replace
|
||||
* @param int $length The length of the piece to replace
|
||||
* @param PropertyPathInterface|string $path The path to insert
|
||||
* @param int $pathOffset The offset where the inserted piece
|
||||
* starts in $path
|
||||
* @param int $pathLength The length of the inserted piece
|
||||
* If 0, the full path is inserted
|
||||
*
|
||||
* @throws OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function replace($offset, $length, $path, $pathOffset = 0, $pathLength = 0)
|
||||
{
|
||||
if (\is_string($path)) {
|
||||
$path = new PropertyPath($path);
|
||||
}
|
||||
|
||||
if ($offset < 0 && abs($offset) <= $this->getLength()) {
|
||||
$offset = $this->getLength() + $offset;
|
||||
} elseif (!isset($this->elements[$offset])) {
|
||||
throw new OutOfBoundsException('The offset '.$offset.' is not within the property path');
|
||||
}
|
||||
|
||||
if (0 === $pathLength) {
|
||||
$pathLength = $path->getLength() - $pathOffset;
|
||||
}
|
||||
|
||||
$this->resize($offset, $length, $pathLength);
|
||||
|
||||
for ($i = 0; $i < $pathLength; ++$i) {
|
||||
$this->elements[$offset + $i] = $path->getElement($pathOffset + $i);
|
||||
$this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i);
|
||||
}
|
||||
ksort($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a property element by an index element.
|
||||
*
|
||||
* @param int $offset The offset at which to replace
|
||||
* @param string $name The new name of the element. Optional
|
||||
*
|
||||
* @throws OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function replaceByIndex($offset, $name = null)
|
||||
{
|
||||
if (!isset($this->elements[$offset])) {
|
||||
throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
|
||||
}
|
||||
|
||||
if (null !== $name) {
|
||||
$this->elements[$offset] = $name;
|
||||
}
|
||||
|
||||
$this->isIndex[$offset] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an index element by a property element.
|
||||
*
|
||||
* @param int $offset The offset at which to replace
|
||||
* @param string $name The new name of the element. Optional
|
||||
*
|
||||
* @throws OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function replaceByProperty($offset, $name = null)
|
||||
{
|
||||
if (!isset($this->elements[$offset])) {
|
||||
throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
|
||||
}
|
||||
|
||||
if (null !== $name) {
|
||||
$this->elements[$offset] = $name;
|
||||
}
|
||||
|
||||
$this->isIndex[$offset] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the current path.
|
||||
*
|
||||
* @return int The path length
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return \count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current property path.
|
||||
*
|
||||
* @return PropertyPathInterface The constructed property path
|
||||
*/
|
||||
public function getPropertyPath()
|
||||
{
|
||||
$pathAsString = $this->__toString();
|
||||
|
||||
return '' !== $pathAsString ? new PropertyPath($pathAsString) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current property path as string.
|
||||
*
|
||||
* @return string The property path as string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$string = '';
|
||||
|
||||
foreach ($this->elements as $offset => $element) {
|
||||
if ($this->isIndex[$offset]) {
|
||||
$element = '['.$element.']';
|
||||
} elseif ('' !== $string) {
|
||||
$string .= '.';
|
||||
}
|
||||
|
||||
$string .= $element;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the path so that a chunk of length $cutLength is
|
||||
* removed at $offset and another chunk of length $insertionLength
|
||||
* can be inserted.
|
||||
*
|
||||
* @param int $offset The offset where the removed chunk starts
|
||||
* @param int $cutLength The length of the removed chunk
|
||||
* @param int $insertionLength The length of the inserted chunk
|
||||
*/
|
||||
private function resize($offset, $cutLength, $insertionLength)
|
||||
{
|
||||
// Nothing else to do in this case
|
||||
if ($insertionLength === $cutLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
$length = \count($this->elements);
|
||||
|
||||
if ($cutLength > $insertionLength) {
|
||||
// More elements should be removed than inserted
|
||||
$diff = $cutLength - $insertionLength;
|
||||
$newLength = $length - $diff;
|
||||
|
||||
// Shift elements to the left (left-to-right until the new end)
|
||||
// Max allowed offset to be shifted is such that
|
||||
// $offset + $diff < $length (otherwise invalid index access)
|
||||
// i.e. $offset < $length - $diff = $newLength
|
||||
for ($i = $offset; $i < $newLength; ++$i) {
|
||||
$this->elements[$i] = $this->elements[$i + $diff];
|
||||
$this->isIndex[$i] = $this->isIndex[$i + $diff];
|
||||
}
|
||||
|
||||
// All remaining elements should be removed
|
||||
for (; $i < $length; ++$i) {
|
||||
unset($this->elements[$i], $this->isIndex[$i]);
|
||||
}
|
||||
} else {
|
||||
$diff = $insertionLength - $cutLength;
|
||||
|
||||
$newLength = $length + $diff;
|
||||
$indexAfterInsertion = $offset + $insertionLength;
|
||||
|
||||
// $diff <= $insertionLength
|
||||
// $indexAfterInsertion >= $insertionLength
|
||||
// => $diff <= $indexAfterInsertion
|
||||
|
||||
// In each of the following loops, $i >= $diff must hold,
|
||||
// otherwise ($i - $diff) becomes negative.
|
||||
|
||||
// Shift old elements to the right to make up space for the
|
||||
// inserted elements. This needs to be done left-to-right in
|
||||
// order to preserve an ascending array index order
|
||||
// Since $i = max($length, $indexAfterInsertion) and $indexAfterInsertion >= $diff,
|
||||
// $i >= $diff is guaranteed.
|
||||
for ($i = max($length, $indexAfterInsertion); $i < $newLength; ++$i) {
|
||||
$this->elements[$i] = $this->elements[$i - $diff];
|
||||
$this->isIndex[$i] = $this->isIndex[$i - $diff];
|
||||
}
|
||||
|
||||
// Shift remaining elements to the right. Do this right-to-left
|
||||
// so we don't overwrite elements before copying them
|
||||
// The last written index is the immediate index after the inserted
|
||||
// string, because the indices before that will be overwritten
|
||||
// anyway.
|
||||
// Since $i >= $indexAfterInsertion and $indexAfterInsertion >= $diff,
|
||||
// $i >= $diff is guaranteed.
|
||||
for ($i = $length - 1; $i >= $indexAfterInsertion; --$i) {
|
||||
$this->elements[$i] = $this->elements[$i - $diff];
|
||||
$this->isIndex[$i] = $this->isIndex[$i - $diff];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
vendor/symfony/property-access/PropertyPathInterface.php
vendored
Normal file
86
vendor/symfony/property-access/PropertyPathInterface.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* A sequence of property names or array indices.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface PropertyPathInterface extends \Traversable
|
||||
{
|
||||
/**
|
||||
* Returns the string representation of the property path.
|
||||
*
|
||||
* @return string The path as string
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* Returns the length of the property path, i.e. the number of elements.
|
||||
*
|
||||
* @return int The path length
|
||||
*/
|
||||
public function getLength();
|
||||
|
||||
/**
|
||||
* Returns the parent property path.
|
||||
*
|
||||
* The parent property path is the one that contains the same items as
|
||||
* this one except for the last one.
|
||||
*
|
||||
* If this property path only contains one item, null is returned.
|
||||
*
|
||||
* @return PropertyPath The parent path or null
|
||||
*/
|
||||
public function getParent();
|
||||
|
||||
/**
|
||||
* Returns the elements of the property path as array.
|
||||
*
|
||||
* @return array An array of property/index names
|
||||
*/
|
||||
public function getElements();
|
||||
|
||||
/**
|
||||
* Returns the element at the given index in the property path.
|
||||
*
|
||||
* @param int $index The index key
|
||||
*
|
||||
* @return string A property or index name
|
||||
*
|
||||
* @throws Exception\OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function getElement($index);
|
||||
|
||||
/**
|
||||
* Returns whether the element at the given index is a property.
|
||||
*
|
||||
* @param int $index The index in the property path
|
||||
*
|
||||
* @return bool Whether the element at this index is a property
|
||||
*
|
||||
* @throws Exception\OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function isProperty($index);
|
||||
|
||||
/**
|
||||
* Returns whether the element at the given index is an array index.
|
||||
*
|
||||
* @param int $index The index in the property path
|
||||
*
|
||||
* @return bool Whether the element at this index is an array index
|
||||
*
|
||||
* @throws Exception\OutOfBoundsException If the offset is invalid
|
||||
*/
|
||||
public function isIndex($index);
|
||||
}
|
||||
49
vendor/symfony/property-access/PropertyPathIterator.php
vendored
Normal file
49
vendor/symfony/property-access/PropertyPathIterator.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* Traverses a property path and provides additional methods to find out
|
||||
* information about the current element.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class PropertyPathIterator extends \ArrayIterator implements PropertyPathIteratorInterface
|
||||
{
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @param PropertyPathInterface $path The property path to traverse
|
||||
*/
|
||||
public function __construct(PropertyPathInterface $path)
|
||||
{
|
||||
parent::__construct($path->getElements());
|
||||
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isIndex()
|
||||
{
|
||||
return $this->path->isIndex($this->key());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isProperty()
|
||||
{
|
||||
return $this->path->isProperty($this->key());
|
||||
}
|
||||
}
|
||||
34
vendor/symfony/property-access/PropertyPathIteratorInterface.php
vendored
Normal file
34
vendor/symfony/property-access/PropertyPathIteratorInterface.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface PropertyPathIteratorInterface extends \Iterator, \SeekableIterator
|
||||
{
|
||||
/**
|
||||
* Returns whether the current element in the property path is an array
|
||||
* index.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isIndex();
|
||||
|
||||
/**
|
||||
* Returns whether the current element in the property path is a property
|
||||
* name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isProperty();
|
||||
}
|
||||
14
vendor/symfony/property-access/README.md
vendored
Normal file
14
vendor/symfony/property-access/README.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
PropertyAccess Component
|
||||
========================
|
||||
|
||||
The PropertyAccess component provides function to read and write from/to an
|
||||
object or array using a simple string notation.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/property_access/index.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
226
vendor/symfony/property-access/StringUtil.php
vendored
Normal file
226
vendor/symfony/property-access/StringUtil.php
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
/**
|
||||
* Creates singulars from plurals.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class StringUtil
|
||||
{
|
||||
/**
|
||||
* Map english plural to singular suffixes.
|
||||
*
|
||||
* @see http://english-zone.com/spelling/plurals.html
|
||||
*/
|
||||
private static $pluralMap = array(
|
||||
// First entry: plural suffix, reversed
|
||||
// Second entry: length of plural suffix
|
||||
// Third entry: Whether the suffix may succeed a vocal
|
||||
// Fourth entry: Whether the suffix may succeed a consonant
|
||||
// Fifth entry: singular suffix, normal
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
array('a', 1, true, true, array('on', 'um')),
|
||||
|
||||
// nebulae (nebula)
|
||||
array('ea', 2, true, true, 'a'),
|
||||
|
||||
// services (service)
|
||||
array('secivres', 8, true, true, 'service'),
|
||||
|
||||
// mice (mouse), lice (louse)
|
||||
array('eci', 3, false, true, 'ouse'),
|
||||
|
||||
// geese (goose)
|
||||
array('esee', 4, false, true, 'oose'),
|
||||
|
||||
// fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius)
|
||||
array('i', 1, true, true, 'us'),
|
||||
|
||||
// men (man), women (woman)
|
||||
array('nem', 3, true, true, 'man'),
|
||||
|
||||
// children (child)
|
||||
array('nerdlihc', 8, true, true, 'child'),
|
||||
|
||||
// oxen (ox)
|
||||
array('nexo', 4, false, false, 'ox'),
|
||||
|
||||
// indices (index), appendices (appendix), prices (price)
|
||||
array('seci', 4, false, true, array('ex', 'ix', 'ice')),
|
||||
|
||||
// selfies (selfie)
|
||||
array('seifles', 7, true, true, 'selfie'),
|
||||
|
||||
// movies (movie)
|
||||
array('seivom', 6, true, true, 'movie'),
|
||||
|
||||
// feet (foot)
|
||||
array('teef', 4, true, true, 'foot'),
|
||||
|
||||
// geese (goose)
|
||||
array('eseeg', 5, true, true, 'goose'),
|
||||
|
||||
// teeth (tooth)
|
||||
array('hteet', 5, true, true, 'tooth'),
|
||||
|
||||
// news (news)
|
||||
array('swen', 4, true, true, 'news'),
|
||||
|
||||
// series (series)
|
||||
array('seires', 6, true, true, 'series'),
|
||||
|
||||
// babies (baby)
|
||||
array('sei', 3, false, true, 'y'),
|
||||
|
||||
// accesses (access), addresses (address), kisses (kiss)
|
||||
array('sess', 4, true, false, 'ss'),
|
||||
|
||||
// analyses (analysis), ellipses (ellipsis), funguses (fungus),
|
||||
// neuroses (neurosis), theses (thesis), emphases (emphasis),
|
||||
// oases (oasis), crises (crisis), houses (house), bases (base),
|
||||
// atlases (atlas)
|
||||
array('ses', 3, true, true, array('s', 'se', 'sis')),
|
||||
|
||||
// objectives (objective), alternative (alternatives)
|
||||
array('sevit', 5, true, true, 'tive'),
|
||||
|
||||
// drives (drive)
|
||||
array('sevird', 6, false, true, 'drive'),
|
||||
|
||||
// lives (life), wives (wife)
|
||||
array('sevi', 4, false, true, 'ife'),
|
||||
|
||||
// moves (move)
|
||||
array('sevom', 5, true, true, 'move'),
|
||||
|
||||
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf), caves (cave), staves (staff)
|
||||
array('sev', 3, true, true, array('f', 've', 'ff')),
|
||||
|
||||
// axes (axis), axes (ax), axes (axe)
|
||||
array('sexa', 4, false, false, array('ax', 'axe', 'axis')),
|
||||
|
||||
// indexes (index), matrixes (matrix)
|
||||
array('sex', 3, true, false, 'x'),
|
||||
|
||||
// quizzes (quiz)
|
||||
array('sezz', 4, true, false, 'z'),
|
||||
|
||||
// bureaus (bureau)
|
||||
array('suae', 4, false, true, 'eau'),
|
||||
|
||||
// roses (rose), garages (garage), cassettes (cassette),
|
||||
// waltzes (waltz), heroes (hero), bushes (bush), arches (arch),
|
||||
// shoes (shoe)
|
||||
array('se', 2, true, true, array('', 'e')),
|
||||
|
||||
// tags (tag)
|
||||
array('s', 1, true, true, ''),
|
||||
|
||||
// chateaux (chateau)
|
||||
array('xuae', 4, false, true, 'eau'),
|
||||
|
||||
// people (person)
|
||||
array('elpoep', 6, true, true, 'person'),
|
||||
);
|
||||
|
||||
/**
|
||||
* This class should not be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singular form of a word.
|
||||
*
|
||||
* If the method can't determine the form with certainty, an array of the
|
||||
* possible singulars is returned.
|
||||
*
|
||||
* @param string $plural A word in plural form
|
||||
*
|
||||
* @return string|array The singular form or an array of possible singular
|
||||
* forms
|
||||
*/
|
||||
public static function singularify($plural)
|
||||
{
|
||||
$pluralRev = strrev($plural);
|
||||
$lowerPluralRev = strtolower($pluralRev);
|
||||
$pluralLength = \strlen($lowerPluralRev);
|
||||
|
||||
// The outer loop iterates over the entries of the plural table
|
||||
// The inner loop $j iterates over the characters of the plural suffix
|
||||
// in the plural table to compare them with the characters of the actual
|
||||
// given plural suffix
|
||||
foreach (self::$pluralMap as $map) {
|
||||
$suffix = $map[0];
|
||||
$suffixLength = $map[1];
|
||||
$j = 0;
|
||||
|
||||
// Compare characters in the plural table and of the suffix of the
|
||||
// given plural one by one
|
||||
while ($suffix[$j] === $lowerPluralRev[$j]) {
|
||||
// Let $j point to the next character
|
||||
++$j;
|
||||
|
||||
// Successfully compared the last character
|
||||
// Add an entry with the singular suffix to the singular array
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $pluralLength) {
|
||||
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
||||
|
||||
if (!$map[2] && $nextIsVocal) {
|
||||
// suffix may not succeed a vocal but next char is one
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$map[3] && !$nextIsVocal) {
|
||||
// suffix may not succeed a consonant but next char is one
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
|
||||
$newSuffix = $map[4];
|
||||
|
||||
// Check whether the first character in the plural suffix
|
||||
// is uppercased. If yes, uppercase the first character in
|
||||
// the singular suffix too
|
||||
$firstUpper = ctype_upper($pluralRev[$j - 1]);
|
||||
|
||||
if (\is_array($newSuffix)) {
|
||||
$singulars = array();
|
||||
|
||||
foreach ($newSuffix as $newSuffixEntry) {
|
||||
$singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
|
||||
}
|
||||
|
||||
return $singulars;
|
||||
}
|
||||
|
||||
return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix);
|
||||
}
|
||||
|
||||
// Suffix is longer than word
|
||||
if ($j === $pluralLength) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assume that plural and singular is identical
|
||||
return $plural;
|
||||
}
|
||||
}
|
||||
65
vendor/symfony/property-access/Tests/Fixtures/NonTraversableArrayObject.php
vendored
Normal file
65
vendor/symfony/property-access/Tests/Fixtures/NonTraversableArrayObject.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* This class is a hand written simplified version of PHP native `ArrayObject`
|
||||
* class, to show that it behaves differently than the PHP native implementation.
|
||||
*/
|
||||
class NonTraversableArrayObject implements \ArrayAccess, \Countable, \Serializable
|
||||
{
|
||||
private $array;
|
||||
|
||||
public function __construct(array $array = null)
|
||||
{
|
||||
$this->array = $array ?: array();
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->array);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->array[$offset];
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (null === $offset) {
|
||||
$this->array[] = $value;
|
||||
} else {
|
||||
$this->array[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->array[$offset]);
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return \count($this->array);
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->array);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->array = (array) unserialize((string) $serialized);
|
||||
}
|
||||
}
|
||||
36
vendor/symfony/property-access/Tests/Fixtures/ReturnTyped.php
vendored
Normal file
36
vendor/symfony/property-access/Tests/Fixtures/ReturnTyped.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ReturnTyped
|
||||
{
|
||||
public function getFoos(): array
|
||||
{
|
||||
return 'It doesn\'t respect the return type on purpose';
|
||||
}
|
||||
|
||||
public function addFoo(\DateTime $dateTime)
|
||||
{
|
||||
}
|
||||
|
||||
public function removeFoo(\DateTime $dateTime)
|
||||
{
|
||||
}
|
||||
|
||||
public function setName($name): self
|
||||
{
|
||||
return 'This does not respect the return type on purpose.';
|
||||
}
|
||||
}
|
||||
176
vendor/symfony/property-access/Tests/Fixtures/TestClass.php
vendored
Normal file
176
vendor/symfony/property-access/Tests/Fixtures/TestClass.php
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public $publicProperty;
|
||||
protected $protectedProperty;
|
||||
private $privateProperty;
|
||||
|
||||
private $publicAccessor;
|
||||
private $publicMethodAccessor;
|
||||
private $publicGetSetter;
|
||||
private $publicAccessorWithDefaultValue;
|
||||
private $publicAccessorWithRequiredAndDefaultValue;
|
||||
private $publicAccessorWithMoreRequiredParameters;
|
||||
private $publicIsAccessor;
|
||||
private $publicHasAccessor;
|
||||
private $publicGetter;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->publicProperty = $value;
|
||||
$this->publicAccessor = $value;
|
||||
$this->publicMethodAccessor = $value;
|
||||
$this->publicGetSetter = $value;
|
||||
$this->publicAccessorWithDefaultValue = $value;
|
||||
$this->publicAccessorWithRequiredAndDefaultValue = $value;
|
||||
$this->publicAccessorWithMoreRequiredParameters = $value;
|
||||
$this->publicIsAccessor = $value;
|
||||
$this->publicHasAccessor = $value;
|
||||
$this->publicGetter = $value;
|
||||
}
|
||||
|
||||
public function setPublicAccessor($value)
|
||||
{
|
||||
$this->publicAccessor = $value;
|
||||
}
|
||||
|
||||
public function setPublicAccessorWithDefaultValue($value = null)
|
||||
{
|
||||
$this->publicAccessorWithDefaultValue = $value;
|
||||
}
|
||||
|
||||
public function setPublicAccessorWithRequiredAndDefaultValue($value, $optional = null)
|
||||
{
|
||||
$this->publicAccessorWithRequiredAndDefaultValue = $value;
|
||||
}
|
||||
|
||||
public function setPublicAccessorWithMoreRequiredParameters($value, $needed)
|
||||
{
|
||||
$this->publicAccessorWithMoreRequiredParameters = $value;
|
||||
}
|
||||
|
||||
public function getPublicAccessor()
|
||||
{
|
||||
return $this->publicAccessor;
|
||||
}
|
||||
|
||||
public function getPublicAccessorWithDefaultValue()
|
||||
{
|
||||
return $this->publicAccessorWithDefaultValue;
|
||||
}
|
||||
|
||||
public function getPublicAccessorWithRequiredAndDefaultValue()
|
||||
{
|
||||
return $this->publicAccessorWithRequiredAndDefaultValue;
|
||||
}
|
||||
|
||||
public function getPublicAccessorWithMoreRequiredParameters()
|
||||
{
|
||||
return $this->publicAccessorWithMoreRequiredParameters;
|
||||
}
|
||||
|
||||
public function setPublicIsAccessor($value)
|
||||
{
|
||||
$this->publicIsAccessor = $value;
|
||||
}
|
||||
|
||||
public function isPublicIsAccessor()
|
||||
{
|
||||
return $this->publicIsAccessor;
|
||||
}
|
||||
|
||||
public function setPublicHasAccessor($value)
|
||||
{
|
||||
$this->publicHasAccessor = $value;
|
||||
}
|
||||
|
||||
public function hasPublicHasAccessor()
|
||||
{
|
||||
return $this->publicHasAccessor;
|
||||
}
|
||||
|
||||
public function publicGetSetter($value = null)
|
||||
{
|
||||
if (null !== $value) {
|
||||
$this->publicGetSetter = $value;
|
||||
}
|
||||
|
||||
return $this->publicGetSetter;
|
||||
}
|
||||
|
||||
public function getPublicMethodMutator()
|
||||
{
|
||||
return $this->publicGetSetter;
|
||||
}
|
||||
|
||||
protected function setProtectedAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
protected function getProtectedAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
protected function setProtectedIsAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
protected function isProtectedIsAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
protected function setProtectedHasAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
protected function hasProtectedHasAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
private function setPrivateAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
private function getPrivateAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
private function setPrivateIsAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
private function isPrivateIsAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
private function setPrivateHasAccessor($value)
|
||||
{
|
||||
}
|
||||
|
||||
private function hasPrivateHasAccessor()
|
||||
{
|
||||
return 'foobar';
|
||||
}
|
||||
|
||||
public function getPublicGetter()
|
||||
{
|
||||
return $this->publicGetter;
|
||||
}
|
||||
}
|
||||
27
vendor/symfony/property-access/Tests/Fixtures/TestClassIsWritable.php
vendored
Normal file
27
vendor/symfony/property-access/Tests/Fixtures/TestClassIsWritable.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class TestClassIsWritable
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
37
vendor/symfony/property-access/Tests/Fixtures/TestClassMagicCall.php
vendored
Normal file
37
vendor/symfony/property-access/Tests/Fixtures/TestClassMagicCall.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class TestClassMagicCall
|
||||
{
|
||||
private $magicCallProperty;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->magicCallProperty = $value;
|
||||
}
|
||||
|
||||
public function __call($method, array $args)
|
||||
{
|
||||
if ('getMagicCallProperty' === $method) {
|
||||
return $this->magicCallProperty;
|
||||
}
|
||||
|
||||
if ('getConstantMagicCallProperty' === $method) {
|
||||
return 'constant value';
|
||||
}
|
||||
|
||||
if ('setMagicCallProperty' === $method) {
|
||||
$this->magicCallProperty = reset($args);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
vendor/symfony/property-access/Tests/Fixtures/TestClassMagicGet.php
vendored
Normal file
42
vendor/symfony/property-access/Tests/Fixtures/TestClassMagicGet.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class TestClassMagicGet
|
||||
{
|
||||
private $magicProperty;
|
||||
|
||||
public $publicProperty;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->magicProperty = $value;
|
||||
}
|
||||
|
||||
public function __set($property, $value)
|
||||
{
|
||||
if ('magicProperty' === $property) {
|
||||
$this->magicProperty = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($property)
|
||||
{
|
||||
if ('magicProperty' === $property) {
|
||||
return $this->magicProperty;
|
||||
}
|
||||
|
||||
if ('constantMagicProperty' === $property) {
|
||||
return 'constant value';
|
||||
}
|
||||
}
|
||||
}
|
||||
32
vendor/symfony/property-access/Tests/Fixtures/TestClassSetValue.php
vendored
Normal file
32
vendor/symfony/property-access/Tests/Fixtures/TestClassSetValue.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class TestClassSetValue
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/property-access/Tests/Fixtures/Ticket5775Object.php
vendored
Normal file
31
vendor/symfony/property-access/Tests/Fixtures/Ticket5775Object.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
class Ticket5775Object
|
||||
{
|
||||
private $property;
|
||||
|
||||
public function getProperty()
|
||||
{
|
||||
return $this->property;
|
||||
}
|
||||
|
||||
private function setProperty()
|
||||
{
|
||||
}
|
||||
|
||||
public function __set($property, $value)
|
||||
{
|
||||
$this->$property = $value;
|
||||
}
|
||||
}
|
||||
70
vendor/symfony/property-access/Tests/Fixtures/TraversableArrayObject.php
vendored
Normal file
70
vendor/symfony/property-access/Tests/Fixtures/TraversableArrayObject.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* This class is a hand written simplified version of PHP native `ArrayObject`
|
||||
* class, to show that it behaves differently than the PHP native implementation.
|
||||
*/
|
||||
class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
|
||||
{
|
||||
private $array;
|
||||
|
||||
public function __construct(array $array = null)
|
||||
{
|
||||
$this->array = $array ?: array();
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->array);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->array[$offset];
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (null === $offset) {
|
||||
$this->array[] = $value;
|
||||
} else {
|
||||
$this->array[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->array[$offset]);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator($this->array);
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return \count($this->array);
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->array);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->array = (array) unserialize((string) $serialized);
|
||||
}
|
||||
}
|
||||
51
vendor/symfony/property-access/Tests/Fixtures/TypeHinted.php
vendored
Normal file
51
vendor/symfony/property-access/Tests/Fixtures/TypeHinted.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class TypeHinted
|
||||
{
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* @var \Countable
|
||||
*/
|
||||
private $countable;
|
||||
|
||||
public function setDate(\DateTime $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Countable
|
||||
*/
|
||||
public function getCountable()
|
||||
{
|
||||
return $this->countable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Countable $countable
|
||||
*/
|
||||
public function setCountable(\Countable $countable)
|
||||
{
|
||||
$this->countable = $countable;
|
||||
}
|
||||
}
|
||||
87
vendor/symfony/property-access/Tests/PropertyAccessorArrayAccessTest.php
vendored
Normal file
87
vendor/symfony/property-access/Tests/PropertyAccessorArrayAccessTest.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||
|
||||
abstract class PropertyAccessorArrayAccessTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PropertyAccessor
|
||||
*/
|
||||
protected $propertyAccessor;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor();
|
||||
}
|
||||
|
||||
abstract protected function getContainer(array $array);
|
||||
|
||||
public function getValidPropertyPaths()
|
||||
{
|
||||
return array(
|
||||
array($this->getContainer(array('firstName' => 'Bernhard')), '[firstName]', 'Bernhard'),
|
||||
array($this->getContainer(array('person' => $this->getContainer(array('firstName' => 'Bernhard')))), '[person][firstName]', 'Bernhard'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testGetValue($collection, $path, $value)
|
||||
{
|
||||
$this->assertSame($value, $this->propertyAccessor->getValue($collection, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
|
||||
*/
|
||||
public function testGetValueFailsIfNoSuchIndex()
|
||||
{
|
||||
$this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
|
||||
->enableExceptionOnInvalidIndex()
|
||||
->getPropertyAccessor();
|
||||
|
||||
$object = $this->getContainer(array('firstName' => 'Bernhard'));
|
||||
|
||||
$this->propertyAccessor->getValue($object, '[lastName]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testSetValue($collection, $path)
|
||||
{
|
||||
$this->propertyAccessor->setValue($collection, $path, 'Updated');
|
||||
|
||||
$this->assertSame('Updated', $this->propertyAccessor->getValue($collection, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testIsReadable($collection, $path)
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isReadable($collection, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testIsWritable($collection, $path)
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path));
|
||||
}
|
||||
}
|
||||
20
vendor/symfony/property-access/Tests/PropertyAccessorArrayObjectTest.php
vendored
Normal file
20
vendor/symfony/property-access/Tests/PropertyAccessorArrayObjectTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
class PropertyAccessorArrayObjectTest extends PropertyAccessorCollectionTest
|
||||
{
|
||||
protected function getContainer(array $array)
|
||||
{
|
||||
return new \ArrayObject($array);
|
||||
}
|
||||
}
|
||||
20
vendor/symfony/property-access/Tests/PropertyAccessorArrayTest.php
vendored
Normal file
20
vendor/symfony/property-access/Tests/PropertyAccessorArrayTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
class PropertyAccessorArrayTest extends PropertyAccessorCollectionTest
|
||||
{
|
||||
protected function getContainer(array $array)
|
||||
{
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
56
vendor/symfony/property-access/Tests/PropertyAccessorBuilderTest.php
vendored
Normal file
56
vendor/symfony/property-access/Tests/PropertyAccessorBuilderTest.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
|
||||
|
||||
class PropertyAccessorBuilderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PropertyAccessorBuilder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->builder = new PropertyAccessorBuilder();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->builder = null;
|
||||
}
|
||||
|
||||
public function testEnableMagicCall()
|
||||
{
|
||||
$this->assertSame($this->builder, $this->builder->enableMagicCall());
|
||||
}
|
||||
|
||||
public function testDisableMagicCall()
|
||||
{
|
||||
$this->assertSame($this->builder, $this->builder->disableMagicCall());
|
||||
}
|
||||
|
||||
public function testIsMagicCallEnable()
|
||||
{
|
||||
$this->assertFalse($this->builder->isMagicCallEnabled());
|
||||
$this->assertTrue($this->builder->enableMagicCall()->isMagicCallEnabled());
|
||||
$this->assertFalse($this->builder->disableMagicCall()->isMagicCallEnabled());
|
||||
}
|
||||
|
||||
public function testGetPropertyAccessor()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\PropertyAccess\PropertyAccessor', $this->builder->getPropertyAccessor());
|
||||
$this->assertInstanceOf('Symfony\Component\PropertyAccess\PropertyAccessor', $this->builder->enableMagicCall()->getPropertyAccessor());
|
||||
}
|
||||
}
|
||||
200
vendor/symfony/property-access/Tests/PropertyAccessorCollectionTest.php
vendored
Normal file
200
vendor/symfony/property-access/Tests/PropertyAccessorCollectionTest.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
class PropertyAccessorCollectionTest_Car
|
||||
{
|
||||
private $axes;
|
||||
|
||||
public function __construct($axes = null)
|
||||
{
|
||||
$this->axes = $axes;
|
||||
}
|
||||
|
||||
// In the test, use a name that StringUtil can't uniquely singularify
|
||||
public function addAxis($axis)
|
||||
{
|
||||
$this->axes[] = $axis;
|
||||
}
|
||||
|
||||
public function removeAxis($axis)
|
||||
{
|
||||
foreach ($this->axes as $key => $value) {
|
||||
if ($value === $axis) {
|
||||
unset($this->axes[$key]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAxes()
|
||||
{
|
||||
return $this->axes;
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyAccessorCollectionTest_CarOnlyAdder
|
||||
{
|
||||
public function addAxis($axis)
|
||||
{
|
||||
}
|
||||
|
||||
public function getAxes()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyAccessorCollectionTest_CarOnlyRemover
|
||||
{
|
||||
public function removeAxis($axis)
|
||||
{
|
||||
}
|
||||
|
||||
public function getAxes()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyAccessorCollectionTest_CarNoAdderAndRemover
|
||||
{
|
||||
public function getAxes()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyAccessorCollectionTest_CompositeCar
|
||||
{
|
||||
public function getStructure()
|
||||
{
|
||||
}
|
||||
|
||||
public function setStructure($structure)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyAccessorCollectionTest_CarStructure
|
||||
{
|
||||
public function addAxis($axis)
|
||||
{
|
||||
}
|
||||
|
||||
public function removeAxis($axis)
|
||||
{
|
||||
}
|
||||
|
||||
public function getAxes()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAccessTest
|
||||
{
|
||||
public function testSetValueCallsAdderAndRemoverForCollections()
|
||||
{
|
||||
$axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth', 4 => 'fifth'));
|
||||
$axesMerged = $this->getContainer(array(1 => 'first', 2 => 'second', 3 => 'third'));
|
||||
$axesAfter = $this->getContainer(array(1 => 'second', 5 => 'first', 6 => 'third'));
|
||||
$axesMergedCopy = \is_object($axesMerged) ? clone $axesMerged : $axesMerged;
|
||||
|
||||
// Don't use a mock in order to test whether the collections are
|
||||
// modified while iterating them
|
||||
$car = new PropertyAccessorCollectionTest_Car($axesBefore);
|
||||
|
||||
$this->propertyAccessor->setValue($car, 'axes', $axesMerged);
|
||||
|
||||
$this->assertEquals($axesAfter, $car->getAxes());
|
||||
|
||||
// The passed collection was not modified
|
||||
$this->assertEquals($axesMergedCopy, $axesMerged);
|
||||
}
|
||||
|
||||
public function testSetValueCallsAdderAndRemoverForNestedCollections()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CompositeCar')->getMock();
|
||||
$structure = $this->getMockBuilder(__CLASS__.'_CarStructure')->getMock();
|
||||
$axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth'));
|
||||
$axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third'));
|
||||
|
||||
$car->expects($this->any())
|
||||
->method('getStructure')
|
||||
->will($this->returnValue($structure));
|
||||
|
||||
$structure->expects($this->at(0))
|
||||
->method('getAxes')
|
||||
->will($this->returnValue($axesBefore));
|
||||
$structure->expects($this->at(1))
|
||||
->method('removeAxis')
|
||||
->with('fourth');
|
||||
$structure->expects($this->at(2))
|
||||
->method('addAxis')
|
||||
->with('first');
|
||||
$structure->expects($this->at(3))
|
||||
->method('addAxis')
|
||||
->with('third');
|
||||
|
||||
$this->propertyAccessor->setValue($car, 'structure.axes', $axesAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
* @expectedExceptionMessage Neither the property "axes" nor one of the methods "addAx()"/"removeAx()", "addAxe()"/"removeAxe()", "addAxis()"/"removeAxis()", "setAxes()", "axes()", "__set()" or "__call()" exist and have public access in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover
|
||||
*/
|
||||
public function testSetValueFailsIfNoAdderNorRemoverFound()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
|
||||
$axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth'));
|
||||
$axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third'));
|
||||
|
||||
$car->expects($this->any())
|
||||
->method('getAxes')
|
||||
->will($this->returnValue($axesBefore));
|
||||
|
||||
$this->propertyAccessor->setValue($car, 'axes', $axesAfter);
|
||||
}
|
||||
|
||||
public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
|
||||
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
|
||||
}
|
||||
|
||||
public function testIsWritableReturnsFalseIfOnlyAdderExists()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CarOnlyAdder')->getMock();
|
||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||
}
|
||||
|
||||
public function testIsWritableReturnsFalseIfOnlyRemoverExists()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CarOnlyRemover')->getMock();
|
||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||
}
|
||||
|
||||
public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
|
||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
* expectedExceptionMessageRegExp /The property "axes" in class "Mock_PropertyAccessorCollectionTest_Car[^"]*" can be defined with the methods "addAxis()", "removeAxis()" but the new value must be an array or an instance of \Traversable, "string" given./
|
||||
*/
|
||||
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
|
||||
{
|
||||
$car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
|
||||
|
||||
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');
|
||||
}
|
||||
}
|
||||
22
vendor/symfony/property-access/Tests/PropertyAccessorNonTraversableArrayObjectTest.php
vendored
Normal file
22
vendor/symfony/property-access/Tests/PropertyAccessorNonTraversableArrayObjectTest.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\NonTraversableArrayObject;
|
||||
|
||||
class PropertyAccessorNonTraversableArrayObjectTest extends PropertyAccessorArrayAccessTest
|
||||
{
|
||||
protected function getContainer(array $array)
|
||||
{
|
||||
return new NonTraversableArrayObject($array);
|
||||
}
|
||||
}
|
||||
605
vendor/symfony/property-access/Tests/PropertyAccessorTest.php
vendored
Normal file
605
vendor/symfony/property-access/Tests/PropertyAccessorTest.php
vendored
Normal file
@@ -0,0 +1,605 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\ReturnTyped;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassIsWritable;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicGet;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassSetValue;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\Ticket5775Object;
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TypeHinted;
|
||||
|
||||
class PropertyAccessorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PropertyAccessor
|
||||
*/
|
||||
private $propertyAccessor;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor();
|
||||
}
|
||||
|
||||
public function getPathsWithUnexpectedType()
|
||||
{
|
||||
return array(
|
||||
array('', 'foobar'),
|
||||
array('foo', 'foobar'),
|
||||
array(null, 'foobar'),
|
||||
array(123, 'foobar'),
|
||||
array((object) array('prop' => null), 'prop.foobar'),
|
||||
array((object) array('prop' => (object) array('subProp' => null)), 'prop.subProp.foobar'),
|
||||
array(array('index' => null), '[index][foobar]'),
|
||||
array(array('index' => array('subIndex' => null)), '[index][subIndex][foobar]'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getPathsWithMissingProperty()
|
||||
{
|
||||
return array(
|
||||
array((object) array('firstName' => 'Bernhard'), 'lastName'),
|
||||
array((object) array('property' => (object) array('firstName' => 'Bernhard')), 'property.lastName'),
|
||||
array(array('index' => (object) array('firstName' => 'Bernhard')), '[index].lastName'),
|
||||
array(new TestClass('Bernhard'), 'protectedProperty'),
|
||||
array(new TestClass('Bernhard'), 'privateProperty'),
|
||||
array(new TestClass('Bernhard'), 'protectedAccessor'),
|
||||
array(new TestClass('Bernhard'), 'protectedIsAccessor'),
|
||||
array(new TestClass('Bernhard'), 'protectedHasAccessor'),
|
||||
array(new TestClass('Bernhard'), 'privateAccessor'),
|
||||
array(new TestClass('Bernhard'), 'privateIsAccessor'),
|
||||
array(new TestClass('Bernhard'), 'privateHasAccessor'),
|
||||
|
||||
// Properties are not camelized
|
||||
array(new TestClass('Bernhard'), 'public_property'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getPathsWithMissingIndex()
|
||||
{
|
||||
return array(
|
||||
array(array('firstName' => 'Bernhard'), '[lastName]'),
|
||||
array(array(), '[index][lastName]'),
|
||||
array(array('index' => array()), '[index][lastName]'),
|
||||
array(array('index' => array('firstName' => 'Bernhard')), '[index][lastName]'),
|
||||
array((object) array('property' => array('firstName' => 'Bernhard')), 'property[lastName]'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testGetValue($objectOrArray, $path, $value)
|
||||
{
|
||||
$this->assertSame($value, $this->propertyAccessor->getValue($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingProperty
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
*/
|
||||
public function testGetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->getValue($objectOrArray, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testGetValueThrowsNoExceptionIfIndexNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->assertNull($this->propertyAccessor->getValue($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
|
||||
*/
|
||||
public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(false, true);
|
||||
$this->propertyAccessor->getValue($objectOrArray, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
|
||||
*/
|
||||
public function testGetValueThrowsExceptionIfNotArrayAccess()
|
||||
{
|
||||
$this->propertyAccessor->getValue(new \stdClass(), '[index]');
|
||||
}
|
||||
|
||||
public function testGetValueReadsMagicGet()
|
||||
{
|
||||
$this->assertSame('Bernhard', $this->propertyAccessor->getValue(new TestClassMagicGet('Bernhard'), 'magicProperty'));
|
||||
}
|
||||
|
||||
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
|
||||
{
|
||||
$object = new \ArrayObject();
|
||||
$array = array('child' => array('index' => $object));
|
||||
|
||||
$this->assertNull($this->propertyAccessor->getValue($array, '[child][index][foo][bar]'));
|
||||
$this->assertSame(array(), $object->getArrayCopy());
|
||||
}
|
||||
|
||||
// https://github.com/symfony/symfony/pull/4450
|
||||
public function testGetValueReadsMagicGetThatReturnsConstant()
|
||||
{
|
||||
$this->assertSame('constant value', $this->propertyAccessor->getValue(new TestClassMagicGet('Bernhard'), 'constantMagicProperty'));
|
||||
}
|
||||
|
||||
public function testGetValueNotModifyObject()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$object->firstName = array('Bernhard');
|
||||
|
||||
$this->assertNull($this->propertyAccessor->getValue($object, 'firstName[1]'));
|
||||
$this->assertSame(array('Bernhard'), $object->firstName);
|
||||
}
|
||||
|
||||
public function testGetValueNotModifyObjectException()
|
||||
{
|
||||
$propertyAccessor = new PropertyAccessor(false, true);
|
||||
$object = new \stdClass();
|
||||
$object->firstName = array('Bernhard');
|
||||
|
||||
try {
|
||||
$propertyAccessor->getValue($object, 'firstName[1]');
|
||||
} catch (NoSuchIndexException $e) {
|
||||
}
|
||||
|
||||
$this->assertSame(array('Bernhard'), $object->firstName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
*/
|
||||
public function testGetValueDoesNotReadMagicCallByDefault()
|
||||
{
|
||||
$this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty');
|
||||
}
|
||||
|
||||
public function testGetValueReadsMagicCallIfEnabled()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(true);
|
||||
|
||||
$this->assertSame('Bernhard', $this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
|
||||
}
|
||||
|
||||
// https://github.com/symfony/symfony/pull/4450
|
||||
public function testGetValueReadsMagicCallThatReturnsConstant()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(true);
|
||||
|
||||
$this->assertSame('constant value', $this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'constantMagicCallProperty'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithUnexpectedType
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException
|
||||
* @expectedExceptionMessage PropertyAccessor requires a graph of objects or arrays to operate on
|
||||
*/
|
||||
public function testGetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->getValue($objectOrArray, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testSetValue($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
|
||||
|
||||
$this->assertSame('Updated', $this->propertyAccessor->getValue($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingProperty
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
*/
|
||||
public function testSetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testSetValueThrowsNoExceptionIfIndexNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
|
||||
|
||||
$this->assertSame('Updated', $this->propertyAccessor->getValue($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testSetValueThrowsNoExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(false, true);
|
||||
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
|
||||
|
||||
$this->assertSame('Updated', $this->propertyAccessor->getValue($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
|
||||
*/
|
||||
public function testSetValueThrowsExceptionIfNotArrayAccess()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
|
||||
$this->propertyAccessor->setValue($object, '[index]', 'Updated');
|
||||
}
|
||||
|
||||
public function testSetValueUpdatesMagicSet()
|
||||
{
|
||||
$author = new TestClassMagicGet('Bernhard');
|
||||
|
||||
$this->propertyAccessor->setValue($author, 'magicProperty', 'Updated');
|
||||
|
||||
$this->assertEquals('Updated', $author->__get('magicProperty'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
*/
|
||||
public function testSetValueThrowsExceptionIfThereAreMissingParameters()
|
||||
{
|
||||
$object = new TestClass('Bernhard');
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'publicAccessorWithMoreRequiredParameters', 'Updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
|
||||
*/
|
||||
public function testSetValueDoesNotUpdateMagicCallByDefault()
|
||||
{
|
||||
$author = new TestClassMagicCall('Bernhard');
|
||||
|
||||
$this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated');
|
||||
}
|
||||
|
||||
public function testSetValueUpdatesMagicCallIfEnabled()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(true);
|
||||
|
||||
$author = new TestClassMagicCall('Bernhard');
|
||||
|
||||
$this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated');
|
||||
|
||||
$this->assertEquals('Updated', $author->__call('getMagicCallProperty', array()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithUnexpectedType
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException
|
||||
* @expectedExceptionMessage PropertyAccessor requires a graph of objects or arrays to operate on
|
||||
*/
|
||||
public function testSetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor->setValue($objectOrArray, $path, 'value');
|
||||
}
|
||||
|
||||
public function testGetValueWhenArrayValueIsNull()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(false, true);
|
||||
$this->assertNull($this->propertyAccessor->getValue(array('index' => array('nullable' => null)), '[index][nullable]'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testIsReadable($objectOrArray, $path)
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isReadable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingProperty
|
||||
*/
|
||||
public function testIsReadableReturnsFalseIfPropertyNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isReadable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testIsReadableReturnsTrueIfIndexNotFound($objectOrArray, $path)
|
||||
{
|
||||
// Non-existing indices can be read. In this case, null is returned
|
||||
$this->assertTrue($this->propertyAccessor->isReadable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testIsReadableReturnsFalseIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(false, true);
|
||||
|
||||
// When exceptions are enabled, non-existing indices cannot be read
|
||||
$this->assertFalse($this->propertyAccessor->isReadable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
public function testIsReadableRecognizesMagicGet()
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isReadable(new TestClassMagicGet('Bernhard'), 'magicProperty'));
|
||||
}
|
||||
|
||||
public function testIsReadableDoesNotRecognizeMagicCallByDefault()
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isReadable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
|
||||
}
|
||||
|
||||
public function testIsReadableRecognizesMagicCallIfEnabled()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(true);
|
||||
|
||||
$this->assertTrue($this->propertyAccessor->isReadable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithUnexpectedType
|
||||
*/
|
||||
public function testIsReadableReturnsFalseIfNotObjectOrArray($objectOrArray, $path)
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isReadable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidPropertyPaths
|
||||
*/
|
||||
public function testIsWritable($objectOrArray, $path)
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isWritable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingProperty
|
||||
*/
|
||||
public function testIsWritableReturnsFalseIfPropertyNotFound($objectOrArray, $path)
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isWritable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testIsWritableReturnsTrueIfIndexNotFound($objectOrArray, $path)
|
||||
{
|
||||
// Non-existing indices can be written. Arrays are created on-demand.
|
||||
$this->assertTrue($this->propertyAccessor->isWritable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithMissingIndex
|
||||
*/
|
||||
public function testIsWritableReturnsTrueIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(false, true);
|
||||
|
||||
// Non-existing indices can be written even if exceptions are enabled
|
||||
$this->assertTrue($this->propertyAccessor->isWritable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
public function testIsWritableRecognizesMagicSet()
|
||||
{
|
||||
$this->assertTrue($this->propertyAccessor->isWritable(new TestClassMagicGet('Bernhard'), 'magicProperty'));
|
||||
}
|
||||
|
||||
public function testIsWritableDoesNotRecognizeMagicCallByDefault()
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isWritable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
|
||||
}
|
||||
|
||||
public function testIsWritableRecognizesMagicCallIfEnabled()
|
||||
{
|
||||
$this->propertyAccessor = new PropertyAccessor(true);
|
||||
|
||||
$this->assertTrue($this->propertyAccessor->isWritable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPathsWithUnexpectedType
|
||||
*/
|
||||
public function testIsWritableReturnsFalseIfNotObjectOrArray($objectOrArray, $path)
|
||||
{
|
||||
$this->assertFalse($this->propertyAccessor->isWritable($objectOrArray, $path));
|
||||
}
|
||||
|
||||
public function getValidPropertyPaths()
|
||||
{
|
||||
return array(
|
||||
array(array('Bernhard', 'Schussek'), '[0]', 'Bernhard'),
|
||||
array(array('Bernhard', 'Schussek'), '[1]', 'Schussek'),
|
||||
array(array('firstName' => 'Bernhard'), '[firstName]', 'Bernhard'),
|
||||
array(array('index' => array('firstName' => 'Bernhard')), '[index][firstName]', 'Bernhard'),
|
||||
array((object) array('firstName' => 'Bernhard'), 'firstName', 'Bernhard'),
|
||||
array((object) array('property' => array('firstName' => 'Bernhard')), 'property[firstName]', 'Bernhard'),
|
||||
array(array('index' => (object) array('firstName' => 'Bernhard')), '[index].firstName', 'Bernhard'),
|
||||
array((object) array('property' => (object) array('firstName' => 'Bernhard')), 'property.firstName', 'Bernhard'),
|
||||
|
||||
// Accessor methods
|
||||
array(new TestClass('Bernhard'), 'publicProperty', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicAccessor', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicAccessorWithDefaultValue', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicAccessorWithRequiredAndDefaultValue', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicIsAccessor', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicHasAccessor', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), 'publicGetSetter', 'Bernhard'),
|
||||
|
||||
// Methods are camelized
|
||||
array(new TestClass('Bernhard'), 'public_accessor', 'Bernhard'),
|
||||
array(new TestClass('Bernhard'), '_public_accessor', 'Bernhard'),
|
||||
|
||||
// Missing indices
|
||||
array(array('index' => array()), '[index][firstName]', null),
|
||||
array(array('root' => array('index' => array())), '[root][index][firstName]', null),
|
||||
|
||||
// Special chars
|
||||
array(array('%!@$§.' => 'Bernhard'), '[%!@$§.]', 'Bernhard'),
|
||||
array(array('index' => array('%!@$§.' => 'Bernhard')), '[index][%!@$§.]', 'Bernhard'),
|
||||
array((object) array('%!@$§' => 'Bernhard'), '%!@$§', 'Bernhard'),
|
||||
array((object) array('property' => (object) array('%!@$§' => 'Bernhard')), 'property.%!@$§', 'Bernhard'),
|
||||
|
||||
// nested objects and arrays
|
||||
array(array('foo' => new TestClass('bar')), '[foo].publicGetSetter', 'bar'),
|
||||
array(new TestClass(array('foo' => 'bar')), 'publicGetSetter[foo]', 'bar'),
|
||||
array(new TestClass(new TestClass('bar')), 'publicGetter.publicGetSetter', 'bar'),
|
||||
array(new TestClass(array('foo' => new TestClass('bar'))), 'publicGetter[foo].publicGetSetter', 'bar'),
|
||||
array(new TestClass(new TestClass(new TestClass('bar'))), 'publicGetter.publicGetter.publicGetSetter', 'bar'),
|
||||
array(new TestClass(array('foo' => array('baz' => new TestClass('bar')))), 'publicGetter[foo][baz].publicGetSetter', 'bar'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testTicket5755()
|
||||
{
|
||||
$object = new Ticket5775Object();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'property', 'foobar');
|
||||
|
||||
$this->assertEquals('foobar', $object->getProperty());
|
||||
}
|
||||
|
||||
public function testSetValueDeepWithMagicGetter()
|
||||
{
|
||||
$obj = new TestClassMagicGet('foo');
|
||||
$obj->publicProperty = array('foo' => array('bar' => 'some_value'));
|
||||
$this->propertyAccessor->setValue($obj, 'publicProperty[foo][bar]', 'Updated');
|
||||
$this->assertSame('Updated', $obj->publicProperty['foo']['bar']);
|
||||
}
|
||||
|
||||
public function getReferenceChainObjectsForSetValue()
|
||||
{
|
||||
return array(
|
||||
array(array('a' => array('b' => array('c' => 'old-value'))), '[a][b][c]', 'new-value'),
|
||||
array(new TestClassSetValue(new TestClassSetValue('old-value')), 'value.value', 'new-value'),
|
||||
array(new TestClassSetValue(array('a' => array('b' => array('c' => new TestClassSetValue('old-value'))))), 'value[a][b][c].value', 'new-value'),
|
||||
array(new TestClassSetValue(array('a' => array('b' => 'old-value'))), 'value[a][b]', 'new-value'),
|
||||
array(new \ArrayIterator(array('a' => array('b' => array('c' => 'old-value')))), '[a][b][c]', 'new-value'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReferenceChainObjectsForSetValue
|
||||
*/
|
||||
public function testSetValueForReferenceChainIssue($object, $path, $value)
|
||||
{
|
||||
$this->propertyAccessor->setValue($object, $path, $value);
|
||||
|
||||
$this->assertEquals($value, $this->propertyAccessor->getValue($object, $path));
|
||||
}
|
||||
|
||||
public function getReferenceChainObjectsForIsWritable()
|
||||
{
|
||||
return array(
|
||||
array(new TestClassIsWritable(array('a' => array('b' => 'old-value'))), 'value[a][b]', false),
|
||||
array(new TestClassIsWritable(new \ArrayIterator(array('a' => array('b' => 'old-value')))), 'value[a][b]', true),
|
||||
array(new TestClassIsWritable(array('a' => array('b' => array('c' => new TestClassSetValue('old-value'))))), 'value[a][b][c].value', true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReferenceChainObjectsForIsWritable
|
||||
*/
|
||||
public function testIsWritableForReferenceChainIssue($object, $path, $value)
|
||||
{
|
||||
$this->assertEquals($value, $this->propertyAccessor->isWritable($object, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Expected argument of type "DateTime", "string" given
|
||||
*/
|
||||
public function testThrowTypeError()
|
||||
{
|
||||
$object = new TypeHinted();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'date', 'This is a string, \DateTime expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Expected argument of type "DateTime", "NULL" given
|
||||
*/
|
||||
public function testThrowTypeErrorWithNullArgument()
|
||||
{
|
||||
$object = new TypeHinted();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'date', null);
|
||||
}
|
||||
|
||||
public function testSetTypeHint()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
$object = new TypeHinted();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'date', $date);
|
||||
$this->assertSame($date, $object->getDate());
|
||||
}
|
||||
|
||||
public function testArrayNotBeeingOverwritten()
|
||||
{
|
||||
$value = array('value1' => 'foo', 'value2' => 'bar');
|
||||
$object = new TestClass($value);
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'publicAccessor[value2]', 'baz');
|
||||
$this->assertSame('baz', $this->propertyAccessor->getValue($object, 'publicAccessor[value2]'));
|
||||
$this->assertSame(array('value1' => 'foo', 'value2' => 'baz'), $object->getPublicAccessor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Expected argument of type "Countable", "string" given
|
||||
*/
|
||||
public function testThrowTypeErrorWithInterface()
|
||||
{
|
||||
$object = new TypeHinted();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'countable', 'This is a string, \Countable expected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*
|
||||
* @expectedException \TypeError
|
||||
*/
|
||||
public function testDoNotDiscardReturnTypeError()
|
||||
{
|
||||
$object = new ReturnTyped();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'foos', array(new \DateTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*
|
||||
* @expectedException \TypeError
|
||||
*/
|
||||
public function testDoNotDiscardReturnTypeErrorWhenWriterMethodIsMisconfigured()
|
||||
{
|
||||
$object = new ReturnTyped();
|
||||
|
||||
$this->propertyAccessor->setValue($object, 'name', 'foo');
|
||||
}
|
||||
}
|
||||
22
vendor/symfony/property-access/Tests/PropertyAccessorTraversableArrayObjectTest.php
vendored
Normal file
22
vendor/symfony/property-access/Tests/PropertyAccessorTraversableArrayObjectTest.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Tests\Fixtures\TraversableArrayObject;
|
||||
|
||||
class PropertyAccessorTraversableArrayObjectTest extends PropertyAccessorCollectionTest
|
||||
{
|
||||
protected function getContainer(array $array)
|
||||
{
|
||||
return new TraversableArrayObject($array);
|
||||
}
|
||||
}
|
||||
288
vendor/symfony/property-access/Tests/PropertyPathBuilderTest.php
vendored
Normal file
288
vendor/symfony/property-access/Tests/PropertyPathBuilderTest.php
vendored
Normal file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
use Symfony\Component\PropertyAccess\PropertyPathBuilder;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class PropertyPathBuilderTest extends TestCase
|
||||
{
|
||||
const PREFIX = 'old1[old2].old3[old4][old5].old6';
|
||||
|
||||
/**
|
||||
* @var PropertyPathBuilder
|
||||
*/
|
||||
private $builder;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->builder = new PropertyPathBuilder(new PropertyPath(self::PREFIX));
|
||||
}
|
||||
|
||||
public function testCreateEmpty()
|
||||
{
|
||||
$builder = new PropertyPathBuilder();
|
||||
|
||||
$this->assertNull($builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testCreateCopyPath()
|
||||
{
|
||||
$this->assertEquals(new PropertyPath(self::PREFIX), $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppendIndex()
|
||||
{
|
||||
$this->builder->appendIndex('new1');
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'[new1]');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppendProperty()
|
||||
{
|
||||
$this->builder->appendProperty('new1');
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'.new1');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppend()
|
||||
{
|
||||
$this->builder->append(new PropertyPath('new1[new2]'));
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'.new1[new2]');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppendUsingString()
|
||||
{
|
||||
$this->builder->append('new1[new2]');
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'.new1[new2]');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppendWithOffset()
|
||||
{
|
||||
$this->builder->append(new PropertyPath('new1[new2].new3'), 1);
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'[new2].new3');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testAppendWithOffsetAndLength()
|
||||
{
|
||||
$this->builder->append(new PropertyPath('new1[new2].new3'), 1, 1);
|
||||
|
||||
$path = new PropertyPath(self::PREFIX.'[new2]');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceByIndex()
|
||||
{
|
||||
$this->builder->replaceByIndex(1, 'new1');
|
||||
|
||||
$path = new PropertyPath('old1[new1].old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceByIndexWithoutName()
|
||||
{
|
||||
$this->builder->replaceByIndex(0);
|
||||
|
||||
$path = new PropertyPath('[old1][old2].old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testReplaceByIndexDoesNotAllowInvalidOffsets()
|
||||
{
|
||||
$this->builder->replaceByIndex(6, 'new1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testReplaceByIndexDoesNotAllowNegativeOffsets()
|
||||
{
|
||||
$this->builder->replaceByIndex(-1, 'new1');
|
||||
}
|
||||
|
||||
public function testReplaceByProperty()
|
||||
{
|
||||
$this->builder->replaceByProperty(1, 'new1');
|
||||
|
||||
$path = new PropertyPath('old1.new1.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceByPropertyWithoutName()
|
||||
{
|
||||
$this->builder->replaceByProperty(1);
|
||||
|
||||
$path = new PropertyPath('old1.old2.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testReplaceByPropertyDoesNotAllowInvalidOffsets()
|
||||
{
|
||||
$this->builder->replaceByProperty(6, 'new1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testReplaceByPropertyDoesNotAllowNegativeOffsets()
|
||||
{
|
||||
$this->builder->replaceByProperty(-1, 'new1');
|
||||
}
|
||||
|
||||
public function testReplace()
|
||||
{
|
||||
$this->builder->replace(1, 1, new PropertyPath('new1[new2].new3'));
|
||||
|
||||
$path = new PropertyPath('old1.new1[new2].new3.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceUsingString()
|
||||
{
|
||||
$this->builder->replace(1, 1, 'new1[new2].new3');
|
||||
|
||||
$path = new PropertyPath('old1.new1[new2].new3.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceNegative()
|
||||
{
|
||||
$this->builder->replace(-1, 1, new PropertyPath('new1[new2].new3'));
|
||||
|
||||
$path = new PropertyPath('old1[old2].old3[old4][old5].new1[new2].new3');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidOffsets
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testReplaceDoesNotAllowInvalidOffsets($offset)
|
||||
{
|
||||
$this->builder->replace($offset, 1, new PropertyPath('new1[new2].new3'));
|
||||
}
|
||||
|
||||
public function provideInvalidOffsets()
|
||||
{
|
||||
return array(
|
||||
array(6),
|
||||
array(-7),
|
||||
);
|
||||
}
|
||||
|
||||
public function testReplaceWithLengthGreaterOne()
|
||||
{
|
||||
$this->builder->replace(0, 2, new PropertyPath('new1[new2].new3'));
|
||||
|
||||
$path = new PropertyPath('new1[new2].new3.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceSubstring()
|
||||
{
|
||||
$this->builder->replace(1, 1, new PropertyPath('new1[new2].new3.new4[new5]'), 1, 3);
|
||||
|
||||
$path = new PropertyPath('old1[new2].new3.new4.old3[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceSubstringWithLengthGreaterOne()
|
||||
{
|
||||
$this->builder->replace(1, 2, new PropertyPath('new1[new2].new3.new4[new5]'), 1, 3);
|
||||
|
||||
$path = new PropertyPath('old1[new2].new3.new4[old4][old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
// https://github.com/symfony/symfony/issues/5605
|
||||
public function testReplaceWithLongerPath()
|
||||
{
|
||||
// error occurs when path contains at least two more elements
|
||||
// than the builder
|
||||
$path = new PropertyPath('new1.new2.new3');
|
||||
|
||||
$builder = new PropertyPathBuilder(new PropertyPath('old1'));
|
||||
$builder->replace(0, 1, $path);
|
||||
|
||||
$this->assertEquals($path, $builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceWithLongerPathKeepsOrder()
|
||||
{
|
||||
$path = new PropertyPath('new1.new2.new3');
|
||||
$expected = new PropertyPath('new1.new2.new3.old2');
|
||||
|
||||
$builder = new PropertyPathBuilder(new PropertyPath('old1.old2'));
|
||||
$builder->replace(0, 1, $path);
|
||||
|
||||
$this->assertEquals($expected, $builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$this->builder->remove(3);
|
||||
|
||||
$path = new PropertyPath('old1[old2].old3[old5].old6');
|
||||
|
||||
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testRemoveDoesNotAllowInvalidOffsets()
|
||||
{
|
||||
$this->builder->remove(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testRemoveDoesNotAllowNegativeOffsets()
|
||||
{
|
||||
$this->builder->remove(-1);
|
||||
}
|
||||
}
|
||||
206
vendor/symfony/property-access/Tests/PropertyPathTest.php
vendored
Normal file
206
vendor/symfony/property-access/Tests/PropertyPathTest.php
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
|
||||
class PropertyPathTest extends TestCase
|
||||
{
|
||||
public function testToString()
|
||||
{
|
||||
$path = new PropertyPath('reference.traversable[index].property');
|
||||
|
||||
$this->assertEquals('reference.traversable[index].property', $path->__toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
|
||||
*/
|
||||
public function testDotIsRequiredBeforeProperty()
|
||||
{
|
||||
new PropertyPath('[index]property');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
|
||||
*/
|
||||
public function testDotCannotBePresentAtTheBeginning()
|
||||
{
|
||||
new PropertyPath('.property');
|
||||
}
|
||||
|
||||
public function providePathsContainingUnexpectedCharacters()
|
||||
{
|
||||
return array(
|
||||
array('property.'),
|
||||
array('property.['),
|
||||
array('property..'),
|
||||
array('property['),
|
||||
array('property[['),
|
||||
array('property[.'),
|
||||
array('property[]'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePathsContainingUnexpectedCharacters
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
|
||||
*/
|
||||
public function testUnexpectedCharacters($path)
|
||||
{
|
||||
new PropertyPath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
|
||||
*/
|
||||
public function testPathCannotBeEmpty()
|
||||
{
|
||||
new PropertyPath('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testPathCannotBeNull()
|
||||
{
|
||||
new PropertyPath(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testPathCannotBeFalse()
|
||||
{
|
||||
new PropertyPath(false);
|
||||
}
|
||||
|
||||
public function testZeroIsValidPropertyPath()
|
||||
{
|
||||
$propertyPath = new PropertyPath('0');
|
||||
|
||||
$this->assertSame('0', (string) $propertyPath);
|
||||
}
|
||||
|
||||
public function testGetParentWithDot()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent.child');
|
||||
|
||||
$this->assertEquals(new PropertyPath('grandpa.parent'), $propertyPath->getParent());
|
||||
}
|
||||
|
||||
public function testGetParentWithIndex()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$this->assertEquals(new PropertyPath('grandpa.parent'), $propertyPath->getParent());
|
||||
}
|
||||
|
||||
public function testGetParentWhenThereIsNoParent()
|
||||
{
|
||||
$propertyPath = new PropertyPath('path');
|
||||
|
||||
$this->assertNull($propertyPath->getParent());
|
||||
}
|
||||
|
||||
public function testCopyConstructor()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
$copy = new PropertyPath($propertyPath);
|
||||
|
||||
$this->assertEquals($propertyPath, $copy);
|
||||
}
|
||||
|
||||
public function testGetElement()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$this->assertEquals('child', $propertyPath->getElement(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testGetElementDoesNotAcceptInvalidIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->getElement(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testGetElementDoesNotAcceptNegativeIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->getElement(-1);
|
||||
}
|
||||
|
||||
public function testIsProperty()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$this->assertTrue($propertyPath->isProperty(1));
|
||||
$this->assertFalse($propertyPath->isProperty(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testIsPropertyDoesNotAcceptInvalidIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->isProperty(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testIsPropertyDoesNotAcceptNegativeIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->isProperty(-1);
|
||||
}
|
||||
|
||||
public function testIsIndex()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$this->assertFalse($propertyPath->isIndex(1));
|
||||
$this->assertTrue($propertyPath->isIndex(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testIsIndexDoesNotAcceptInvalidIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->isIndex(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testIsIndexDoesNotAcceptNegativeIndices()
|
||||
{
|
||||
$propertyPath = new PropertyPath('grandpa.parent[child]');
|
||||
|
||||
$propertyPath->isIndex(-1);
|
||||
}
|
||||
}
|
||||
172
vendor/symfony/property-access/Tests/StringUtilTest.php
vendored
Normal file
172
vendor/symfony/property-access/Tests/StringUtilTest.php
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\PropertyAccess\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\PropertyAccess\StringUtil;
|
||||
|
||||
class StringUtilTest extends TestCase
|
||||
{
|
||||
public function singularifyProvider()
|
||||
{
|
||||
// see http://english-zone.com/spelling/plurals.html
|
||||
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
|
||||
return array(
|
||||
array('accesses', 'access'),
|
||||
array('addresses', 'address'),
|
||||
array('agendas', 'agenda'),
|
||||
array('alumnae', 'alumna'),
|
||||
array('alumni', 'alumnus'),
|
||||
array('analyses', array('analys', 'analyse', 'analysis')),
|
||||
array('antennae', 'antenna'),
|
||||
array('antennas', 'antenna'),
|
||||
array('appendices', array('appendex', 'appendix', 'appendice')),
|
||||
array('arches', array('arch', 'arche')),
|
||||
array('atlases', array('atlas', 'atlase', 'atlasis')),
|
||||
array('axes', array('ax', 'axe', 'axis')),
|
||||
array('babies', 'baby'),
|
||||
array('bacteria', array('bacterion', 'bacterium')),
|
||||
array('bases', array('bas', 'base', 'basis')),
|
||||
array('batches', array('batch', 'batche')),
|
||||
array('beaux', 'beau'),
|
||||
array('bees', array('be', 'bee')),
|
||||
array('boxes', 'box'),
|
||||
array('boys', 'boy'),
|
||||
array('bureaus', 'bureau'),
|
||||
array('bureaux', 'bureau'),
|
||||
array('buses', array('bus', 'buse', 'busis')),
|
||||
array('bushes', array('bush', 'bushe')),
|
||||
array('calves', array('calf', 'calve', 'calff')),
|
||||
array('cars', 'car'),
|
||||
array('cassettes', array('cassett', 'cassette')),
|
||||
array('caves', array('caf', 'cave', 'caff')),
|
||||
array('chateaux', 'chateau'),
|
||||
array('cheeses', array('chees', 'cheese', 'cheesis')),
|
||||
array('children', 'child'),
|
||||
array('circuses', array('circus', 'circuse', 'circusis')),
|
||||
array('cliffs', 'cliff'),
|
||||
array('committee', 'committee'),
|
||||
array('crises', array('cris', 'crise', 'crisis')),
|
||||
array('criteria', array('criterion', 'criterium')),
|
||||
array('cups', 'cup'),
|
||||
array('data', array('daton', 'datum')),
|
||||
array('days', 'day'),
|
||||
array('discos', 'disco'),
|
||||
array('devices', array('devex', 'devix', 'device')),
|
||||
array('drives', 'drive'),
|
||||
array('drivers', 'driver'),
|
||||
array('dwarves', array('dwarf', 'dwarve', 'dwarff')),
|
||||
array('echoes', array('echo', 'echoe')),
|
||||
array('elves', array('elf', 'elve', 'elff')),
|
||||
array('emphases', array('emphas', 'emphase', 'emphasis')),
|
||||
array('faxes', 'fax'),
|
||||
array('feet', 'foot'),
|
||||
array('feedback', 'feedback'),
|
||||
array('foci', 'focus'),
|
||||
array('focuses', array('focus', 'focuse', 'focusis')),
|
||||
array('formulae', 'formula'),
|
||||
array('formulas', 'formula'),
|
||||
array('fungi', 'fungus'),
|
||||
array('funguses', array('fungus', 'funguse', 'fungusis')),
|
||||
array('garages', array('garag', 'garage')),
|
||||
array('geese', 'goose'),
|
||||
array('halves', array('half', 'halve', 'halff')),
|
||||
array('hats', 'hat'),
|
||||
array('heroes', array('hero', 'heroe')),
|
||||
array('hippopotamuses', array('hippopotamus', 'hippopotamuse', 'hippopotamusis')), //hippopotami
|
||||
array('hoaxes', 'hoax'),
|
||||
array('hooves', array('hoof', 'hoove', 'hooff')),
|
||||
array('houses', array('hous', 'house', 'housis')),
|
||||
array('indexes', 'index'),
|
||||
array('indices', array('index', 'indix', 'indice')),
|
||||
array('ions', 'ion'),
|
||||
array('irises', array('iris', 'irise', 'irisis')),
|
||||
array('kisses', 'kiss'),
|
||||
array('knives', 'knife'),
|
||||
array('lamps', 'lamp'),
|
||||
array('leaves', array('leaf', 'leave', 'leaff')),
|
||||
array('lice', 'louse'),
|
||||
array('lives', 'life'),
|
||||
array('matrices', array('matrex', 'matrix', 'matrice')),
|
||||
array('matrixes', 'matrix'),
|
||||
array('men', 'man'),
|
||||
array('mice', 'mouse'),
|
||||
array('moves', 'move'),
|
||||
array('movies', 'movie'),
|
||||
array('nebulae', 'nebula'),
|
||||
array('neuroses', array('neuros', 'neurose', 'neurosis')),
|
||||
array('news', 'news'),
|
||||
array('oases', array('oas', 'oase', 'oasis')),
|
||||
array('objectives', 'objective'),
|
||||
array('oxen', 'ox'),
|
||||
array('parties', 'party'),
|
||||
array('people', 'person'),
|
||||
array('persons', 'person'),
|
||||
array('phenomena', array('phenomenon', 'phenomenum')),
|
||||
array('photos', 'photo'),
|
||||
array('pianos', 'piano'),
|
||||
array('plateaux', 'plateau'),
|
||||
array('poppies', 'poppy'),
|
||||
array('prices', array('prex', 'prix', 'price')),
|
||||
array('quizzes', 'quiz'),
|
||||
array('radii', 'radius'),
|
||||
array('roofs', 'roof'),
|
||||
array('roses', array('ros', 'rose', 'rosis')),
|
||||
array('sandwiches', array('sandwich', 'sandwiche')),
|
||||
array('scarves', array('scarf', 'scarve', 'scarff')),
|
||||
array('schemas', 'schema'), //schemata
|
||||
array('selfies', 'selfie'),
|
||||
array('series', 'series'),
|
||||
array('services', 'service'),
|
||||
array('sheriffs', 'sheriff'),
|
||||
array('shoes', array('sho', 'shoe')),
|
||||
array('spies', 'spy'),
|
||||
array('staves', array('staf', 'stave', 'staff')),
|
||||
array('stories', 'story'),
|
||||
array('strata', array('straton', 'stratum')),
|
||||
array('suitcases', array('suitcas', 'suitcase', 'suitcasis')),
|
||||
array('syllabi', 'syllabus'),
|
||||
array('tags', 'tag'),
|
||||
array('teeth', 'tooth'),
|
||||
array('theses', array('thes', 'these', 'thesis')),
|
||||
array('thieves', array('thief', 'thieve', 'thieff')),
|
||||
array('trees', array('tre', 'tree')),
|
||||
array('waltzes', array('waltz', 'waltze')),
|
||||
array('wives', 'wife'),
|
||||
|
||||
// test casing: if the first letter was uppercase, it should remain so
|
||||
array('Men', 'Man'),
|
||||
array('GrandChildren', 'GrandChild'),
|
||||
array('SubTrees', array('SubTre', 'SubTree')),
|
||||
|
||||
// Known issues
|
||||
//array('insignia', 'insigne'),
|
||||
//array('insignias', 'insigne'),
|
||||
//array('rattles', 'rattle'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider singularifyProvider
|
||||
*/
|
||||
public function testSingularify($plural, $singular)
|
||||
{
|
||||
$single = StringUtil::singularify($plural);
|
||||
if (\is_string($singular) && \is_array($single)) {
|
||||
$this->fail("--- Expected\n`string`: ".$singular."\n+++ Actual\n`array`: ".implode(', ', $single));
|
||||
} elseif (\is_array($singular) && \is_string($single)) {
|
||||
$this->fail("--- Expected\n`array`: ".implode(', ', $singular)."\n+++ Actual\n`string`: ".$single);
|
||||
}
|
||||
|
||||
$this->assertEquals($singular, $single);
|
||||
}
|
||||
}
|
||||
34
vendor/symfony/property-access/composer.json
vendored
Normal file
34
vendor/symfony/property-access/composer.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "symfony/property-access",
|
||||
"type": "library",
|
||||
"description": "Symfony PropertyAccess Component",
|
||||
"keywords": ["property", "index", "access", "object", "array", "extraction", "injection", "reflection", "property path"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.9",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\PropertyAccess\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/property-access/phpunit.xml.dist
vendored
Normal file
31
vendor/symfony/property-access/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony PropertyAccess Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
53
vendor/symfony/var-dumper/CHANGELOG.md
vendored
Normal file
53
vendor/symfony/var-dumper/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* added `VarDumperTestTrait::setUpVarDumper()` and `VarDumperTestTrait::tearDownVarDumper()`
|
||||
to configure casters & flags to use in tests
|
||||
* added `ImagineCaster` and infrastructure to dump images
|
||||
* added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data
|
||||
* added `UuidCaster`
|
||||
* made all casters final
|
||||
* added support for the `NO_COLOR` env var (https://no-color.org/)
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added `DsCaster` to support dumping the contents of data structures from the Ds extension
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* support selecting the format to use by setting the environment variable `VAR_DUMPER_FORMAT` to `html` or `cli`
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
* added a `ServerDumper` to send serialized Data clones to a server
|
||||
* added a `ServerDumpCommand` and `DumpServer` to run a server collecting
|
||||
and displaying dumps on a single place with multiple formats support
|
||||
* added `CliDescriptor` and `HtmlDescriptor` descriptors for `server:dump` CLI and HTML formats support
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* support for passing `\ReflectionClass` instances to the `Caster::castObject()`
|
||||
method has been dropped, pass class names as strings instead
|
||||
* the `Data::getRawData()` method has been removed
|
||||
* the `VarDumperTestTrait::assertDumpEquals()` method expects a 3rd `$filter = 0`
|
||||
argument and moves `$message = ''` argument at 4th position.
|
||||
* the `VarDumperTestTrait::assertDumpMatchesFormat()` method expects a 3rd `$filter = 0`
|
||||
argument and moves `$message = ''` argument at 4th position.
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* added `AbstractCloner::setMinDepth()` function to ensure minimum tree depth
|
||||
* deprecated `MongoCaster`
|
||||
|
||||
2.7.0
|
||||
-----
|
||||
|
||||
* deprecated `Cloner\Data::getLimitedClone()`. Use `withMaxDepth`, `withMaxItemsPerDepth` or `withRefHandles` instead.
|
||||
212
vendor/symfony/var-dumper/Caster/AmqpCaster.php
vendored
Normal file
212
vendor/symfony/var-dumper/Caster/AmqpCaster.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Amqp related classes to array representation.
|
||||
*
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class AmqpCaster
|
||||
{
|
||||
private static $flags = [
|
||||
AMQP_DURABLE => 'AMQP_DURABLE',
|
||||
AMQP_PASSIVE => 'AMQP_PASSIVE',
|
||||
AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE',
|
||||
AMQP_AUTODELETE => 'AMQP_AUTODELETE',
|
||||
AMQP_INTERNAL => 'AMQP_INTERNAL',
|
||||
AMQP_NOLOCAL => 'AMQP_NOLOCAL',
|
||||
AMQP_AUTOACK => 'AMQP_AUTOACK',
|
||||
AMQP_IFEMPTY => 'AMQP_IFEMPTY',
|
||||
AMQP_IFUNUSED => 'AMQP_IFUNUSED',
|
||||
AMQP_MANDATORY => 'AMQP_MANDATORY',
|
||||
AMQP_IMMEDIATE => 'AMQP_IMMEDIATE',
|
||||
AMQP_MULTIPLE => 'AMQP_MULTIPLE',
|
||||
AMQP_NOWAIT => 'AMQP_NOWAIT',
|
||||
AMQP_REQUEUE => 'AMQP_REQUEUE',
|
||||
];
|
||||
|
||||
private static $exchangeTypes = [
|
||||
AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT',
|
||||
AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT',
|
||||
AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC',
|
||||
AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS',
|
||||
];
|
||||
|
||||
public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += [
|
||||
$prefix.'is_connected' => $c->isConnected(),
|
||||
];
|
||||
|
||||
// Recent version of the extension already expose private properties
|
||||
if (isset($a["\x00AMQPConnection\x00login"])) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
// BC layer in the amqp lib
|
||||
if (method_exists($c, 'getReadTimeout')) {
|
||||
$timeout = $c->getReadTimeout();
|
||||
} else {
|
||||
$timeout = $c->getTimeout();
|
||||
}
|
||||
|
||||
$a += [
|
||||
$prefix.'is_connected' => $c->isConnected(),
|
||||
$prefix.'login' => $c->getLogin(),
|
||||
$prefix.'password' => $c->getPassword(),
|
||||
$prefix.'host' => $c->getHost(),
|
||||
$prefix.'vhost' => $c->getVhost(),
|
||||
$prefix.'port' => $c->getPort(),
|
||||
$prefix.'read_timeout' => $timeout,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += [
|
||||
$prefix.'is_connected' => $c->isConnected(),
|
||||
$prefix.'channel_id' => $c->getChannelId(),
|
||||
];
|
||||
|
||||
// Recent version of the extension already expose private properties
|
||||
if (isset($a["\x00AMQPChannel\x00connection"])) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
$a += [
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
$prefix.'prefetch_size' => $c->getPrefetchSize(),
|
||||
$prefix.'prefetch_count' => $c->getPrefetchCount(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += [
|
||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
||||
];
|
||||
|
||||
// Recent version of the extension already expose private properties
|
||||
if (isset($a["\x00AMQPQueue\x00name"])) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
$a += [
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
$prefix.'channel' => $c->getChannel(),
|
||||
$prefix.'name' => $c->getName(),
|
||||
$prefix.'arguments' => $c->getArguments(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += [
|
||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
||||
];
|
||||
|
||||
$type = isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType();
|
||||
|
||||
// Recent version of the extension already expose private properties
|
||||
if (isset($a["\x00AMQPExchange\x00name"])) {
|
||||
$a["\x00AMQPExchange\x00type"] = $type;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
$a += [
|
||||
$prefix.'connection' => $c->getConnection(),
|
||||
$prefix.'channel' => $c->getChannel(),
|
||||
$prefix.'name' => $c->getName(),
|
||||
$prefix.'type' => $type,
|
||||
$prefix.'arguments' => $c->getArguments(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode());
|
||||
|
||||
// Recent version of the extension already expose private properties
|
||||
if (isset($a["\x00AMQPEnvelope\x00body"])) {
|
||||
$a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||
$a += [$prefix.'body' => $c->getBody()];
|
||||
}
|
||||
|
||||
$a += [
|
||||
$prefix.'delivery_tag' => $c->getDeliveryTag(),
|
||||
$prefix.'is_redelivery' => $c->isRedelivery(),
|
||||
$prefix.'exchange_name' => $c->getExchangeName(),
|
||||
$prefix.'routing_key' => $c->getRoutingKey(),
|
||||
$prefix.'content_type' => $c->getContentType(),
|
||||
$prefix.'content_encoding' => $c->getContentEncoding(),
|
||||
$prefix.'headers' => $c->getHeaders(),
|
||||
$prefix.'delivery_mode' => $deliveryMode,
|
||||
$prefix.'priority' => $c->getPriority(),
|
||||
$prefix.'correlation_id' => $c->getCorrelationId(),
|
||||
$prefix.'reply_to' => $c->getReplyTo(),
|
||||
$prefix.'expiration' => $c->getExpiration(),
|
||||
$prefix.'message_id' => $c->getMessageId(),
|
||||
$prefix.'timestamp' => $c->getTimeStamp(),
|
||||
$prefix.'type' => $c->getType(),
|
||||
$prefix.'user_id' => $c->getUserId(),
|
||||
$prefix.'app_id' => $c->getAppId(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function extractFlags(int $flags): ConstStub
|
||||
{
|
||||
$flagsArray = [];
|
||||
|
||||
foreach (self::$flags as $value => $name) {
|
||||
if ($flags & $value) {
|
||||
$flagsArray[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagsArray) {
|
||||
$flagsArray = ['AMQP_NOPARAM'];
|
||||
}
|
||||
|
||||
return new ConstStub(implode('|', $flagsArray), $flags);
|
||||
}
|
||||
}
|
||||
80
vendor/symfony/var-dumper/Caster/ArgsStub.php
vendored
Normal file
80
vendor/symfony/var-dumper/Caster/ArgsStub.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents a list of function arguments.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ArgsStub extends EnumStub
|
||||
{
|
||||
private static $parameters = [];
|
||||
|
||||
public function __construct(array $args, string $function, ?string $class)
|
||||
{
|
||||
list($variadic, $params) = self::getParameters($function, $class);
|
||||
|
||||
$values = [];
|
||||
foreach ($args as $k => $v) {
|
||||
$values[$k] = !is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v;
|
||||
}
|
||||
if (null === $params) {
|
||||
parent::__construct($values, false);
|
||||
|
||||
return;
|
||||
}
|
||||
if (\count($values) < \count($params)) {
|
||||
$params = \array_slice($params, 0, \count($values));
|
||||
} elseif (\count($values) > \count($params)) {
|
||||
$values[] = new EnumStub(array_splice($values, \count($params)), false);
|
||||
$params[] = $variadic;
|
||||
}
|
||||
if (['...'] === $params) {
|
||||
$this->dumpKeys = false;
|
||||
$this->value = $values[0]->value;
|
||||
} else {
|
||||
$this->value = array_combine($params, $values);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getParameters(string $function, ?string $class): array
|
||||
{
|
||||
if (isset(self::$parameters[$k = $class.'::'.$function])) {
|
||||
return self::$parameters[$k];
|
||||
}
|
||||
|
||||
try {
|
||||
$r = null !== $class ? new \ReflectionMethod($class, $function) : new \ReflectionFunction($function);
|
||||
} catch (\ReflectionException $e) {
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
$variadic = '...';
|
||||
$params = [];
|
||||
foreach ($r->getParameters() as $v) {
|
||||
$k = '$'.$v->name;
|
||||
if ($v->isPassedByReference()) {
|
||||
$k = '&'.$k;
|
||||
}
|
||||
if ($v->isVariadic()) {
|
||||
$variadic .= $k;
|
||||
} else {
|
||||
$params[] = $k;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$parameters[$k] = [$variadic, $params];
|
||||
}
|
||||
}
|
||||
170
vendor/symfony/var-dumper/Caster/Caster.php
vendored
Normal file
170
vendor/symfony/var-dumper/Caster/Caster.php
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Helper for filtering out properties in casters.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class Caster
|
||||
{
|
||||
const EXCLUDE_VERBOSE = 1;
|
||||
const EXCLUDE_VIRTUAL = 2;
|
||||
const EXCLUDE_DYNAMIC = 4;
|
||||
const EXCLUDE_PUBLIC = 8;
|
||||
const EXCLUDE_PROTECTED = 16;
|
||||
const EXCLUDE_PRIVATE = 32;
|
||||
const EXCLUDE_NULL = 64;
|
||||
const EXCLUDE_EMPTY = 128;
|
||||
const EXCLUDE_NOT_IMPORTANT = 256;
|
||||
const EXCLUDE_STRICT = 512;
|
||||
|
||||
const PREFIX_VIRTUAL = "\0~\0";
|
||||
const PREFIX_DYNAMIC = "\0+\0";
|
||||
const PREFIX_PROTECTED = "\0*\0";
|
||||
|
||||
/**
|
||||
* Casts objects to arrays and adds the dynamic property prefix.
|
||||
*
|
||||
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
|
||||
*
|
||||
* @return array The array-cast of the object, with prefixed dynamic properties
|
||||
*/
|
||||
public static function castObject(object $obj, string $class, bool $hasDebugInfo = false): array
|
||||
{
|
||||
if ($hasDebugInfo) {
|
||||
try {
|
||||
$debugInfo = $obj->__debugInfo();
|
||||
} catch (\Exception $e) {
|
||||
// ignore failing __debugInfo()
|
||||
$hasDebugInfo = false;
|
||||
}
|
||||
}
|
||||
|
||||
$a = $obj instanceof \Closure ? [] : (array) $obj;
|
||||
|
||||
if ($obj instanceof \__PHP_Incomplete_Class) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
if ($a) {
|
||||
static $publicProperties = [];
|
||||
|
||||
$i = 0;
|
||||
$prefixedKeys = [];
|
||||
foreach ($a as $k => $v) {
|
||||
if ("\0" !== ($k[0] ?? '')) {
|
||||
if (!isset($publicProperties[$class])) {
|
||||
foreach ((new \ReflectionClass($class))->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||
$publicProperties[$class][$prop->name] = true;
|
||||
}
|
||||
}
|
||||
if (!isset($publicProperties[$class][$k])) {
|
||||
$prefixedKeys[$i] = self::PREFIX_DYNAMIC.$k;
|
||||
}
|
||||
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
||||
$prefixedKeys[$i] = "\0".get_parent_class($class).'@anonymous'.strrchr($k, "\0");
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
if ($prefixedKeys) {
|
||||
$keys = array_keys($a);
|
||||
foreach ($prefixedKeys as $i => $k) {
|
||||
$keys[$i] = $k;
|
||||
}
|
||||
$a = array_combine($keys, $a);
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasDebugInfo && \is_array($debugInfo)) {
|
||||
foreach ($debugInfo as $k => $v) {
|
||||
if (!isset($k[0]) || "\0" !== $k[0]) {
|
||||
$k = self::PREFIX_VIRTUAL.$k;
|
||||
}
|
||||
|
||||
unset($a[$k]);
|
||||
$a[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out the specified properties.
|
||||
*
|
||||
* By default, a single match in the $filter bit field filters properties out, following an "or" logic.
|
||||
* When EXCLUDE_STRICT is set, an "and" logic is applied: all bits must match for a property to be removed.
|
||||
*
|
||||
* @param array $a The array containing the properties to filter
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out
|
||||
* @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set
|
||||
* @param int &$count Set to the number of removed properties
|
||||
*
|
||||
* @return array The filtered array
|
||||
*/
|
||||
public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($a as $k => $v) {
|
||||
$type = self::EXCLUDE_STRICT & $filter;
|
||||
|
||||
if (null === $v) {
|
||||
$type |= self::EXCLUDE_NULL & $filter;
|
||||
$type |= self::EXCLUDE_EMPTY & $filter;
|
||||
} elseif (false === $v || '' === $v || '0' === $v || 0 === $v || 0.0 === $v || [] === $v) {
|
||||
$type |= self::EXCLUDE_EMPTY & $filter;
|
||||
}
|
||||
if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !\in_array($k, $listedProperties, true)) {
|
||||
$type |= self::EXCLUDE_NOT_IMPORTANT;
|
||||
}
|
||||
if ((self::EXCLUDE_VERBOSE & $filter) && \in_array($k, $listedProperties, true)) {
|
||||
$type |= self::EXCLUDE_VERBOSE;
|
||||
}
|
||||
|
||||
if (!isset($k[1]) || "\0" !== $k[0]) {
|
||||
$type |= self::EXCLUDE_PUBLIC & $filter;
|
||||
} elseif ('~' === $k[1]) {
|
||||
$type |= self::EXCLUDE_VIRTUAL & $filter;
|
||||
} elseif ('+' === $k[1]) {
|
||||
$type |= self::EXCLUDE_DYNAMIC & $filter;
|
||||
} elseif ('*' === $k[1]) {
|
||||
$type |= self::EXCLUDE_PROTECTED & $filter;
|
||||
} else {
|
||||
$type |= self::EXCLUDE_PRIVATE & $filter;
|
||||
}
|
||||
|
||||
if ((self::EXCLUDE_STRICT & $filter) ? $type === $filter : $type) {
|
||||
unset($a[$k]);
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
if (isset($a['__PHP_Incomplete_Class_Name'])) {
|
||||
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';
|
||||
unset($a['__PHP_Incomplete_Class_Name']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
106
vendor/symfony/var-dumper/Caster/ClassStub.php
vendored
Normal file
106
vendor/symfony/var-dumper/Caster/ClassStub.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents a PHP class identifier.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ClassStub extends ConstStub
|
||||
{
|
||||
/**
|
||||
* @param string $identifier A PHP identifier, e.g. a class, method, interface, etc. name
|
||||
* @param callable $callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier
|
||||
*/
|
||||
public function __construct(string $identifier, $callable = null)
|
||||
{
|
||||
$this->value = $identifier;
|
||||
|
||||
try {
|
||||
if (null !== $callable) {
|
||||
if ($callable instanceof \Closure) {
|
||||
$r = new \ReflectionFunction($callable);
|
||||
} elseif (\is_object($callable)) {
|
||||
$r = [$callable, '__invoke'];
|
||||
} elseif (\is_array($callable)) {
|
||||
$r = $callable;
|
||||
} elseif (false !== $i = strpos($callable, '::')) {
|
||||
$r = [substr($callable, 0, $i), substr($callable, 2 + $i)];
|
||||
} else {
|
||||
$r = new \ReflectionFunction($callable);
|
||||
}
|
||||
} elseif (0 < $i = strpos($identifier, '::') ?: strpos($identifier, '->')) {
|
||||
$r = [substr($identifier, 0, $i), substr($identifier, 2 + $i)];
|
||||
} else {
|
||||
$r = new \ReflectionClass($identifier);
|
||||
}
|
||||
|
||||
if (\is_array($r)) {
|
||||
try {
|
||||
$r = new \ReflectionMethod($r[0], $r[1]);
|
||||
} catch (\ReflectionException $e) {
|
||||
$r = new \ReflectionClass($r[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== strpos($identifier, "class@anonymous\0")) {
|
||||
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
|
||||
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
|
||||
}, $identifier);
|
||||
}
|
||||
|
||||
if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) {
|
||||
$s = ReflectionCaster::castFunctionAbstract($r, [], new Stub(), true, Caster::EXCLUDE_VERBOSE);
|
||||
$s = ReflectionCaster::getSignature($s);
|
||||
|
||||
if ('()' === substr($identifier, -2)) {
|
||||
$this->value = substr_replace($identifier, $s, -2);
|
||||
} else {
|
||||
$this->value .= $s;
|
||||
}
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
return;
|
||||
} finally {
|
||||
if (0 < $i = strrpos($this->value, '\\')) {
|
||||
$this->attr['ellipsis'] = \strlen($this->value) - $i;
|
||||
$this->attr['ellipsis-type'] = 'class';
|
||||
$this->attr['ellipsis-tail'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($f = $r->getFileName()) {
|
||||
$this->attr['file'] = $f;
|
||||
$this->attr['line'] = $r->getStartLine();
|
||||
}
|
||||
}
|
||||
|
||||
public static function wrapCallable($callable)
|
||||
{
|
||||
if (\is_object($callable) || !\is_callable($callable)) {
|
||||
return $callable;
|
||||
}
|
||||
|
||||
if (!\is_array($callable)) {
|
||||
$callable = new static($callable, $callable);
|
||||
} elseif (\is_string($callable[0])) {
|
||||
$callable[0] = new static($callable[0], $callable);
|
||||
} else {
|
||||
$callable[1] = new static($callable[1], $callable);
|
||||
}
|
||||
|
||||
return $callable;
|
||||
}
|
||||
}
|
||||
36
vendor/symfony/var-dumper/Caster/ConstStub.php
vendored
Normal file
36
vendor/symfony/var-dumper/Caster/ConstStub.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents a PHP constant and its value.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ConstStub extends Stub
|
||||
{
|
||||
public function __construct(string $name, $value = null)
|
||||
{
|
||||
$this->class = $name;
|
||||
$this->value = 1 < \func_num_args() ? $value : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/var-dumper/Caster/CutArrayStub.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/CutArrayStub.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Represents a cut array.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CutArrayStub extends CutStub
|
||||
{
|
||||
public $preservedSubset;
|
||||
|
||||
public function __construct(array $value, array $preservedKeys)
|
||||
{
|
||||
parent::__construct($value);
|
||||
|
||||
$this->preservedSubset = array_intersect_key($value, array_flip($preservedKeys));
|
||||
$this->cut -= \count($this->preservedSubset);
|
||||
}
|
||||
}
|
||||
64
vendor/symfony/var-dumper/Caster/CutStub.php
vendored
Normal file
64
vendor/symfony/var-dumper/Caster/CutStub.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents the main properties of a PHP variable, pre-casted by a caster.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CutStub extends Stub
|
||||
{
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
switch (\gettype($value)) {
|
||||
case 'object':
|
||||
$this->type = self::TYPE_OBJECT;
|
||||
$this->class = \get_class($value);
|
||||
|
||||
if ($value instanceof \Closure) {
|
||||
ReflectionCaster::castClosure($value, [], $this, true, Caster::EXCLUDE_VERBOSE);
|
||||
}
|
||||
|
||||
$this->cut = -1;
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
$this->type = self::TYPE_ARRAY;
|
||||
$this->class = self::ARRAY_ASSOC;
|
||||
$this->cut = $this->value = \count($value);
|
||||
break;
|
||||
|
||||
case 'resource':
|
||||
case 'unknown type':
|
||||
case 'resource (closed)':
|
||||
$this->type = self::TYPE_RESOURCE;
|
||||
$this->handle = (int) $value;
|
||||
if ('Unknown' === $this->class = @get_resource_type($value)) {
|
||||
$this->class = 'Closed';
|
||||
}
|
||||
$this->cut = -1;
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
$this->type = self::TYPE_STRING;
|
||||
$this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
|
||||
$this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8');
|
||||
$this->value = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
304
vendor/symfony/var-dumper/Caster/DOMCaster.php
vendored
Normal file
304
vendor/symfony/var-dumper/Caster/DOMCaster.php
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts DOM related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class DOMCaster
|
||||
{
|
||||
private static $errorCodes = [
|
||||
DOM_PHP_ERR => 'DOM_PHP_ERR',
|
||||
DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
|
||||
DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
|
||||
DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR',
|
||||
DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR',
|
||||
DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR',
|
||||
DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR',
|
||||
DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR',
|
||||
DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR',
|
||||
DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR',
|
||||
DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR',
|
||||
DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR',
|
||||
DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR',
|
||||
DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR',
|
||||
DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR',
|
||||
DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR',
|
||||
DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR',
|
||||
];
|
||||
|
||||
private static $nodeTypes = [
|
||||
XML_ELEMENT_NODE => 'XML_ELEMENT_NODE',
|
||||
XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE',
|
||||
XML_TEXT_NODE => 'XML_TEXT_NODE',
|
||||
XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE',
|
||||
XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE',
|
||||
XML_ENTITY_NODE => 'XML_ENTITY_NODE',
|
||||
XML_PI_NODE => 'XML_PI_NODE',
|
||||
XML_COMMENT_NODE => 'XML_COMMENT_NODE',
|
||||
XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE',
|
||||
XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE',
|
||||
XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE',
|
||||
XML_NOTATION_NODE => 'XML_NOTATION_NODE',
|
||||
XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE',
|
||||
XML_DTD_NODE => 'XML_DTD_NODE',
|
||||
XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE',
|
||||
XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
|
||||
XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
|
||||
XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
|
||||
];
|
||||
|
||||
public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$k = Caster::PREFIX_PROTECTED.'code';
|
||||
if (isset($a[$k], self::$errorCodes[$a[$k]])) {
|
||||
$a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castLength($dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'length' => $dom->length,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castImplementation($dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'Core' => '1.0',
|
||||
Caster::PREFIX_VIRTUAL.'XML' => '2.0',
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'nodeName' => $dom->nodeName,
|
||||
'nodeValue' => new CutStub($dom->nodeValue),
|
||||
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
|
||||
'parentNode' => new CutStub($dom->parentNode),
|
||||
'childNodes' => $dom->childNodes,
|
||||
'firstChild' => new CutStub($dom->firstChild),
|
||||
'lastChild' => new CutStub($dom->lastChild),
|
||||
'previousSibling' => new CutStub($dom->previousSibling),
|
||||
'nextSibling' => new CutStub($dom->nextSibling),
|
||||
'attributes' => $dom->attributes,
|
||||
'ownerDocument' => new CutStub($dom->ownerDocument),
|
||||
'namespaceURI' => $dom->namespaceURI,
|
||||
'prefix' => $dom->prefix,
|
||||
'localName' => $dom->localName,
|
||||
'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI,
|
||||
'textContent' => new CutStub($dom->textContent),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'nodeName' => $dom->nodeName,
|
||||
'nodeValue' => new CutStub($dom->nodeValue),
|
||||
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
|
||||
'prefix' => $dom->prefix,
|
||||
'localName' => $dom->localName,
|
||||
'namespaceURI' => $dom->namespaceURI,
|
||||
'ownerDocument' => new CutStub($dom->ownerDocument),
|
||||
'parentNode' => new CutStub($dom->parentNode),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$a += [
|
||||
'doctype' => $dom->doctype,
|
||||
'implementation' => $dom->implementation,
|
||||
'documentElement' => new CutStub($dom->documentElement),
|
||||
'actualEncoding' => $dom->actualEncoding,
|
||||
'encoding' => $dom->encoding,
|
||||
'xmlEncoding' => $dom->xmlEncoding,
|
||||
'standalone' => $dom->standalone,
|
||||
'xmlStandalone' => $dom->xmlStandalone,
|
||||
'version' => $dom->version,
|
||||
'xmlVersion' => $dom->xmlVersion,
|
||||
'strictErrorChecking' => $dom->strictErrorChecking,
|
||||
'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI,
|
||||
'config' => $dom->config,
|
||||
'formatOutput' => $dom->formatOutput,
|
||||
'validateOnParse' => $dom->validateOnParse,
|
||||
'resolveExternals' => $dom->resolveExternals,
|
||||
'preserveWhiteSpace' => $dom->preserveWhiteSpace,
|
||||
'recover' => $dom->recover,
|
||||
'substituteEntities' => $dom->substituteEntities,
|
||||
];
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||
$formatOutput = $dom->formatOutput;
|
||||
$dom->formatOutput = true;
|
||||
$a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()];
|
||||
$dom->formatOutput = $formatOutput;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'data' => $dom->data,
|
||||
'length' => $dom->length,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'name' => $dom->name,
|
||||
'specified' => $dom->specified,
|
||||
'value' => $dom->value,
|
||||
'ownerElement' => $dom->ownerElement,
|
||||
'schemaTypeInfo' => $dom->schemaTypeInfo,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'tagName' => $dom->tagName,
|
||||
'schemaTypeInfo' => $dom->schemaTypeInfo,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'wholeText' => $dom->wholeText,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'typeName' => $dom->typeName,
|
||||
'typeNamespace' => $dom->typeNamespace,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'severity' => $dom->severity,
|
||||
'message' => $dom->message,
|
||||
'type' => $dom->type,
|
||||
'relatedException' => $dom->relatedException,
|
||||
'related_data' => $dom->related_data,
|
||||
'location' => $dom->location,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'lineNumber' => $dom->lineNumber,
|
||||
'columnNumber' => $dom->columnNumber,
|
||||
'offset' => $dom->offset,
|
||||
'relatedNode' => $dom->relatedNode,
|
||||
'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'name' => $dom->name,
|
||||
'entities' => $dom->entities,
|
||||
'notations' => $dom->notations,
|
||||
'publicId' => $dom->publicId,
|
||||
'systemId' => $dom->systemId,
|
||||
'internalSubset' => $dom->internalSubset,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'publicId' => $dom->publicId,
|
||||
'systemId' => $dom->systemId,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'publicId' => $dom->publicId,
|
||||
'systemId' => $dom->systemId,
|
||||
'notationName' => $dom->notationName,
|
||||
'actualEncoding' => $dom->actualEncoding,
|
||||
'encoding' => $dom->encoding,
|
||||
'version' => $dom->version,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'target' => $dom->target,
|
||||
'data' => $dom->data,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
'document' => $dom->document,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
126
vendor/symfony/var-dumper/Caster/DateCaster.php
vendored
Normal file
126
vendor/symfony/var-dumper/Caster/DateCaster.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts DateTimeInterface related classes to array representation.
|
||||
*
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class DateCaster
|
||||
{
|
||||
private const PERIOD_LIMIT = 3;
|
||||
|
||||
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$location = $d->getTimezone()->getLocation();
|
||||
$fromNow = (new \DateTime())->diff($d);
|
||||
|
||||
$title = $d->format('l, F j, Y')
|
||||
."\n".self::formatInterval($fromNow).' from now'
|
||||
.($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '')
|
||||
;
|
||||
|
||||
unset(
|
||||
$a[Caster::PREFIX_DYNAMIC.'date'],
|
||||
$a[Caster::PREFIX_DYNAMIC.'timezone'],
|
||||
$a[Caster::PREFIX_DYNAMIC.'timezone_type']
|
||||
);
|
||||
$a[$prefix.'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title);
|
||||
|
||||
$stub->class .= $d->format(' @U');
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter)
|
||||
{
|
||||
$now = new \DateTimeImmutable();
|
||||
$numberOfSeconds = $now->add($interval)->getTimestamp() - $now->getTimestamp();
|
||||
$title = number_format($numberOfSeconds, 0, '.', ' ').'s';
|
||||
|
||||
$i = [Caster::PREFIX_VIRTUAL.'interval' => new ConstStub(self::formatInterval($interval), $title)];
|
||||
|
||||
return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a;
|
||||
}
|
||||
|
||||
private static function formatInterval(\DateInterval $i): string
|
||||
{
|
||||
$format = '%R ';
|
||||
|
||||
if (0 === $i->y && 0 === $i->m && ($i->h >= 24 || $i->i >= 60 || $i->s >= 60)) {
|
||||
$i = date_diff($d = new \DateTime(), date_add(clone $d, $i)); // recalculate carry over points
|
||||
$format .= 0 < $i->days ? '%ad ' : '';
|
||||
} else {
|
||||
$format .= ($i->y ? '%yy ' : '').($i->m ? '%mm ' : '').($i->d ? '%dd ' : '');
|
||||
}
|
||||
|
||||
$format .= $i->h || $i->i || $i->s || $i->f ? '%H:%I:'.self::formatSeconds($i->s, substr($i->f, 2)) : '';
|
||||
$format = '%R ' === $format ? '0s' : $format;
|
||||
|
||||
return $i->format(rtrim($format));
|
||||
}
|
||||
|
||||
public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, bool $isNested, int $filter)
|
||||
{
|
||||
$location = $timeZone->getLocation();
|
||||
$formatted = (new \DateTime('now', $timeZone))->format($location ? 'e (P)' : 'P');
|
||||
$title = $location && \extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code']) : '';
|
||||
|
||||
$z = [Caster::PREFIX_VIRTUAL.'timezone' => new ConstStub($formatted, $title)];
|
||||
|
||||
return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a;
|
||||
}
|
||||
|
||||
public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, bool $isNested, int $filter)
|
||||
{
|
||||
$dates = [];
|
||||
foreach (clone $p as $i => $d) {
|
||||
if (self::PERIOD_LIMIT === $i) {
|
||||
$now = new \DateTimeImmutable();
|
||||
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
|
||||
? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u')))
|
||||
: $p->recurrences - $i
|
||||
);
|
||||
break;
|
||||
}
|
||||
$dates[] = sprintf('%s) %s', $i + 1, self::formatDateTime($d));
|
||||
}
|
||||
|
||||
$period = sprintf(
|
||||
'every %s, from %s (%s) %s',
|
||||
self::formatInterval($p->getDateInterval()),
|
||||
self::formatDateTime($p->getStartDate()),
|
||||
$p->include_start_date ? 'included' : 'excluded',
|
||||
($end = $p->getEndDate()) ? 'to '.self::formatDateTime($end) : 'recurring '.$p->recurrences.' time/s'
|
||||
);
|
||||
|
||||
$p = [Caster::PREFIX_VIRTUAL.'period' => new ConstStub($period, implode("\n", $dates))];
|
||||
|
||||
return $filter & Caster::EXCLUDE_VERBOSE ? $p : $p + $a;
|
||||
}
|
||||
|
||||
private static function formatDateTime(\DateTimeInterface $d, string $extra = ''): string
|
||||
{
|
||||
return $d->format('Y-m-d H:i:'.self::formatSeconds($d->format('s'), $d->format('u')).$extra);
|
||||
}
|
||||
|
||||
private static function formatSeconds(string $s, string $us): string
|
||||
{
|
||||
return sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us));
|
||||
}
|
||||
}
|
||||
62
vendor/symfony/var-dumper/Caster/DoctrineCaster.php
vendored
Normal file
62
vendor/symfony/var-dumper/Caster/DoctrineCaster.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Doctrine\Common\Proxy\Proxy as CommonProxy;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\ORM\Proxy\Proxy as OrmProxy;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Doctrine related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class DoctrineCaster
|
||||
{
|
||||
public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
foreach (['__cloner__', '__initializer__'] as $k) {
|
||||
if (\array_key_exists($k, $a)) {
|
||||
unset($a[$k]);
|
||||
++$stub->cut;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
foreach (['_entityPersister', '_identifier'] as $k) {
|
||||
if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) {
|
||||
unset($a[$k]);
|
||||
++$stub->cut;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
foreach (['snapshot', 'association', 'typeClass'] as $k) {
|
||||
if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) {
|
||||
$a[$k] = new CutStub($a[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
70
vendor/symfony/var-dumper/Caster/DsCaster.php
vendored
Normal file
70
vendor/symfony/var-dumper/Caster/DsCaster.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Ds\Collection;
|
||||
use Ds\Map;
|
||||
use Ds\Pair;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Ds extension classes to array representation.
|
||||
*
|
||||
* @author Jáchym Toušek <enumag@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class DsCaster
|
||||
{
|
||||
public static function castCollection(Collection $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'count'] = $c->count();
|
||||
$a[Caster::PREFIX_VIRTUAL.'capacity'] = $c->capacity();
|
||||
|
||||
if (!$c instanceof Map) {
|
||||
$a += $c->toArray();
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMap(Map $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
foreach ($c as $k => $v) {
|
||||
$a[] = new DsPairStub($k, $v);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPair(Pair $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
foreach ($c->toArray() as $k => $v) {
|
||||
$a[Caster::PREFIX_VIRTUAL.$k] = $v;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPairStub(DsPairStub $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
if ($isNested) {
|
||||
$stub->class = Pair::class;
|
||||
$stub->value = null;
|
||||
$stub->handle = 0;
|
||||
|
||||
$a = $c->value;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
28
vendor/symfony/var-dumper/Caster/DsPairStub.php
vendored
Normal file
28
vendor/symfony/var-dumper/Caster/DsPairStub.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class DsPairStub extends Stub
|
||||
{
|
||||
public function __construct($key, $value)
|
||||
{
|
||||
$this->value = [
|
||||
Caster::PREFIX_VIRTUAL.'key' => $key,
|
||||
Caster::PREFIX_VIRTUAL.'value' => $value,
|
||||
];
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/var-dumper/Caster/EnumStub.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/EnumStub.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents an enumeration of values.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class EnumStub extends Stub
|
||||
{
|
||||
public $dumpKeys = true;
|
||||
|
||||
public function __construct(array $values, bool $dumpKeys = true)
|
||||
{
|
||||
$this->value = $values;
|
||||
$this->dumpKeys = $dumpKeys;
|
||||
}
|
||||
}
|
||||
383
vendor/symfony/var-dumper/Caster/ExceptionCaster.php
vendored
Normal file
383
vendor/symfony/var-dumper/Caster/ExceptionCaster.php
vendored
Normal file
@@ -0,0 +1,383 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
|
||||
|
||||
/**
|
||||
* Casts common Exception classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ExceptionCaster
|
||||
{
|
||||
public static $srcContext = 1;
|
||||
public static $traceArgs = true;
|
||||
public static $errorTypes = [
|
||||
E_DEPRECATED => 'E_DEPRECATED',
|
||||
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
||||
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
||||
E_ERROR => 'E_ERROR',
|
||||
E_WARNING => 'E_WARNING',
|
||||
E_PARSE => 'E_PARSE',
|
||||
E_NOTICE => 'E_NOTICE',
|
||||
E_CORE_ERROR => 'E_CORE_ERROR',
|
||||
E_CORE_WARNING => 'E_CORE_WARNING',
|
||||
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
|
||||
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
||||
E_USER_ERROR => 'E_USER_ERROR',
|
||||
E_USER_WARNING => 'E_USER_WARNING',
|
||||
E_USER_NOTICE => 'E_USER_NOTICE',
|
||||
E_STRICT => 'E_STRICT',
|
||||
];
|
||||
|
||||
private static $framesCache = [];
|
||||
|
||||
public static function castError(\Error $e, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter);
|
||||
}
|
||||
|
||||
public static function castException(\Exception $e, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter);
|
||||
}
|
||||
|
||||
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) {
|
||||
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$trace = Caster::PREFIX_VIRTUAL.'trace';
|
||||
$prefix = Caster::PREFIX_PROTECTED;
|
||||
$xPrefix = "\0Exception\0";
|
||||
|
||||
if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) {
|
||||
$b = (array) $a[$xPrefix.'previous'];
|
||||
$class = \get_class($a[$xPrefix.'previous']);
|
||||
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
|
||||
self::traceUnshift($b[$xPrefix.'trace'], $class, $b[$prefix.'file'], $b[$prefix.'line']);
|
||||
$a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value));
|
||||
}
|
||||
|
||||
unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$sPrefix = "\0".SilencedErrorContext::class."\0";
|
||||
|
||||
if (!isset($a[$s = $sPrefix.'severity'])) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
if (isset(self::$errorTypes[$a[$s]])) {
|
||||
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
|
||||
}
|
||||
|
||||
$trace = [[
|
||||
'file' => $a[$sPrefix.'file'],
|
||||
'line' => $a[$sPrefix.'line'],
|
||||
]];
|
||||
|
||||
if (isset($a[$sPrefix.'trace'])) {
|
||||
$trace = array_merge($trace, $a[$sPrefix.'trace']);
|
||||
}
|
||||
|
||||
unset($a[$sPrefix.'file'], $a[$sPrefix.'line'], $a[$sPrefix.'trace']);
|
||||
$a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if (!$isNested) {
|
||||
return $a;
|
||||
}
|
||||
$stub->class = '';
|
||||
$stub->handle = 0;
|
||||
$frames = $trace->value;
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a = [];
|
||||
$j = \count($frames);
|
||||
if (0 > $i = $trace->sliceOffset) {
|
||||
$i = max(0, $j + $i);
|
||||
}
|
||||
if (!isset($trace->value[$i])) {
|
||||
return [];
|
||||
}
|
||||
$lastCall = isset($frames[$i]['function']) ? (isset($frames[$i]['class']) ? $frames[0]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : '';
|
||||
$frames[] = ['function' => ''];
|
||||
$collapse = false;
|
||||
|
||||
for ($j += $trace->numberingOffset - $i++; isset($frames[$i]); ++$i, --$j) {
|
||||
$f = $frames[$i];
|
||||
$call = isset($f['function']) ? (isset($f['class']) ? $f['class'].$f['type'] : '').$f['function'] : '???';
|
||||
|
||||
$frame = new FrameStub(
|
||||
[
|
||||
'object' => isset($f['object']) ? $f['object'] : null,
|
||||
'class' => isset($f['class']) ? $f['class'] : null,
|
||||
'type' => isset($f['type']) ? $f['type'] : null,
|
||||
'function' => isset($f['function']) ? $f['function'] : null,
|
||||
] + $frames[$i - 1],
|
||||
false,
|
||||
true
|
||||
);
|
||||
$f = self::castFrameStub($frame, [], $frame, true);
|
||||
if (isset($f[$prefix.'src'])) {
|
||||
foreach ($f[$prefix.'src']->value as $label => $frame) {
|
||||
if (0 === strpos($label, "\0~collapse=0")) {
|
||||
if ($collapse) {
|
||||
$label = substr_replace($label, '1', 11, 1);
|
||||
} else {
|
||||
$collapse = true;
|
||||
}
|
||||
}
|
||||
$label = substr_replace($label, "title=Stack level $j.&", 2, 0);
|
||||
}
|
||||
$f = $frames[$i - 1];
|
||||
if ($trace->keepArgs && !empty($f['args']) && $frame instanceof EnumStub) {
|
||||
$frame->value['arguments'] = new ArgsStub($f['args'], isset($f['function']) ? $f['function'] : null, isset($f['class']) ? $f['class'] : null);
|
||||
}
|
||||
} elseif ('???' !== $lastCall) {
|
||||
$label = new ClassStub($lastCall);
|
||||
if (isset($label->attr['ellipsis'])) {
|
||||
$label->attr['ellipsis'] += 2;
|
||||
$label = substr_replace($prefix, "ellipsis-type=class&ellipsis={$label->attr['ellipsis']}&ellipsis-tail=1&title=Stack level $j.", 2, 0).$label->value.'()';
|
||||
} else {
|
||||
$label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$label->value.'()';
|
||||
}
|
||||
} else {
|
||||
$label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$lastCall;
|
||||
}
|
||||
$a[substr_replace($label, sprintf('separator=%s&', $frame instanceof EnumStub ? ' ' : ':'), 2, 0)] = $frame;
|
||||
|
||||
$lastCall = $call;
|
||||
}
|
||||
if (null !== $trace->sliceLength) {
|
||||
$a = \array_slice($a, 0, $trace->sliceLength, true);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if (!$isNested) {
|
||||
return $a;
|
||||
}
|
||||
$f = $frame->value;
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if (isset($f['file'], $f['line'])) {
|
||||
$cacheKey = $f;
|
||||
unset($cacheKey['object'], $cacheKey['args']);
|
||||
$cacheKey[] = self::$srcContext;
|
||||
$cacheKey = implode('-', $cacheKey);
|
||||
|
||||
if (isset(self::$framesCache[$cacheKey])) {
|
||||
$a[$prefix.'src'] = self::$framesCache[$cacheKey];
|
||||
} else {
|
||||
if (preg_match('/\((\d+)\)(?:\([\da-f]{32}\))? : (?:eval\(\)\'d code|runtime-created function)$/', $f['file'], $match)) {
|
||||
$f['file'] = substr($f['file'], 0, -\strlen($match[0]));
|
||||
$f['line'] = (int) $match[1];
|
||||
}
|
||||
$src = $f['line'];
|
||||
$srcKey = $f['file'];
|
||||
$ellipsis = new LinkStub($srcKey, 0);
|
||||
$srcAttr = 'collapse='.(int) $ellipsis->inVendor;
|
||||
$ellipsisTail = isset($ellipsis->attr['ellipsis-tail']) ? $ellipsis->attr['ellipsis-tail'] : 0;
|
||||
$ellipsis = isset($ellipsis->attr['ellipsis']) ? $ellipsis->attr['ellipsis'] : 0;
|
||||
|
||||
if (file_exists($f['file']) && 0 <= self::$srcContext) {
|
||||
if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) {
|
||||
$template = isset($f['object']) ? $f['object'] : unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class']));
|
||||
|
||||
$ellipsis = 0;
|
||||
$templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : '');
|
||||
$templateInfo = $template->getDebugInfo();
|
||||
if (isset($templateInfo[$f['line']])) {
|
||||
if (!method_exists($template, 'getSourceContext') || !file_exists($templatePath = $template->getSourceContext()->getPath())) {
|
||||
$templatePath = null;
|
||||
}
|
||||
if ($templateSrc) {
|
||||
$src = self::extractSource($templateSrc, $templateInfo[$f['line']], self::$srcContext, 'twig', $templatePath, $f);
|
||||
$srcKey = ($templatePath ?: $template->getTemplateName()).':'.$templateInfo[$f['line']];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($srcKey == $f['file']) {
|
||||
$src = self::extractSource(file_get_contents($f['file']), $f['line'], self::$srcContext, 'php', $f['file'], $f);
|
||||
$srcKey .= ':'.$f['line'];
|
||||
if ($ellipsis) {
|
||||
$ellipsis += 1 + \strlen($f['line']);
|
||||
}
|
||||
}
|
||||
$srcAttr .= sprintf('&separator= &file=%s&line=%d', rawurlencode($f['file']), $f['line']);
|
||||
} else {
|
||||
$srcAttr .= '&separator=:';
|
||||
}
|
||||
$srcAttr .= $ellipsis ? '&ellipsis-type=path&ellipsis='.$ellipsis.'&ellipsis-tail='.$ellipsisTail : '';
|
||||
self::$framesCache[$cacheKey] = $a[$prefix.'src'] = new EnumStub(["\0~$srcAttr\0$srcKey" => $src]);
|
||||
}
|
||||
}
|
||||
|
||||
unset($a[$prefix.'args'], $a[$prefix.'line'], $a[$prefix.'file']);
|
||||
if ($frame->inTraceStub) {
|
||||
unset($a[$prefix.'class'], $a[$prefix.'type'], $a[$prefix.'function']);
|
||||
}
|
||||
foreach ($a as $k => $v) {
|
||||
if (!$v) {
|
||||
unset($a[$k]);
|
||||
}
|
||||
}
|
||||
if ($frame->keepArgs && !empty($f['args'])) {
|
||||
$a[$prefix.'arguments'] = new ArgsStub($f['args'], $f['function'], $f['class']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function filterExceptionArray(string $xClass, array $a, string $xPrefix, int $filter): array
|
||||
{
|
||||
if (isset($a[$xPrefix.'trace'])) {
|
||||
$trace = $a[$xPrefix.'trace'];
|
||||
unset($a[$xPrefix.'trace']); // Ensures the trace is always last
|
||||
} else {
|
||||
$trace = [];
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && $trace) {
|
||||
if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) {
|
||||
self::traceUnshift($trace, $xClass, $a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']);
|
||||
}
|
||||
$a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs);
|
||||
}
|
||||
if (empty($a[$xPrefix.'previous'])) {
|
||||
unset($a[$xPrefix.'previous']);
|
||||
}
|
||||
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
|
||||
|
||||
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
|
||||
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
|
||||
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
|
||||
}, $a[Caster::PREFIX_PROTECTED.'message']);
|
||||
}
|
||||
|
||||
if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) {
|
||||
$a[Caster::PREFIX_PROTECTED.'file'] = new LinkStub($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function traceUnshift(array &$trace, ?string $class, string $file, int $line): void
|
||||
{
|
||||
if (isset($trace[0]['file'], $trace[0]['line']) && $trace[0]['file'] === $file && $trace[0]['line'] === $line) {
|
||||
return;
|
||||
}
|
||||
array_unshift($trace, [
|
||||
'function' => $class ? 'new '.$class : null,
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
]);
|
||||
}
|
||||
|
||||
private static function extractSource(string $srcLines, int $line, int $srcContext, string $lang, ?string $file, array $frame): EnumStub
|
||||
{
|
||||
$srcLines = explode("\n", $srcLines);
|
||||
$src = [];
|
||||
|
||||
for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) {
|
||||
$src[] = (isset($srcLines[$i]) ? $srcLines[$i] : '')."\n";
|
||||
}
|
||||
|
||||
if ($frame['function'] ?? false) {
|
||||
$stub = new CutStub(new \stdClass());
|
||||
$stub->class = (isset($frame['class']) ? $frame['class'].$frame['type'] : '').$frame['function'];
|
||||
$stub->type = Stub::TYPE_OBJECT;
|
||||
$stub->attr['cut_hash'] = true;
|
||||
$stub->attr['file'] = $frame['file'];
|
||||
$stub->attr['line'] = $frame['line'];
|
||||
|
||||
try {
|
||||
$caller = isset($frame['class']) ? new \ReflectionMethod($frame['class'], $frame['function']) : new \ReflectionFunction($frame['function']);
|
||||
$stub->class .= ReflectionCaster::getSignature(ReflectionCaster::castFunctionAbstract($caller, [], $stub, true, Caster::EXCLUDE_VERBOSE));
|
||||
|
||||
if ($f = $caller->getFileName()) {
|
||||
$stub->attr['file'] = $f;
|
||||
$stub->attr['line'] = $caller->getStartLine();
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
// ignore fake class/function
|
||||
}
|
||||
|
||||
$srcLines = ["\0~separator=\0" => $stub];
|
||||
} else {
|
||||
$stub = null;
|
||||
$srcLines = [];
|
||||
}
|
||||
|
||||
$ltrim = 0;
|
||||
do {
|
||||
$pad = null;
|
||||
for ($i = $srcContext << 1; $i >= 0; --$i) {
|
||||
if (isset($src[$i][$ltrim]) && "\r" !== ($c = $src[$i][$ltrim]) && "\n" !== $c) {
|
||||
if (null === $pad) {
|
||||
$pad = $c;
|
||||
}
|
||||
if ((' ' !== $c && "\t" !== $c) || $pad !== $c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
++$ltrim;
|
||||
} while (0 > $i && null !== $pad);
|
||||
|
||||
--$ltrim;
|
||||
|
||||
foreach ($src as $i => $c) {
|
||||
if ($ltrim) {
|
||||
$c = isset($c[$ltrim]) && "\r" !== $c[$ltrim] ? substr($c, $ltrim) : ltrim($c, " \t");
|
||||
}
|
||||
$c = substr($c, 0, -1);
|
||||
if ($i !== $srcContext) {
|
||||
$c = new ConstStub('default', $c);
|
||||
} else {
|
||||
$c = new ConstStub($c, $stub ? 'in '.$stub->class : '');
|
||||
if (null !== $file) {
|
||||
$c->attr['file'] = $file;
|
||||
$c->attr['line'] = $line;
|
||||
}
|
||||
}
|
||||
$c->attr['lang'] = $lang;
|
||||
$srcLines[sprintf("\0~separator=› &%d\0", $i + $line - $srcContext)] = $c;
|
||||
}
|
||||
|
||||
return new EnumStub($srcLines);
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/var-dumper/Caster/FrameStub.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/FrameStub.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Represents a single backtrace frame as returned by debug_backtrace() or Exception->getTrace().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class FrameStub extends EnumStub
|
||||
{
|
||||
public $keepArgs;
|
||||
public $inTraceStub;
|
||||
|
||||
public function __construct(array $frame, bool $keepArgs = true, bool $inTraceStub = false)
|
||||
{
|
||||
$this->value = $frame;
|
||||
$this->keepArgs = $keepArgs;
|
||||
$this->inTraceStub = $inTraceStub;
|
||||
}
|
||||
}
|
||||
32
vendor/symfony/var-dumper/Caster/GmpCaster.php
vendored
Normal file
32
vendor/symfony/var-dumper/Caster/GmpCaster.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts GMP objects to array representation.
|
||||
*
|
||||
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class GmpCaster
|
||||
{
|
||||
public static function castGmp(\GMP $gmp, array $a, Stub $stub, bool $isNested, int $filter): array
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'value'] = new ConstStub(gmp_strval($gmp), gmp_strval($gmp));
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
37
vendor/symfony/var-dumper/Caster/ImagineCaster.php
vendored
Normal file
37
vendor/symfony/var-dumper/Caster/ImagineCaster.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Imagine\Image\ImageInterface;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
final class ImagineCaster
|
||||
{
|
||||
public static function castImage(ImageInterface $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
$imgData = $c->get('png');
|
||||
if (\strlen($imgData) > 1 * 1000 * 1000) {
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'image' => new ConstStub($c->getSize()),
|
||||
];
|
||||
} else {
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'image' => new ImgStub($imgData, 'image/png', $c->getSize()),
|
||||
];
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
26
vendor/symfony/var-dumper/Caster/ImgStub.php
vendored
Normal file
26
vendor/symfony/var-dumper/Caster/ImgStub.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class ImgStub extends ConstStub
|
||||
{
|
||||
public function __construct(string $data, string $contentType, string $size)
|
||||
{
|
||||
$this->value = '';
|
||||
$this->attr['img-data'] = $data;
|
||||
$this->attr['img-size'] = $size;
|
||||
$this->attr['content-type'] = $contentType;
|
||||
}
|
||||
}
|
||||
172
vendor/symfony/var-dumper/Caster/IntlCaster.php
vendored
Normal file
172
vendor/symfony/var-dumper/Caster/IntlCaster.php
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class IntlCaster
|
||||
{
|
||||
public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
|
||||
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
|
||||
];
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
|
||||
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
|
||||
];
|
||||
|
||||
if ($filter & Caster::EXCLUDE_VERBOSE) {
|
||||
$stub->cut += 3;
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub(
|
||||
[
|
||||
'PARSE_INT_ONLY' => $c->getAttribute(\NumberFormatter::PARSE_INT_ONLY),
|
||||
'GROUPING_USED' => $c->getAttribute(\NumberFormatter::GROUPING_USED),
|
||||
'DECIMAL_ALWAYS_SHOWN' => $c->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN),
|
||||
'MAX_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS),
|
||||
'MIN_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS),
|
||||
'INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::INTEGER_DIGITS),
|
||||
'MAX_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS),
|
||||
'MIN_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS),
|
||||
'FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::FRACTION_DIGITS),
|
||||
'MULTIPLIER' => $c->getAttribute(\NumberFormatter::MULTIPLIER),
|
||||
'GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::GROUPING_SIZE),
|
||||
'ROUNDING_MODE' => $c->getAttribute(\NumberFormatter::ROUNDING_MODE),
|
||||
'ROUNDING_INCREMENT' => $c->getAttribute(\NumberFormatter::ROUNDING_INCREMENT),
|
||||
'FORMAT_WIDTH' => $c->getAttribute(\NumberFormatter::FORMAT_WIDTH),
|
||||
'PADDING_POSITION' => $c->getAttribute(\NumberFormatter::PADDING_POSITION),
|
||||
'SECONDARY_GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE),
|
||||
'SIGNIFICANT_DIGITS_USED' => $c->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED),
|
||||
'MIN_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS),
|
||||
'MAX_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS),
|
||||
'LENIENT_PARSE' => $c->getAttribute(\NumberFormatter::LENIENT_PARSE),
|
||||
]
|
||||
),
|
||||
Caster::PREFIX_VIRTUAL.'text_attributes' => new EnumStub(
|
||||
[
|
||||
'POSITIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX),
|
||||
'POSITIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX),
|
||||
'NEGATIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX),
|
||||
'NEGATIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX),
|
||||
'PADDING_CHARACTER' => $c->getTextAttribute(\NumberFormatter::PADDING_CHARACTER),
|
||||
'CURRENCY_CODE' => $c->getTextAttribute(\NumberFormatter::CURRENCY_CODE),
|
||||
'DEFAULT_RULESET' => $c->getTextAttribute(\NumberFormatter::DEFAULT_RULESET),
|
||||
'PUBLIC_RULESETS' => $c->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS),
|
||||
]
|
||||
),
|
||||
Caster::PREFIX_VIRTUAL.'symbols' => new EnumStub(
|
||||
[
|
||||
'DECIMAL_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL),
|
||||
'GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL),
|
||||
'PATTERN_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL),
|
||||
'PERCENT_SYMBOL' => $c->getSymbol(\NumberFormatter::PERCENT_SYMBOL),
|
||||
'ZERO_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL),
|
||||
'DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::DIGIT_SYMBOL),
|
||||
'MINUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL),
|
||||
'PLUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL),
|
||||
'CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::CURRENCY_SYMBOL),
|
||||
'INTL_CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL),
|
||||
'MONETARY_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL),
|
||||
'EXPONENTIAL_SYMBOL' => $c->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL),
|
||||
'PERMILL_SYMBOL' => $c->getSymbol(\NumberFormatter::PERMILL_SYMBOL),
|
||||
'PAD_ESCAPE_SYMBOL' => $c->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL),
|
||||
'INFINITY_SYMBOL' => $c->getSymbol(\NumberFormatter::INFINITY_SYMBOL),
|
||||
'NAN_SYMBOL' => $c->getSymbol(\NumberFormatter::NAN_SYMBOL),
|
||||
'SIGNIFICANT_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL),
|
||||
'MONETARY_GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL),
|
||||
]
|
||||
),
|
||||
];
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'display_name' => $c->getDisplayName(),
|
||||
Caster::PREFIX_VIRTUAL.'id' => $c->getID(),
|
||||
Caster::PREFIX_VIRTUAL.'raw_offset' => $c->getRawOffset(),
|
||||
];
|
||||
|
||||
if ($c->useDaylightTime()) {
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'dst_savings' => $c->getDSTSavings(),
|
||||
];
|
||||
}
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'type' => $c->getType(),
|
||||
Caster::PREFIX_VIRTUAL.'first_day_of_week' => $c->getFirstDayOfWeek(),
|
||||
Caster::PREFIX_VIRTUAL.'minimal_days_in_first_week' => $c->getMinimalDaysInFirstWeek(),
|
||||
Caster::PREFIX_VIRTUAL.'repeated_wall_time_option' => $c->getRepeatedWallTimeOption(),
|
||||
Caster::PREFIX_VIRTUAL.'skipped_wall_time_option' => $c->getSkippedWallTimeOption(),
|
||||
Caster::PREFIX_VIRTUAL.'time' => $c->getTime(),
|
||||
Caster::PREFIX_VIRTUAL.'in_daylight_time' => $c->inDaylightTime(),
|
||||
Caster::PREFIX_VIRTUAL.'is_lenient' => $c->isLenient(),
|
||||
Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(),
|
||||
];
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
|
||||
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
|
||||
Caster::PREFIX_VIRTUAL.'calendar' => $c->getCalendar(),
|
||||
Caster::PREFIX_VIRTUAL.'time_zone_id' => $c->getTimeZoneId(),
|
||||
Caster::PREFIX_VIRTUAL.'time_type' => $c->getTimeType(),
|
||||
Caster::PREFIX_VIRTUAL.'date_type' => $c->getDateType(),
|
||||
Caster::PREFIX_VIRTUAL.'calendar_object' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getCalendarObject()) : $c->getCalendarObject(),
|
||||
Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(),
|
||||
];
|
||||
|
||||
return self::castError($c, $a);
|
||||
}
|
||||
|
||||
private static function castError(object $c, array $a): array
|
||||
{
|
||||
if ($errorCode = $c->getErrorCode()) {
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'error_code' => $errorCode,
|
||||
Caster::PREFIX_VIRTUAL.'error_message' => $c->getErrorMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
108
vendor/symfony/var-dumper/Caster/LinkStub.php
vendored
Normal file
108
vendor/symfony/var-dumper/Caster/LinkStub.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
/**
|
||||
* Represents a file or a URL.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class LinkStub extends ConstStub
|
||||
{
|
||||
public $inVendor = false;
|
||||
|
||||
private static $vendorRoots;
|
||||
private static $composerRoots;
|
||||
|
||||
public function __construct($label, int $line = 0, $href = null)
|
||||
{
|
||||
$this->value = $label;
|
||||
|
||||
if (null === $href) {
|
||||
$href = $label;
|
||||
}
|
||||
if (!\is_string($href)) {
|
||||
return;
|
||||
}
|
||||
if (0 === strpos($href, 'file://')) {
|
||||
if ($href === $label) {
|
||||
$label = substr($label, 7);
|
||||
}
|
||||
$href = substr($href, 7);
|
||||
} elseif (false !== strpos($href, '://')) {
|
||||
$this->attr['href'] = $href;
|
||||
|
||||
return;
|
||||
}
|
||||
if (!file_exists($href)) {
|
||||
return;
|
||||
}
|
||||
if ($line) {
|
||||
$this->attr['line'] = $line;
|
||||
}
|
||||
if ($label !== $this->attr['file'] = realpath($href) ?: $href) {
|
||||
return;
|
||||
}
|
||||
if ($composerRoot = $this->getComposerRoot($href, $this->inVendor)) {
|
||||
$this->attr['ellipsis'] = \strlen($href) - \strlen($composerRoot) + 1;
|
||||
$this->attr['ellipsis-type'] = 'path';
|
||||
$this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + \strlen(implode('', \array_slice(explode(\DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0);
|
||||
} elseif (3 < \count($ellipsis = explode(\DIRECTORY_SEPARATOR, $href))) {
|
||||
$this->attr['ellipsis'] = 2 + \strlen(implode('', \array_slice($ellipsis, -2)));
|
||||
$this->attr['ellipsis-type'] = 'path';
|
||||
$this->attr['ellipsis-tail'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private function getComposerRoot(string $file, bool &$inVendor)
|
||||
{
|
||||
if (null === self::$vendorRoots) {
|
||||
self::$vendorRoots = [];
|
||||
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$v = \dirname($r->getFileName(), 2);
|
||||
if (file_exists($v.'/composer/installed.json')) {
|
||||
self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$inVendor = false;
|
||||
|
||||
if (isset(self::$composerRoots[$dir = \dirname($file)])) {
|
||||
return self::$composerRoots[$dir];
|
||||
}
|
||||
|
||||
foreach (self::$vendorRoots as $root) {
|
||||
if ($inVendor = 0 === strpos($file, $root)) {
|
||||
return $root;
|
||||
}
|
||||
}
|
||||
|
||||
$parent = $dir;
|
||||
while (!@file_exists($parent.'/composer.json')) {
|
||||
if (!@file_exists($parent)) {
|
||||
// open_basedir restriction in effect
|
||||
break;
|
||||
}
|
||||
if ($parent === \dirname($parent)) {
|
||||
return self::$composerRoots[$dir] = false;
|
||||
}
|
||||
|
||||
$parent = \dirname($parent);
|
||||
}
|
||||
|
||||
return self::$composerRoots[$dir] = $parent.\DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
81
vendor/symfony/var-dumper/Caster/MemcachedCaster.php
vendored
Normal file
81
vendor/symfony/var-dumper/Caster/MemcachedCaster.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class MemcachedCaster
|
||||
{
|
||||
private static $optionConstants;
|
||||
private static $defaultOptions;
|
||||
|
||||
public static function castMemcached(\Memcached $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(),
|
||||
Caster::PREFIX_VIRTUAL.'options' => new EnumStub(
|
||||
self::getNonDefaultOptions($c)
|
||||
),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function getNonDefaultOptions(\Memcached $c): array
|
||||
{
|
||||
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
|
||||
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
||||
|
||||
$nonDefaultOptions = [];
|
||||
foreach (self::$optionConstants as $constantKey => $value) {
|
||||
if (self::$defaultOptions[$constantKey] !== $option = $c->getOption($value)) {
|
||||
$nonDefaultOptions[$constantKey] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
return $nonDefaultOptions;
|
||||
}
|
||||
|
||||
private static function discoverDefaultOptions(): array
|
||||
{
|
||||
$defaultMemcached = new \Memcached();
|
||||
$defaultMemcached->addServer('127.0.0.1', 11211);
|
||||
|
||||
$defaultOptions = [];
|
||||
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
||||
|
||||
foreach (self::$optionConstants as $constantKey => $value) {
|
||||
$defaultOptions[$constantKey] = $defaultMemcached->getOption($value);
|
||||
}
|
||||
|
||||
return $defaultOptions;
|
||||
}
|
||||
|
||||
private static function getOptionConstants(): array
|
||||
{
|
||||
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
|
||||
|
||||
$optionConstants = [];
|
||||
foreach ($reflectedMemcached->getConstants() as $constantKey => $value) {
|
||||
if (0 === strpos($constantKey, 'OPT_')) {
|
||||
$optionConstants[$constantKey] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $optionConstants;
|
||||
}
|
||||
}
|
||||
122
vendor/symfony/var-dumper/Caster/PdoCaster.php
vendored
Normal file
122
vendor/symfony/var-dumper/Caster/PdoCaster.php
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts PDO related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class PdoCaster
|
||||
{
|
||||
private static $pdoAttributes = [
|
||||
'CASE' => [
|
||||
\PDO::CASE_LOWER => 'LOWER',
|
||||
\PDO::CASE_NATURAL => 'NATURAL',
|
||||
\PDO::CASE_UPPER => 'UPPER',
|
||||
],
|
||||
'ERRMODE' => [
|
||||
\PDO::ERRMODE_SILENT => 'SILENT',
|
||||
\PDO::ERRMODE_WARNING => 'WARNING',
|
||||
\PDO::ERRMODE_EXCEPTION => 'EXCEPTION',
|
||||
],
|
||||
'TIMEOUT',
|
||||
'PREFETCH',
|
||||
'AUTOCOMMIT',
|
||||
'PERSISTENT',
|
||||
'DRIVER_NAME',
|
||||
'SERVER_INFO',
|
||||
'ORACLE_NULLS' => [
|
||||
\PDO::NULL_NATURAL => 'NATURAL',
|
||||
\PDO::NULL_EMPTY_STRING => 'EMPTY_STRING',
|
||||
\PDO::NULL_TO_STRING => 'TO_STRING',
|
||||
],
|
||||
'CLIENT_VERSION',
|
||||
'SERVER_VERSION',
|
||||
'STATEMENT_CLASS',
|
||||
'EMULATE_PREPARES',
|
||||
'CONNECTION_STATUS',
|
||||
'STRINGIFY_FETCHES',
|
||||
'DEFAULT_FETCH_MODE' => [
|
||||
\PDO::FETCH_ASSOC => 'ASSOC',
|
||||
\PDO::FETCH_BOTH => 'BOTH',
|
||||
\PDO::FETCH_LAZY => 'LAZY',
|
||||
\PDO::FETCH_NUM => 'NUM',
|
||||
\PDO::FETCH_OBJ => 'OBJ',
|
||||
],
|
||||
];
|
||||
|
||||
public static function castPdo(\PDO $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$attr = [];
|
||||
$errmode = $c->getAttribute(\PDO::ATTR_ERRMODE);
|
||||
$c->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
foreach (self::$pdoAttributes as $k => $v) {
|
||||
if (!isset($k[0])) {
|
||||
$k = $v;
|
||||
$v = [];
|
||||
}
|
||||
|
||||
try {
|
||||
$attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(\constant('PDO::ATTR_'.$k));
|
||||
if ($v && isset($v[$attr[$k]])) {
|
||||
$attr[$k] = new ConstStub($v[$attr[$k]], $attr[$k]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
if (isset($attr[$k = 'STATEMENT_CLASS'][1])) {
|
||||
if ($attr[$k][1]) {
|
||||
$attr[$k][1] = new ArgsStub($attr[$k][1], '__construct', $attr[$k][0]);
|
||||
}
|
||||
$attr[$k][0] = new ClassStub($attr[$k][0]);
|
||||
}
|
||||
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$a += [
|
||||
$prefix.'inTransaction' => method_exists($c, 'inTransaction'),
|
||||
$prefix.'errorInfo' => $c->errorInfo(),
|
||||
$prefix.'attributes' => new EnumStub($attr),
|
||||
];
|
||||
|
||||
if ($a[$prefix.'inTransaction']) {
|
||||
$a[$prefix.'inTransaction'] = $c->inTransaction();
|
||||
} else {
|
||||
unset($a[$prefix.'inTransaction']);
|
||||
}
|
||||
|
||||
if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) {
|
||||
unset($a[$prefix.'errorInfo']);
|
||||
}
|
||||
|
||||
$c->setAttribute(\PDO::ATTR_ERRMODE, $errmode);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$a[$prefix.'errorInfo'] = $c->errorInfo();
|
||||
|
||||
if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) {
|
||||
unset($a[$prefix.'errorInfo']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
156
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
Normal file
156
vendor/symfony/var-dumper/Caster/PgSqlCaster.php
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts pqsql resources to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class PgSqlCaster
|
||||
{
|
||||
private static $paramCodes = [
|
||||
'server_encoding',
|
||||
'client_encoding',
|
||||
'is_superuser',
|
||||
'session_authorization',
|
||||
'DateStyle',
|
||||
'TimeZone',
|
||||
'IntervalStyle',
|
||||
'integer_datetimes',
|
||||
'application_name',
|
||||
'standard_conforming_strings',
|
||||
];
|
||||
|
||||
private static $transactionStatus = [
|
||||
PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE',
|
||||
PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE',
|
||||
PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS',
|
||||
PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR',
|
||||
PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN',
|
||||
];
|
||||
|
||||
private static $resultStatus = [
|
||||
PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY',
|
||||
PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK',
|
||||
PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK',
|
||||
PGSQL_COPY_OUT => 'PGSQL_COPY_OUT',
|
||||
PGSQL_COPY_IN => 'PGSQL_COPY_IN',
|
||||
PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE',
|
||||
PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR',
|
||||
PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR',
|
||||
];
|
||||
|
||||
private static $diagCodes = [
|
||||
'severity' => PGSQL_DIAG_SEVERITY,
|
||||
'sqlstate' => PGSQL_DIAG_SQLSTATE,
|
||||
'message' => PGSQL_DIAG_MESSAGE_PRIMARY,
|
||||
'detail' => PGSQL_DIAG_MESSAGE_DETAIL,
|
||||
'hint' => PGSQL_DIAG_MESSAGE_HINT,
|
||||
'statement position' => PGSQL_DIAG_STATEMENT_POSITION,
|
||||
'internal position' => PGSQL_DIAG_INTERNAL_POSITION,
|
||||
'internal query' => PGSQL_DIAG_INTERNAL_QUERY,
|
||||
'context' => PGSQL_DIAG_CONTEXT,
|
||||
'file' => PGSQL_DIAG_SOURCE_FILE,
|
||||
'line' => PGSQL_DIAG_SOURCE_LINE,
|
||||
'function' => PGSQL_DIAG_SOURCE_FUNCTION,
|
||||
];
|
||||
|
||||
public static function castLargeObject($lo, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a['seek position'] = pg_lo_tell($lo);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castLink($link, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a['status'] = pg_connection_status($link);
|
||||
$a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']);
|
||||
$a['busy'] = pg_connection_busy($link);
|
||||
|
||||
$a['transaction'] = pg_transaction_status($link);
|
||||
if (isset(self::$transactionStatus[$a['transaction']])) {
|
||||
$a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']);
|
||||
}
|
||||
|
||||
$a['pid'] = pg_get_pid($link);
|
||||
$a['last error'] = pg_last_error($link);
|
||||
$a['last notice'] = pg_last_notice($link);
|
||||
$a['host'] = pg_host($link);
|
||||
$a['port'] = pg_port($link);
|
||||
$a['dbname'] = pg_dbname($link);
|
||||
$a['options'] = pg_options($link);
|
||||
$a['version'] = pg_version($link);
|
||||
|
||||
foreach (self::$paramCodes as $v) {
|
||||
if (false !== $s = pg_parameter_status($link, $v)) {
|
||||
$a['param'][$v] = $s;
|
||||
}
|
||||
}
|
||||
|
||||
$a['param']['client_encoding'] = pg_client_encoding($link);
|
||||
$a['param'] = new EnumStub($a['param']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castResult($result, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a['num rows'] = pg_num_rows($result);
|
||||
$a['status'] = pg_result_status($result);
|
||||
if (isset(self::$resultStatus[$a['status']])) {
|
||||
$a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
|
||||
}
|
||||
$a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
|
||||
|
||||
if (-1 === $a['num rows']) {
|
||||
foreach (self::$diagCodes as $k => $v) {
|
||||
$a['error'][$k] = pg_result_error_field($result, $v);
|
||||
}
|
||||
}
|
||||
|
||||
$a['affected rows'] = pg_affected_rows($result);
|
||||
$a['last OID'] = pg_last_oid($result);
|
||||
|
||||
$fields = pg_num_fields($result);
|
||||
|
||||
for ($i = 0; $i < $fields; ++$i) {
|
||||
$field = [
|
||||
'name' => pg_field_name($result, $i),
|
||||
'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)),
|
||||
'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)),
|
||||
'nullable' => (bool) pg_field_is_null($result, $i),
|
||||
'storage' => pg_field_size($result, $i).' bytes',
|
||||
'display' => pg_field_prtlen($result, $i).' chars',
|
||||
];
|
||||
if (' (OID: )' === $field['table']) {
|
||||
$field['table'] = null;
|
||||
}
|
||||
if ('-1 bytes' === $field['storage']) {
|
||||
$field['storage'] = 'variable size';
|
||||
} elseif ('1 bytes' === $field['storage']) {
|
||||
$field['storage'] = '1 byte';
|
||||
}
|
||||
if ('1 chars' === $field['display']) {
|
||||
$field['display'] = '1 char';
|
||||
}
|
||||
$a['fields'][] = new EnumStub($field);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
33
vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php
vendored
Normal file
33
vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use ProxyManager\Proxy\ProxyInterface;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ProxyManagerCaster
|
||||
{
|
||||
public static function castProxy(ProxyInterface $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if ($parent = get_parent_class($c)) {
|
||||
$stub->class .= ' - '.$parent;
|
||||
}
|
||||
$stub->class .= '@proxy';
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
152
vendor/symfony/var-dumper/Caster/RedisCaster.php
vendored
Normal file
152
vendor/symfony/var-dumper/Caster/RedisCaster.php
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Redis class from ext-redis to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class RedisCaster
|
||||
{
|
||||
private static $serializer = [
|
||||
\Redis::SERIALIZER_NONE => 'NONE',
|
||||
\Redis::SERIALIZER_PHP => 'PHP',
|
||||
2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY
|
||||
];
|
||||
|
||||
private static $mode = [
|
||||
\Redis::ATOMIC => 'ATOMIC',
|
||||
\Redis::MULTI => 'MULTI',
|
||||
\Redis::PIPELINE => 'PIPELINE',
|
||||
];
|
||||
|
||||
private static $compression = [
|
||||
0 => 'NONE', // Redis::COMPRESSION_NONE
|
||||
1 => 'LZF', // Redis::COMPRESSION_LZF
|
||||
];
|
||||
|
||||
private static $failover = [
|
||||
\RedisCluster::FAILOVER_NONE => 'NONE',
|
||||
\RedisCluster::FAILOVER_ERROR => 'ERROR',
|
||||
\RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE',
|
||||
\RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES',
|
||||
];
|
||||
|
||||
public static function castRedis(\Redis $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if (!$connected = $c->isConnected()) {
|
||||
return $a + [
|
||||
$prefix.'isConnected' => $connected,
|
||||
];
|
||||
}
|
||||
|
||||
$mode = $c->getMode();
|
||||
|
||||
return $a + [
|
||||
$prefix.'isConnected' => $connected,
|
||||
$prefix.'host' => $c->getHost(),
|
||||
$prefix.'port' => $c->getPort(),
|
||||
$prefix.'auth' => $c->getAuth(),
|
||||
$prefix.'mode' => isset(self::$mode[$mode]) ? new ConstStub(self::$mode[$mode], $mode) : $mode,
|
||||
$prefix.'dbNum' => $c->getDbNum(),
|
||||
$prefix.'timeout' => $c->getTimeout(),
|
||||
$prefix.'lastError' => $c->getLastError(),
|
||||
$prefix.'persistentId' => $c->getPersistentID(),
|
||||
$prefix.'options' => self::getRedisOptions($c),
|
||||
];
|
||||
}
|
||||
|
||||
public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
return $a + [
|
||||
$prefix.'hosts' => $c->_hosts(),
|
||||
$prefix.'function' => ClassStub::wrapCallable($c->_function()),
|
||||
$prefix.'lastError' => $c->getLastError(),
|
||||
$prefix.'options' => self::getRedisOptions($c),
|
||||
];
|
||||
}
|
||||
|
||||
public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$failover = $c->getOption(\RedisCluster::OPT_SLAVE_FAILOVER);
|
||||
|
||||
$a += [
|
||||
$prefix.'_masters' => $c->_masters(),
|
||||
$prefix.'_redir' => $c->_redir(),
|
||||
$prefix.'mode' => new ConstStub($c->getMode() ? 'MULTI' : 'ATOMIC', $c->getMode()),
|
||||
$prefix.'lastError' => $c->getLastError(),
|
||||
$prefix.'options' => self::getRedisOptions($c, [
|
||||
'SLAVE_FAILOVER' => isset(self::$failover[$failover]) ? new ConstStub(self::$failover[$failover], $failover) : $failover,
|
||||
]),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster $redis
|
||||
*/
|
||||
private static function getRedisOptions($redis, array $options = []): EnumStub
|
||||
{
|
||||
$serializer = $redis->getOption(\Redis::OPT_SERIALIZER);
|
||||
if (\is_array($serializer)) {
|
||||
foreach ($serializer as &$v) {
|
||||
if (isset(self::$serializer[$v])) {
|
||||
$v = new ConstStub(self::$serializer[$v], $v);
|
||||
}
|
||||
}
|
||||
} elseif (isset(self::$serializer[$serializer])) {
|
||||
$serializer = new ConstStub(self::$serializer[$serializer], $serializer);
|
||||
}
|
||||
|
||||
$compression = \defined('Redis::OPT_COMPRESSION') ? $redis->getOption(\Redis::OPT_COMPRESSION) : 0;
|
||||
if (\is_array($compression)) {
|
||||
foreach ($compression as &$v) {
|
||||
if (isset(self::$compression[$v])) {
|
||||
$v = new ConstStub(self::$compression[$v], $v);
|
||||
}
|
||||
}
|
||||
} elseif (isset(self::$compression[$compression])) {
|
||||
$compression = new ConstStub(self::$compression[$compression], $compression);
|
||||
}
|
||||
|
||||
$retry = \defined('Redis::OPT_SCAN') ? $redis->getOption(\Redis::OPT_SCAN) : 0;
|
||||
if (\is_array($retry)) {
|
||||
foreach ($retry as &$v) {
|
||||
$v = new ConstStub($v ? 'RETRY' : 'NORETRY', $v);
|
||||
}
|
||||
} else {
|
||||
$retry = new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry);
|
||||
}
|
||||
|
||||
$options += [
|
||||
'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : 0,
|
||||
'READ_TIMEOUT' => $redis->getOption(\Redis::OPT_READ_TIMEOUT),
|
||||
'COMPRESSION' => $compression,
|
||||
'SERIALIZER' => $serializer,
|
||||
'PREFIX' => $redis->getOption(\Redis::OPT_PREFIX),
|
||||
'SCAN' => $retry,
|
||||
];
|
||||
|
||||
return new EnumStub($options);
|
||||
}
|
||||
}
|
||||
384
vendor/symfony/var-dumper/Caster/ReflectionCaster.php
vendored
Normal file
384
vendor/symfony/var-dumper/Caster/ReflectionCaster.php
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts Reflector related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ReflectionCaster
|
||||
{
|
||||
const UNSET_CLOSURE_FILE_INFO = ['Closure' => __CLASS__.'::unsetClosureFileInfo'];
|
||||
|
||||
private static $extraMap = [
|
||||
'docComment' => 'getDocComment',
|
||||
'extension' => 'getExtensionName',
|
||||
'isDisabled' => 'isDisabled',
|
||||
'isDeprecated' => 'isDeprecated',
|
||||
'isInternal' => 'isInternal',
|
||||
'isUserDefined' => 'isUserDefined',
|
||||
'isGenerator' => 'isGenerator',
|
||||
'isVariadic' => 'isVariadic',
|
||||
];
|
||||
|
||||
public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$c = new \ReflectionFunction($c);
|
||||
|
||||
$a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
|
||||
|
||||
if (false === strpos($c->name, '{closure}')) {
|
||||
$stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name;
|
||||
unset($a[$prefix.'class']);
|
||||
}
|
||||
unset($a[$prefix.'extra']);
|
||||
|
||||
$stub->class .= self::getSignature($a);
|
||||
|
||||
if ($f = $c->getFileName()) {
|
||||
$stub->attr['file'] = $f;
|
||||
$stub->attr['line'] = $c->getStartLine();
|
||||
}
|
||||
|
||||
unset($a[$prefix.'parameters']);
|
||||
|
||||
if ($filter & Caster::EXCLUDE_VERBOSE) {
|
||||
$stub->cut += ($c->getFileName() ? 2 : 0) + \count($a);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($f) {
|
||||
$a[$prefix.'file'] = new LinkStub($f, $c->getStartLine());
|
||||
$a[$prefix.'line'] = $c->getStartLine().' to '.$c->getEndLine();
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function unsetClosureFileInfo(\Closure $c, array $a)
|
||||
{
|
||||
unset($a[Caster::PREFIX_VIRTUAL.'file'], $a[Caster::PREFIX_VIRTUAL.'line']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castGenerator(\Generator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
// Cannot create ReflectionGenerator based on a terminated Generator
|
||||
try {
|
||||
$reflectionGenerator = new \ReflectionGenerator($c);
|
||||
} catch (\Exception $e) {
|
||||
$a[Caster::PREFIX_VIRTUAL.'closed'] = true;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested);
|
||||
}
|
||||
|
||||
public static function castType(\ReflectionType $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += [
|
||||
$prefix.'name' => $c->getName(),
|
||||
$prefix.'allowsNull' => $c->allowsNull(),
|
||||
$prefix.'isBuiltin' => $c->isBuiltin(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if ($c->getThis()) {
|
||||
$a[$prefix.'this'] = new CutStub($c->getThis());
|
||||
}
|
||||
$function = $c->getFunction();
|
||||
$frame = [
|
||||
'class' => isset($function->class) ? $function->class : null,
|
||||
'type' => isset($function->class) ? ($function->isStatic() ? '::' : '->') : null,
|
||||
'function' => $function->name,
|
||||
'file' => $c->getExecutingFile(),
|
||||
'line' => $c->getExecutingLine(),
|
||||
];
|
||||
if ($trace = $c->getTrace(DEBUG_BACKTRACE_IGNORE_ARGS)) {
|
||||
$function = new \ReflectionGenerator($c->getExecutingGenerator());
|
||||
array_unshift($trace, [
|
||||
'function' => 'yield',
|
||||
'file' => $function->getExecutingFile(),
|
||||
'line' => $function->getExecutingLine() - 1,
|
||||
]);
|
||||
$trace[] = $frame;
|
||||
$a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);
|
||||
} else {
|
||||
$function = new FrameStub($frame, false, true);
|
||||
$function = ExceptionCaster::castFrameStub($function, [], $function, true);
|
||||
$a[$prefix.'executing'] = $function[$prefix.'src'];
|
||||
}
|
||||
|
||||
$a[Caster::PREFIX_VIRTUAL.'closed'] = false;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castClass(\ReflectionClass $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if ($n = \Reflection::getModifierNames($c->getModifiers())) {
|
||||
$a[$prefix.'modifiers'] = implode(' ', $n);
|
||||
}
|
||||
|
||||
self::addMap($a, $c, [
|
||||
'extends' => 'getParentClass',
|
||||
'implements' => 'getInterfaceNames',
|
||||
'constants' => 'getConstants',
|
||||
]);
|
||||
|
||||
foreach ($c->getProperties() as $n) {
|
||||
$a[$prefix.'properties'][$n->name] = $n;
|
||||
}
|
||||
|
||||
foreach ($c->getMethods() as $n) {
|
||||
$a[$prefix.'methods'][$n->name] = $n;
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
|
||||
self::addExtra($a, $c);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
self::addMap($a, $c, [
|
||||
'returnsReference' => 'returnsReference',
|
||||
'returnType' => 'getReturnType',
|
||||
'class' => 'getClosureScopeClass',
|
||||
'this' => 'getClosureThis',
|
||||
]);
|
||||
|
||||
if (isset($a[$prefix.'returnType'])) {
|
||||
$v = $a[$prefix.'returnType'];
|
||||
$v = $v->getName();
|
||||
$a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
|
||||
}
|
||||
if (isset($a[$prefix.'class'])) {
|
||||
$a[$prefix.'class'] = new ClassStub($a[$prefix.'class']);
|
||||
}
|
||||
if (isset($a[$prefix.'this'])) {
|
||||
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
|
||||
}
|
||||
|
||||
foreach ($c->getParameters() as $v) {
|
||||
$k = '$'.$v->name;
|
||||
if ($v->isVariadic()) {
|
||||
$k = '...'.$k;
|
||||
}
|
||||
if ($v->isPassedByReference()) {
|
||||
$k = '&'.$k;
|
||||
}
|
||||
$a[$prefix.'parameters'][$k] = $v;
|
||||
}
|
||||
if (isset($a[$prefix.'parameters'])) {
|
||||
$a[$prefix.'parameters'] = new EnumStub($a[$prefix.'parameters']);
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && $v = $c->getStaticVariables()) {
|
||||
foreach ($v as $k => &$v) {
|
||||
if (\is_object($v)) {
|
||||
$a[$prefix.'use']['$'.$k] = new CutStub($v);
|
||||
} else {
|
||||
$a[$prefix.'use']['$'.$k] = &$v;
|
||||
}
|
||||
}
|
||||
unset($v);
|
||||
$a[$prefix.'use'] = new EnumStub($a[$prefix.'use']);
|
||||
}
|
||||
|
||||
if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) {
|
||||
self::addExtra($a, $c);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
self::addMap($a, $c, [
|
||||
'position' => 'getPosition',
|
||||
'isVariadic' => 'isVariadic',
|
||||
'byReference' => 'isPassedByReference',
|
||||
'allowsNull' => 'allowsNull',
|
||||
]);
|
||||
|
||||
if ($v = $c->getType()) {
|
||||
$a[$prefix.'typeHint'] = $v->getName();
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'typeHint'])) {
|
||||
$v = $a[$prefix.'typeHint'];
|
||||
$a[$prefix.'typeHint'] = new ClassStub($v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
|
||||
} else {
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
}
|
||||
|
||||
try {
|
||||
$a[$prefix.'default'] = $v = $c->getDefaultValue();
|
||||
if ($c->isDefaultValueConstant()) {
|
||||
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
|
||||
}
|
||||
if (null === $v) {
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers()));
|
||||
self::addExtra($a, $c);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castReference(\ReflectionReference $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId();
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
self::addMap($a, $c, [
|
||||
'version' => 'getVersion',
|
||||
'dependencies' => 'getDependencies',
|
||||
'iniEntries' => 'getIniEntries',
|
||||
'isPersistent' => 'isPersistent',
|
||||
'isTemporary' => 'isTemporary',
|
||||
'constants' => 'getConstants',
|
||||
'functions' => 'getFunctions',
|
||||
'classes' => 'getClasses',
|
||||
]);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
self::addMap($a, $c, [
|
||||
'version' => 'getVersion',
|
||||
'author' => 'getAuthor',
|
||||
'copyright' => 'getCopyright',
|
||||
'url' => 'getURL',
|
||||
]);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function getSignature(array $a)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$signature = '';
|
||||
|
||||
if (isset($a[$prefix.'parameters'])) {
|
||||
foreach ($a[$prefix.'parameters']->value as $k => $param) {
|
||||
$signature .= ', ';
|
||||
if ($type = $param->getType()) {
|
||||
if (!$param->isOptional() && $param->allowsNull()) {
|
||||
$signature .= '?';
|
||||
}
|
||||
$signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' ';
|
||||
}
|
||||
$signature .= $k;
|
||||
|
||||
if (!$param->isDefaultValueAvailable()) {
|
||||
continue;
|
||||
}
|
||||
$v = $param->getDefaultValue();
|
||||
$signature .= ' = ';
|
||||
|
||||
if ($param->isDefaultValueConstant()) {
|
||||
$signature .= substr(strrchr('\\'.$param->getDefaultValueConstantName(), '\\'), 1);
|
||||
} elseif (null === $v) {
|
||||
$signature .= 'null';
|
||||
} elseif (\is_array($v)) {
|
||||
$signature .= $v ? '[…'.\count($v).']' : '[]';
|
||||
} elseif (\is_string($v)) {
|
||||
$signature .= 10 > \strlen($v) && false === strpos($v, '\\') ? "'{$v}'" : "'…".\strlen($v)."'";
|
||||
} elseif (\is_bool($v)) {
|
||||
$signature .= $v ? 'true' : 'false';
|
||||
} else {
|
||||
$signature .= $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
$signature = (empty($a[$prefix.'returnsReference']) ? '' : '&').'('.substr($signature, 2).')';
|
||||
|
||||
if (isset($a[$prefix.'returnType'])) {
|
||||
$signature .= ': '.substr(strrchr('\\'.$a[$prefix.'returnType'], '\\'), 1);
|
||||
}
|
||||
|
||||
return $signature;
|
||||
}
|
||||
|
||||
private static function addExtra(array &$a, \Reflector $c)
|
||||
{
|
||||
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : [];
|
||||
|
||||
if (method_exists($c, 'getFileName') && $m = $c->getFileName()) {
|
||||
$x['file'] = new LinkStub($m, $c->getStartLine());
|
||||
$x['line'] = $c->getStartLine().' to '.$c->getEndLine();
|
||||
}
|
||||
|
||||
self::addMap($x, $c, self::$extraMap, '');
|
||||
|
||||
if ($x) {
|
||||
$a[Caster::PREFIX_VIRTUAL.'extra'] = new EnumStub($x);
|
||||
}
|
||||
}
|
||||
|
||||
private static function addMap(array &$a, \Reflector $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
|
||||
{
|
||||
foreach ($map as $k => $m) {
|
||||
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {
|
||||
$a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
100
vendor/symfony/var-dumper/Caster/ResourceCaster.php
vendored
Normal file
100
vendor/symfony/var-dumper/Caster/ResourceCaster.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts common resource types to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ResourceCaster
|
||||
{
|
||||
public static function castCurl($h, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return curl_getinfo($h);
|
||||
}
|
||||
|
||||
public static function castDba($dba, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$list = dba_list();
|
||||
$a['file'] = $list[(int) $dba];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castProcess($process, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return proc_get_status($process);
|
||||
}
|
||||
|
||||
public static function castStream($stream, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested);
|
||||
if (isset($a['uri'])) {
|
||||
$a['uri'] = new LinkStub($a['uri']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castStreamContext($stream, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return @stream_context_get_params($stream) ?: $a;
|
||||
}
|
||||
|
||||
public static function castGd($gd, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a['size'] = imagesx($gd).'x'.imagesy($gd);
|
||||
$a['trueColor'] = imageistruecolor($gd);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castMysqlLink($h, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a['host'] = mysql_get_host_info($h);
|
||||
$a['protocol'] = mysql_get_proto_info($h);
|
||||
$a['server'] = mysql_get_server_info($h);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castOpensslX509($h, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$stub->cut = -1;
|
||||
$info = openssl_x509_parse($h, false);
|
||||
|
||||
$pin = openssl_pkey_get_public($h);
|
||||
$pin = openssl_pkey_get_details($pin)['key'];
|
||||
$pin = \array_slice(explode("\n", $pin), 1, -2);
|
||||
$pin = base64_decode(implode('', $pin));
|
||||
$pin = base64_encode(hash('sha256', $pin, true));
|
||||
|
||||
$a += [
|
||||
'subject' => new EnumStub(array_intersect_key($info['subject'], ['organizationName' => true, 'commonName' => true])),
|
||||
'issuer' => new EnumStub(array_intersect_key($info['issuer'], ['organizationName' => true, 'commonName' => true])),
|
||||
'expiry' => new ConstStub(date(\DateTime::ISO8601, $info['validTo_time_t']), $info['validTo_time_t']),
|
||||
'fingerprint' => new EnumStub([
|
||||
'md5' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'md5')), 2, ':', true)),
|
||||
'sha1' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha1')), 2, ':', true)),
|
||||
'sha256' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha256')), 2, ':', true)),
|
||||
'pin-sha256' => new ConstStub($pin),
|
||||
]),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
228
vendor/symfony/var-dumper/Caster/SplCaster.php
vendored
Normal file
228
vendor/symfony/var-dumper/Caster/SplCaster.php
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts SPL related classes to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class SplCaster
|
||||
{
|
||||
private static $splFileObjectFlags = [
|
||||
\SplFileObject::DROP_NEW_LINE => 'DROP_NEW_LINE',
|
||||
\SplFileObject::READ_AHEAD => 'READ_AHEAD',
|
||||
\SplFileObject::SKIP_EMPTY => 'SKIP_EMPTY',
|
||||
\SplFileObject::READ_CSV => 'READ_CSV',
|
||||
];
|
||||
|
||||
public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return self::castSplArray($c, $a, $stub, $isNested);
|
||||
}
|
||||
|
||||
public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return self::castSplArray($c, $a, $stub, $isNested);
|
||||
}
|
||||
|
||||
public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'heap' => iterator_to_array(clone $c),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$mode = $c->getIteratorMode();
|
||||
$c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE);
|
||||
|
||||
$a += [
|
||||
$prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_DELETE) ? 'IT_MODE_DELETE' : 'IT_MODE_KEEP'), $mode),
|
||||
$prefix.'dllist' => iterator_to_array($c),
|
||||
];
|
||||
$c->setIteratorMode($mode);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
static $map = [
|
||||
'path' => 'getPath',
|
||||
'filename' => 'getFilename',
|
||||
'basename' => 'getBasename',
|
||||
'pathname' => 'getPathname',
|
||||
'extension' => 'getExtension',
|
||||
'realPath' => 'getRealPath',
|
||||
'aTime' => 'getATime',
|
||||
'mTime' => 'getMTime',
|
||||
'cTime' => 'getCTime',
|
||||
'inode' => 'getInode',
|
||||
'size' => 'getSize',
|
||||
'perms' => 'getPerms',
|
||||
'owner' => 'getOwner',
|
||||
'group' => 'getGroup',
|
||||
'type' => 'getType',
|
||||
'writable' => 'isWritable',
|
||||
'readable' => 'isReadable',
|
||||
'executable' => 'isExecutable',
|
||||
'file' => 'isFile',
|
||||
'dir' => 'isDir',
|
||||
'link' => 'isLink',
|
||||
'linkTarget' => 'getLinkTarget',
|
||||
];
|
||||
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
if (false === $c->getPathname()) {
|
||||
$a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state';
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
foreach ($map as $key => $accessor) {
|
||||
try {
|
||||
$a[$prefix.$key] = $c->$accessor();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'realPath'])) {
|
||||
$a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']);
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'perms'])) {
|
||||
$a[$prefix.'perms'] = new ConstStub(sprintf('0%o', $a[$prefix.'perms']), $a[$prefix.'perms']);
|
||||
}
|
||||
|
||||
static $mapDate = ['aTime', 'mTime', 'cTime'];
|
||||
foreach ($mapDate as $key) {
|
||||
if (isset($a[$prefix.$key])) {
|
||||
$a[$prefix.$key] = new ConstStub(date('Y-m-d H:i:s', $a[$prefix.$key]), $a[$prefix.$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
static $map = [
|
||||
'csvControl' => 'getCsvControl',
|
||||
'flags' => 'getFlags',
|
||||
'maxLineLen' => 'getMaxLineLen',
|
||||
'fstat' => 'fstat',
|
||||
'eof' => 'eof',
|
||||
'key' => 'key',
|
||||
];
|
||||
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
foreach ($map as $key => $accessor) {
|
||||
try {
|
||||
$a[$prefix.$key] = $c->$accessor();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'flags'])) {
|
||||
$flagsArray = [];
|
||||
foreach (self::$splFileObjectFlags as $value => $name) {
|
||||
if ($a[$prefix.'flags'] & $value) {
|
||||
$flagsArray[] = $name;
|
||||
}
|
||||
}
|
||||
$a[$prefix.'flags'] = new ConstStub(implode('|', $flagsArray), $a[$prefix.'flags']);
|
||||
}
|
||||
|
||||
if (isset($a[$prefix.'fstat'])) {
|
||||
$a[$prefix.'fstat'] = new CutArrayStub($a[$prefix.'fstat'], ['dev', 'ino', 'nlink', 'rdev', 'blksize', 'blocks']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'storage' => $c->toArray(),
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$storage = [];
|
||||
unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967
|
||||
|
||||
$clone = clone $c;
|
||||
foreach ($clone as $obj) {
|
||||
$storage[] = [
|
||||
'object' => $obj,
|
||||
'info' => $clone->getInfo(),
|
||||
];
|
||||
}
|
||||
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'storage' => $storage,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator();
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a[Caster::PREFIX_VIRTUAL.'object'] = $c->get();
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
$class = $stub->class;
|
||||
$flags = $c->getFlags();
|
||||
|
||||
if (!($flags & \ArrayObject::STD_PROP_LIST)) {
|
||||
$c->setFlags(\ArrayObject::STD_PROP_LIST);
|
||||
$a = Caster::castObject($c, $class);
|
||||
$c->setFlags($flags);
|
||||
}
|
||||
$a += [
|
||||
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
|
||||
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
|
||||
];
|
||||
if ($c instanceof \ArrayObject) {
|
||||
$a[$prefix.'iteratorClass'] = new ClassStub($c->getIteratorClass());
|
||||
}
|
||||
$a[$prefix.'storage'] = $c->getArrayCopy();
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
84
vendor/symfony/var-dumper/Caster/StubCaster.php
vendored
Normal file
84
vendor/symfony/var-dumper/Caster/StubCaster.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts a caster's Stub.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class StubCaster
|
||||
{
|
||||
public static function castStub(Stub $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if ($isNested) {
|
||||
$stub->type = $c->type;
|
||||
$stub->class = $c->class;
|
||||
$stub->value = $c->value;
|
||||
$stub->handle = $c->handle;
|
||||
$stub->cut = $c->cut;
|
||||
$stub->attr = $c->attr;
|
||||
|
||||
if (Stub::TYPE_REF === $c->type && !$c->class && \is_string($c->value) && !preg_match('//u', $c->value)) {
|
||||
$stub->type = Stub::TYPE_STRING;
|
||||
$stub->class = Stub::STRING_BINARY;
|
||||
}
|
||||
|
||||
$a = [];
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
return $isNested ? $c->preservedSubset : $a;
|
||||
}
|
||||
|
||||
public static function cutInternals($obj, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if ($isNested) {
|
||||
$stub->cut += \count($a);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castEnum(EnumStub $c, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
if ($isNested) {
|
||||
$stub->class = $c->dumpKeys ? '' : null;
|
||||
$stub->handle = 0;
|
||||
$stub->value = null;
|
||||
$stub->cut = $c->cut;
|
||||
$stub->attr = $c->attr;
|
||||
|
||||
$a = [];
|
||||
|
||||
if ($c->value) {
|
||||
foreach (array_keys($c->value) as $k) {
|
||||
$keys[] = !isset($k[0]) || "\0" !== $k[0] ? Caster::PREFIX_VIRTUAL.$k : $k;
|
||||
}
|
||||
// Preserve references with array_combine()
|
||||
$a = array_combine($keys, $c->value);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
69
vendor/symfony/var-dumper/Caster/SymfonyCaster.php
vendored
Normal file
69
vendor/symfony/var-dumper/Caster/SymfonyCaster.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @final
|
||||
*/
|
||||
class SymfonyCaster
|
||||
{
|
||||
private static $requestGetters = [
|
||||
'pathInfo' => 'getPathInfo',
|
||||
'requestUri' => 'getRequestUri',
|
||||
'baseUrl' => 'getBaseUrl',
|
||||
'basePath' => 'getBasePath',
|
||||
'method' => 'getMethod',
|
||||
'format' => 'getRequestFormat',
|
||||
];
|
||||
|
||||
public static function castRequest(Request $request, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$clone = null;
|
||||
|
||||
foreach (self::$requestGetters as $prop => $getter) {
|
||||
$key = Caster::PREFIX_PROTECTED.$prop;
|
||||
if (\array_key_exists($key, $a) && null === $a[$key]) {
|
||||
if (null === $clone) {
|
||||
$clone = clone $request;
|
||||
}
|
||||
$a[Caster::PREFIX_VIRTUAL.$prop] = $clone->{$getter}();
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castHttpClient($client, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$multiKey = sprintf("\0%s\0multi", \get_class($client));
|
||||
if (isset($a[$multiKey])) {
|
||||
$a[$multiKey] = new CutStub($a[$multiKey]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castHttpClientResponse($response, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$stub->cut += \count($a);
|
||||
$a = [];
|
||||
|
||||
foreach ($response->getInfo() as $k => $v) {
|
||||
$a[Caster::PREFIX_VIRTUAL.$k] = $v;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
36
vendor/symfony/var-dumper/Caster/TraceStub.php
vendored
Normal file
36
vendor/symfony/var-dumper/Caster/TraceStub.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Represents a backtrace as returned by debug_backtrace() or Exception->getTrace().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class TraceStub extends Stub
|
||||
{
|
||||
public $keepArgs;
|
||||
public $sliceOffset;
|
||||
public $sliceLength;
|
||||
public $numberingOffset;
|
||||
|
||||
public function __construct(array $trace, bool $keepArgs = true, int $sliceOffset = 0, int $sliceLength = null, int $numberingOffset = 0)
|
||||
{
|
||||
$this->value = $trace;
|
||||
$this->keepArgs = $keepArgs;
|
||||
$this->sliceOffset = $sliceOffset;
|
||||
$this->sliceLength = $sliceLength;
|
||||
$this->numberingOffset = $numberingOffset;
|
||||
}
|
||||
}
|
||||
30
vendor/symfony/var-dumper/Caster/UuidCaster.php
vendored
Normal file
30
vendor/symfony/var-dumper/Caster/UuidCaster.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
final class UuidCaster
|
||||
{
|
||||
public static function castRamseyUuid(UuidInterface $c, array $a, Stub $stub, bool $isNested): array
|
||||
{
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'uuid' => (string) $c,
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
79
vendor/symfony/var-dumper/Caster/XmlReaderCaster.php
vendored
Normal file
79
vendor/symfony/var-dumper/Caster/XmlReaderCaster.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts XmlReader class to array representation.
|
||||
*
|
||||
* @author Baptiste Clavié <clavie.b@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class XmlReaderCaster
|
||||
{
|
||||
private static $nodeTypes = [
|
||||
\XMLReader::NONE => 'NONE',
|
||||
\XMLReader::ELEMENT => 'ELEMENT',
|
||||
\XMLReader::ATTRIBUTE => 'ATTRIBUTE',
|
||||
\XMLReader::TEXT => 'TEXT',
|
||||
\XMLReader::CDATA => 'CDATA',
|
||||
\XMLReader::ENTITY_REF => 'ENTITY_REF',
|
||||
\XMLReader::ENTITY => 'ENTITY',
|
||||
\XMLReader::PI => 'PI (Processing Instruction)',
|
||||
\XMLReader::COMMENT => 'COMMENT',
|
||||
\XMLReader::DOC => 'DOC',
|
||||
\XMLReader::DOC_TYPE => 'DOC_TYPE',
|
||||
\XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT',
|
||||
\XMLReader::NOTATION => 'NOTATION',
|
||||
\XMLReader::WHITESPACE => 'WHITESPACE',
|
||||
\XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE',
|
||||
\XMLReader::END_ELEMENT => 'END_ELEMENT',
|
||||
\XMLReader::END_ENTITY => 'END_ENTITY',
|
||||
\XMLReader::XML_DECLARATION => 'XML_DECLARATION',
|
||||
];
|
||||
|
||||
public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$props = Caster::PREFIX_VIRTUAL.'parserProperties';
|
||||
$info = [
|
||||
'localName' => $reader->localName,
|
||||
'prefix' => $reader->prefix,
|
||||
'nodeType' => new ConstStub(self::$nodeTypes[$reader->nodeType], $reader->nodeType),
|
||||
'depth' => $reader->depth,
|
||||
'isDefault' => $reader->isDefault,
|
||||
'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement,
|
||||
'xmlLang' => $reader->xmlLang,
|
||||
'attributeCount' => $reader->attributeCount,
|
||||
'value' => $reader->value,
|
||||
'namespaceURI' => $reader->namespaceURI,
|
||||
'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI,
|
||||
$props => [
|
||||
'LOADDTD' => $reader->getParserProperty(\XMLReader::LOADDTD),
|
||||
'DEFAULTATTRS' => $reader->getParserProperty(\XMLReader::DEFAULTATTRS),
|
||||
'VALIDATE' => $reader->getParserProperty(\XMLReader::VALIDATE),
|
||||
'SUBST_ENTITIES' => $reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
|
||||
],
|
||||
];
|
||||
|
||||
if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) {
|
||||
$info[$props] = new EnumStub($info[$props]);
|
||||
$info[$props]->cut = $count;
|
||||
}
|
||||
|
||||
$info = Caster::filter($info, Caster::EXCLUDE_EMPTY, [], $count);
|
||||
// +2 because hasValue and hasAttributes are always filtered
|
||||
$stub->cut += $count + 2;
|
||||
|
||||
return $a + $info;
|
||||
}
|
||||
}
|
||||
63
vendor/symfony/var-dumper/Caster/XmlResourceCaster.php
vendored
Normal file
63
vendor/symfony/var-dumper/Caster/XmlResourceCaster.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Casts XML resources to array representation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class XmlResourceCaster
|
||||
{
|
||||
private static $xmlErrors = [
|
||||
XML_ERROR_NONE => 'XML_ERROR_NONE',
|
||||
XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY',
|
||||
XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX',
|
||||
XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS',
|
||||
XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN',
|
||||
XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN',
|
||||
XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR',
|
||||
XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH',
|
||||
XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE',
|
||||
XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT',
|
||||
XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF',
|
||||
XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY',
|
||||
XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF',
|
||||
XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY',
|
||||
XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF',
|
||||
XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF',
|
||||
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF',
|
||||
XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI',
|
||||
XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING',
|
||||
XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING',
|
||||
XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION',
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING',
|
||||
];
|
||||
|
||||
public static function castXml($h, array $a, Stub $stub, bool $isNested)
|
||||
{
|
||||
$a['current_byte_index'] = xml_get_current_byte_index($h);
|
||||
$a['current_column_number'] = xml_get_current_column_number($h);
|
||||
$a['current_line_number'] = xml_get_current_line_number($h);
|
||||
$a['error_code'] = xml_get_error_code($h);
|
||||
|
||||
if (isset(self::$xmlErrors[$a['error_code']])) {
|
||||
$a['error_code'] = new ConstStub(self::$xmlErrors[$a['error_code']], $a['error_code']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
360
vendor/symfony/var-dumper/Cloner/AbstractCloner.php
vendored
Normal file
360
vendor/symfony/var-dumper/Cloner/AbstractCloner.php
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
|
||||
|
||||
/**
|
||||
* AbstractCloner implements a generic caster mechanism for objects and resources.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
abstract class AbstractCloner implements ClonerInterface
|
||||
{
|
||||
public static $defaultCasters = [
|
||||
'__PHP_Incomplete_Class' => ['Symfony\Component\VarDumper\Caster\Caster', 'castPhpIncompleteClass'],
|
||||
|
||||
'Symfony\Component\VarDumper\Caster\CutStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'],
|
||||
'Symfony\Component\VarDumper\Caster\CutArrayStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castCutArray'],
|
||||
'Symfony\Component\VarDumper\Caster\ConstStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'],
|
||||
'Symfony\Component\VarDumper\Caster\EnumStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castEnum'],
|
||||
|
||||
'Closure' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClosure'],
|
||||
'Generator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castGenerator'],
|
||||
'ReflectionType' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castType'],
|
||||
'ReflectionGenerator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReflectionGenerator'],
|
||||
'ReflectionClass' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClass'],
|
||||
'ReflectionFunctionAbstract' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castFunctionAbstract'],
|
||||
'ReflectionMethod' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castMethod'],
|
||||
'ReflectionParameter' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castParameter'],
|
||||
'ReflectionProperty' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castProperty'],
|
||||
'ReflectionReference' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReference'],
|
||||
'ReflectionExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castExtension'],
|
||||
'ReflectionZendExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castZendExtension'],
|
||||
|
||||
'Doctrine\Common\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Doctrine\Common\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castCommonProxy'],
|
||||
'Doctrine\ORM\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castOrmProxy'],
|
||||
'Doctrine\ORM\PersistentCollection' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castPersistentCollection'],
|
||||
'Doctrine\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
|
||||
'DOMException' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castException'],
|
||||
'DOMStringList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
'DOMNameList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
'DOMImplementation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castImplementation'],
|
||||
'DOMImplementationList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
'DOMNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNode'],
|
||||
'DOMNameSpaceNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNameSpaceNode'],
|
||||
'DOMDocument' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocument'],
|
||||
'DOMNodeList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
'DOMNamedNodeMap' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
'DOMCharacterData' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castCharacterData'],
|
||||
'DOMAttr' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castAttr'],
|
||||
'DOMElement' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castElement'],
|
||||
'DOMText' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castText'],
|
||||
'DOMTypeinfo' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castTypeinfo'],
|
||||
'DOMDomError' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDomError'],
|
||||
'DOMLocator' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLocator'],
|
||||
'DOMDocumentType' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocumentType'],
|
||||
'DOMNotation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNotation'],
|
||||
'DOMEntity' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castEntity'],
|
||||
'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'],
|
||||
'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'],
|
||||
|
||||
'XMLReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'],
|
||||
|
||||
'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'],
|
||||
'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'],
|
||||
'Error' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castError'],
|
||||
'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Symfony\Component\EventDispatcher\EventDispatcherInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
|
||||
'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'],
|
||||
'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
|
||||
'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'],
|
||||
'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'],
|
||||
'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'],
|
||||
'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'],
|
||||
'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'],
|
||||
'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Symfony\Component\ErrorHandler\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'],
|
||||
|
||||
'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster', 'castImage'],
|
||||
|
||||
'Ramsey\Uuid\UuidInterface' => ['Symfony\Component\VarDumper\Caster\UuidCaster', 'castRamseyUuid'],
|
||||
|
||||
'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'],
|
||||
'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'PHPUnit\Framework\MockObject\MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'PHPUnit\Framework\MockObject\Stub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Prophecy\Prophecy\ProphecySubjectInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
'Mockery\MockInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
|
||||
'PDO' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdo'],
|
||||
'PDOStatement' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdoStatement'],
|
||||
|
||||
'AMQPConnection' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castConnection'],
|
||||
'AMQPChannel' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castChannel'],
|
||||
'AMQPQueue' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castQueue'],
|
||||
'AMQPExchange' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castExchange'],
|
||||
'AMQPEnvelope' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castEnvelope'],
|
||||
|
||||
'ArrayObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayObject'],
|
||||
'ArrayIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayIterator'],
|
||||
'SplDoublyLinkedList' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castDoublyLinkedList'],
|
||||
'SplFileInfo' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileInfo'],
|
||||
'SplFileObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileObject'],
|
||||
'SplFixedArray' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFixedArray'],
|
||||
'SplHeap' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'],
|
||||
'SplObjectStorage' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castObjectStorage'],
|
||||
'SplPriorityQueue' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'],
|
||||
'OuterIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castOuterIterator'],
|
||||
'WeakReference' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakReference'],
|
||||
|
||||
'Redis' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'],
|
||||
'RedisArray' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'],
|
||||
'RedisCluster' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisCluster'],
|
||||
|
||||
'DateTimeInterface' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castDateTime'],
|
||||
'DateInterval' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castInterval'],
|
||||
'DateTimeZone' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castTimeZone'],
|
||||
'DatePeriod' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castPeriod'],
|
||||
|
||||
'GMP' => ['Symfony\Component\VarDumper\Caster\GmpCaster', 'castGmp'],
|
||||
|
||||
'MessageFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castMessageFormatter'],
|
||||
'NumberFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castNumberFormatter'],
|
||||
'IntlTimeZone' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlTimeZone'],
|
||||
'IntlCalendar' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlCalendar'],
|
||||
'IntlDateFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlDateFormatter'],
|
||||
|
||||
'Memcached' => ['Symfony\Component\VarDumper\Caster\MemcachedCaster', 'castMemcached'],
|
||||
|
||||
'Ds\Collection' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castCollection'],
|
||||
'Ds\Map' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castMap'],
|
||||
'Ds\Pair' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPair'],
|
||||
'Symfony\Component\VarDumper\Caster\DsPairStub' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPairStub'],
|
||||
|
||||
':curl' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'],
|
||||
':dba' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'],
|
||||
':dba persistent' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'],
|
||||
':gd' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'],
|
||||
':mysql link' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castMysqlLink'],
|
||||
':pgsql large object' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLargeObject'],
|
||||
':pgsql link' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'],
|
||||
':pgsql link persistent' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'],
|
||||
':pgsql result' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castResult'],
|
||||
':process' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castProcess'],
|
||||
':stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'],
|
||||
':OpenSSL X.509' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'],
|
||||
':persistent stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'],
|
||||
':stream-context' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStreamContext'],
|
||||
':xml' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'],
|
||||
];
|
||||
|
||||
protected $maxItems = 2500;
|
||||
protected $maxString = -1;
|
||||
protected $minDepth = 1;
|
||||
|
||||
private $casters = [];
|
||||
private $prevErrorHandler;
|
||||
private $classInfo = [];
|
||||
private $filter = 0;
|
||||
|
||||
/**
|
||||
* @param callable[]|null $casters A map of casters
|
||||
*
|
||||
* @see addCasters
|
||||
*/
|
||||
public function __construct(array $casters = null)
|
||||
{
|
||||
if (null === $casters) {
|
||||
$casters = static::$defaultCasters;
|
||||
}
|
||||
$this->addCasters($casters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds casters for resources and objects.
|
||||
*
|
||||
* Maps resources or objects types to a callback.
|
||||
* Types are in the key, with a callable caster for value.
|
||||
* Resource types are to be prefixed with a `:`,
|
||||
* see e.g. static::$defaultCasters.
|
||||
*
|
||||
* @param callable[] $casters A map of casters
|
||||
*/
|
||||
public function addCasters(array $casters)
|
||||
{
|
||||
foreach ($casters as $type => $callback) {
|
||||
$this->casters[$type][] = $callback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of items to clone past the minimum depth in nested structures.
|
||||
*/
|
||||
public function setMaxItems(int $maxItems)
|
||||
{
|
||||
$this->maxItems = $maxItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum cloned length for strings.
|
||||
*/
|
||||
public function setMaxString(int $maxString)
|
||||
{
|
||||
$this->maxString = $maxString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum tree depth where we are guaranteed to clone all the items. After this
|
||||
* depth is reached, only setMaxItems items will be cloned.
|
||||
*/
|
||||
public function setMinDepth(int $minDepth)
|
||||
{
|
||||
$this->minDepth = $minDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a PHP variable.
|
||||
*
|
||||
* @param mixed $var Any PHP variable
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants
|
||||
*
|
||||
* @return Data The cloned variable represented by a Data object
|
||||
*/
|
||||
public function cloneVar($var, int $filter = 0)
|
||||
{
|
||||
$this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {
|
||||
if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) {
|
||||
// Cloner never dies
|
||||
throw new \ErrorException($msg, 0, $type, $file, $line);
|
||||
}
|
||||
|
||||
if ($this->prevErrorHandler) {
|
||||
return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
$this->filter = $filter;
|
||||
|
||||
if ($gc = gc_enabled()) {
|
||||
gc_disable();
|
||||
}
|
||||
try {
|
||||
return new Data($this->doClone($var));
|
||||
} finally {
|
||||
if ($gc) {
|
||||
gc_enable();
|
||||
}
|
||||
restore_error_handler();
|
||||
$this->prevErrorHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Effectively clones the PHP variable.
|
||||
*
|
||||
* @param mixed $var Any PHP variable
|
||||
*
|
||||
* @return array The cloned variable represented in an array
|
||||
*/
|
||||
abstract protected function doClone($var);
|
||||
|
||||
/**
|
||||
* Casts an object to an array representation.
|
||||
*
|
||||
* @param bool $isNested True if the object is nested in the dumped structure
|
||||
*
|
||||
* @return array The object casted as array
|
||||
*/
|
||||
protected function castObject(Stub $stub, bool $isNested)
|
||||
{
|
||||
$obj = $stub->value;
|
||||
$class = $stub->class;
|
||||
|
||||
if (isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00")) {
|
||||
$stub->class = get_parent_class($class).'@anonymous';
|
||||
}
|
||||
if (isset($this->classInfo[$class])) {
|
||||
list($i, $parents, $hasDebugInfo, $fileInfo) = $this->classInfo[$class];
|
||||
} else {
|
||||
$i = 2;
|
||||
$parents = [$class];
|
||||
$hasDebugInfo = method_exists($class, '__debugInfo');
|
||||
|
||||
foreach (class_parents($class) as $p) {
|
||||
$parents[] = $p;
|
||||
++$i;
|
||||
}
|
||||
foreach (class_implements($class) as $p) {
|
||||
$parents[] = $p;
|
||||
++$i;
|
||||
}
|
||||
$parents[] = '*';
|
||||
|
||||
$r = new \ReflectionClass($class);
|
||||
$fileInfo = $r->isInternal() || $r->isSubclassOf(Stub::class) ? [] : [
|
||||
'file' => $r->getFileName(),
|
||||
'line' => $r->getStartLine(),
|
||||
];
|
||||
|
||||
$this->classInfo[$class] = [$i, $parents, $hasDebugInfo, $fileInfo];
|
||||
}
|
||||
|
||||
$stub->attr += $fileInfo;
|
||||
$a = Caster::castObject($obj, $class, $hasDebugInfo);
|
||||
|
||||
try {
|
||||
while ($i--) {
|
||||
if (!empty($this->casters[$p = $parents[$i]])) {
|
||||
foreach ($this->casters[$p] as $callback) {
|
||||
$a = $callback($obj, $a, $stub, $isNested, $this->filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a resource to an array representation.
|
||||
*
|
||||
* @param bool $isNested True if the object is nested in the dumped structure
|
||||
*
|
||||
* @return array The resource casted as array
|
||||
*/
|
||||
protected function castResource(Stub $stub, bool $isNested)
|
||||
{
|
||||
$a = [];
|
||||
$res = $stub->value;
|
||||
$type = $stub->class;
|
||||
|
||||
try {
|
||||
if (!empty($this->casters[':'.$type])) {
|
||||
foreach ($this->casters[':'.$type] as $callback) {
|
||||
$a = $callback($res, $a, $stub, $isNested, $this->filter);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
27
vendor/symfony/var-dumper/Cloner/ClonerInterface.php
vendored
Normal file
27
vendor/symfony/var-dumper/Cloner/ClonerInterface.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface ClonerInterface
|
||||
{
|
||||
/**
|
||||
* Clones a PHP variable.
|
||||
*
|
||||
* @param mixed $var Any PHP variable
|
||||
*
|
||||
* @return Data The cloned variable represented by a Data object
|
||||
*/
|
||||
public function cloneVar($var);
|
||||
}
|
||||
43
vendor/symfony/var-dumper/Cloner/Cursor.php
vendored
Normal file
43
vendor/symfony/var-dumper/Cloner/Cursor.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
/**
|
||||
* Represents the current state of a dumper while dumping.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class Cursor
|
||||
{
|
||||
const HASH_INDEXED = Stub::ARRAY_INDEXED;
|
||||
const HASH_ASSOC = Stub::ARRAY_ASSOC;
|
||||
const HASH_OBJECT = Stub::TYPE_OBJECT;
|
||||
const HASH_RESOURCE = Stub::TYPE_RESOURCE;
|
||||
|
||||
public $depth = 0;
|
||||
public $refIndex = 0;
|
||||
public $softRefTo = 0;
|
||||
public $softRefCount = 0;
|
||||
public $softRefHandle = 0;
|
||||
public $hardRefTo = 0;
|
||||
public $hardRefCount = 0;
|
||||
public $hardRefHandle = 0;
|
||||
public $hashType;
|
||||
public $hashKey;
|
||||
public $hashKeyIsBinary;
|
||||
public $hashIndex = 0;
|
||||
public $hashLength = 0;
|
||||
public $hashCut = 0;
|
||||
public $stop = false;
|
||||
public $attr = [];
|
||||
public $skipChildren = false;
|
||||
}
|
||||
451
vendor/symfony/var-dumper/Cloner/Data.php
vendored
Normal file
451
vendor/symfony/var-dumper/Cloner/Data.php
vendored
Normal file
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class Data implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
{
|
||||
private $data;
|
||||
private $position = 0;
|
||||
private $key = 0;
|
||||
private $maxDepth = 20;
|
||||
private $maxItemsPerDepth = -1;
|
||||
private $useRefHandles = -1;
|
||||
private $context = [];
|
||||
|
||||
/**
|
||||
* @param array $data An array as returned by ClonerInterface::cloneVar()
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null The type of the value
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
$item = $this->data[$this->position][$this->key];
|
||||
|
||||
if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) {
|
||||
$item = $item->value;
|
||||
}
|
||||
if (!$item instanceof Stub) {
|
||||
return \gettype($item);
|
||||
}
|
||||
if (Stub::TYPE_STRING === $item->type) {
|
||||
return 'string';
|
||||
}
|
||||
if (Stub::TYPE_ARRAY === $item->type) {
|
||||
return 'array';
|
||||
}
|
||||
if (Stub::TYPE_OBJECT === $item->type) {
|
||||
return $item->class;
|
||||
}
|
||||
if (Stub::TYPE_RESOURCE === $item->type) {
|
||||
return $item->class.' resource';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|bool $recursive Whether values should be resolved recursively or not
|
||||
*
|
||||
* @return string|int|float|bool|array|Data[]|null A native representation of the original value
|
||||
*/
|
||||
public function getValue($recursive = false)
|
||||
{
|
||||
$item = $this->data[$this->position][$this->key];
|
||||
|
||||
if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) {
|
||||
$item = $item->value;
|
||||
}
|
||||
if (!($item = $this->getStub($item)) instanceof Stub) {
|
||||
return $item;
|
||||
}
|
||||
if (Stub::TYPE_STRING === $item->type) {
|
||||
return $item->value;
|
||||
}
|
||||
|
||||
$children = $item->position ? $this->data[$item->position] : [];
|
||||
|
||||
foreach ($children as $k => $v) {
|
||||
if ($recursive && !($v = $this->getStub($v)) instanceof Stub) {
|
||||
continue;
|
||||
}
|
||||
$children[$k] = clone $this;
|
||||
$children[$k]->key = $k;
|
||||
$children[$k]->position = $item->position;
|
||||
|
||||
if ($recursive) {
|
||||
if (Stub::TYPE_REF === $v->type && ($v = $this->getStub($v->value)) instanceof Stub) {
|
||||
$recursive = (array) $recursive;
|
||||
if (isset($recursive[$v->position])) {
|
||||
continue;
|
||||
}
|
||||
$recursive[$v->position] = true;
|
||||
}
|
||||
$children[$k] = $children[$k]->getValue($recursive);
|
||||
}
|
||||
}
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \count($this->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
if (!\is_array($value = $this->getValue())) {
|
||||
throw new \LogicException(sprintf('"%s" object holds non-iterable type "%s".', self::class, \gettype($value)));
|
||||
}
|
||||
|
||||
yield from $value;
|
||||
}
|
||||
|
||||
public function __get(string $key)
|
||||
{
|
||||
if (null !== $data = $this->seek($key)) {
|
||||
$item = $this->getStub($data->data[$data->position][$data->key]);
|
||||
|
||||
return $item instanceof Stub || [] === $item ? $data : $item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset(string $key)
|
||||
{
|
||||
return null !== $this->seek($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return $this->__isset($key);
|
||||
}
|
||||
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->__get($key);
|
||||
}
|
||||
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
throw new \BadMethodCallException(self::class.' objects are immutable.');
|
||||
}
|
||||
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
throw new \BadMethodCallException(self::class.' objects are immutable.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$value = $this->getValue();
|
||||
|
||||
if (!\is_array($value)) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
return sprintf('%s (count=%d)', $this->getType(), \count($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a depth limited clone of $this.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withMaxDepth(int $maxDepth)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->maxDepth = (int) $maxDepth;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limits the number of elements per depth level.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withMaxItemsPerDepth(int $maxItemsPerDepth)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables objects' identifiers tracking.
|
||||
*
|
||||
* @param bool $useRefHandles False to hide global ref. handles
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withRefHandles(bool $useRefHandles)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->useRefHandles = $useRefHandles ? -1 : 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function withContext(array $context)
|
||||
{
|
||||
$data = clone $this;
|
||||
$data->context = $context;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeks to a specific key in nested data structures.
|
||||
*
|
||||
* @param string|int $key The key to seek to
|
||||
*
|
||||
* @return static|null Null if the key is not set
|
||||
*/
|
||||
public function seek($key)
|
||||
{
|
||||
$item = $this->data[$this->position][$this->key];
|
||||
|
||||
if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) {
|
||||
$item = $item->value;
|
||||
}
|
||||
if (!($item = $this->getStub($item)) instanceof Stub || !$item->position) {
|
||||
return null;
|
||||
}
|
||||
$keys = [$key];
|
||||
|
||||
switch ($item->type) {
|
||||
case Stub::TYPE_OBJECT:
|
||||
$keys[] = Caster::PREFIX_DYNAMIC.$key;
|
||||
$keys[] = Caster::PREFIX_PROTECTED.$key;
|
||||
$keys[] = Caster::PREFIX_VIRTUAL.$key;
|
||||
$keys[] = "\0$item->class\0$key";
|
||||
// no break
|
||||
case Stub::TYPE_ARRAY:
|
||||
case Stub::TYPE_RESOURCE:
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = null;
|
||||
$children = $this->data[$item->position];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (isset($children[$key]) || \array_key_exists($key, $children)) {
|
||||
$data = clone $this;
|
||||
$data->key = $key;
|
||||
$data->position = $item->position;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps data with a DumperInterface dumper.
|
||||
*/
|
||||
public function dump(DumperInterface $dumper)
|
||||
{
|
||||
$refs = [0];
|
||||
$cursor = new Cursor();
|
||||
|
||||
if ($cursor->attr = $this->context[SourceContextProvider::class] ?? []) {
|
||||
$cursor->attr['if_links'] = true;
|
||||
$cursor->hashType = -1;
|
||||
$dumper->dumpScalar($cursor, 'default', '^');
|
||||
$cursor->attr = ['if_links' => true];
|
||||
$dumper->dumpScalar($cursor, 'default', ' ');
|
||||
$cursor->hashType = 0;
|
||||
}
|
||||
|
||||
$this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depth-first dumping of items.
|
||||
*
|
||||
* @param mixed $item A Stub object or the original value being dumped
|
||||
*/
|
||||
private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, $item)
|
||||
{
|
||||
$cursor->refIndex = 0;
|
||||
$cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0;
|
||||
$cursor->hardRefTo = $cursor->hardRefHandle = $cursor->hardRefCount = 0;
|
||||
$firstSeen = true;
|
||||
|
||||
if (!$item instanceof Stub) {
|
||||
$cursor->attr = [];
|
||||
$type = \gettype($item);
|
||||
if ($item && 'array' === $type) {
|
||||
$item = $this->getStub($item);
|
||||
}
|
||||
} elseif (Stub::TYPE_REF === $item->type) {
|
||||
if ($item->handle) {
|
||||
if (!isset($refs[$r = $item->handle - (PHP_INT_MAX >> 1)])) {
|
||||
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
|
||||
} else {
|
||||
$firstSeen = false;
|
||||
}
|
||||
$cursor->hardRefTo = $refs[$r];
|
||||
$cursor->hardRefHandle = $this->useRefHandles & $item->handle;
|
||||
$cursor->hardRefCount = $item->refCount;
|
||||
}
|
||||
$cursor->attr = $item->attr;
|
||||
$type = $item->class ?: \gettype($item->value);
|
||||
$item = $this->getStub($item->value);
|
||||
}
|
||||
if ($item instanceof Stub) {
|
||||
if ($item->refCount) {
|
||||
if (!isset($refs[$r = $item->handle])) {
|
||||
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
|
||||
} else {
|
||||
$firstSeen = false;
|
||||
}
|
||||
$cursor->softRefTo = $refs[$r];
|
||||
}
|
||||
$cursor->softRefHandle = $this->useRefHandles & $item->handle;
|
||||
$cursor->softRefCount = $item->refCount;
|
||||
$cursor->attr = $item->attr;
|
||||
$cut = $item->cut;
|
||||
|
||||
if ($item->position && $firstSeen) {
|
||||
$children = $this->data[$item->position];
|
||||
|
||||
if ($cursor->stop) {
|
||||
if ($cut >= 0) {
|
||||
$cut += \count($children);
|
||||
}
|
||||
$children = [];
|
||||
}
|
||||
} else {
|
||||
$children = [];
|
||||
}
|
||||
switch ($item->type) {
|
||||
case Stub::TYPE_STRING:
|
||||
$dumper->dumpString($cursor, $item->value, Stub::STRING_BINARY === $item->class, $cut);
|
||||
break;
|
||||
|
||||
case Stub::TYPE_ARRAY:
|
||||
$item = clone $item;
|
||||
$item->type = $item->class;
|
||||
$item->class = $item->value;
|
||||
// no break
|
||||
case Stub::TYPE_OBJECT:
|
||||
case Stub::TYPE_RESOURCE:
|
||||
$withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth;
|
||||
$dumper->enterHash($cursor, $item->type, $item->class, $withChildren);
|
||||
if ($withChildren) {
|
||||
if ($cursor->skipChildren) {
|
||||
$withChildren = false;
|
||||
$cut = -1;
|
||||
} else {
|
||||
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type, null !== $item->class);
|
||||
}
|
||||
} elseif ($children && 0 <= $cut) {
|
||||
$cut += \count($children);
|
||||
}
|
||||
$cursor->skipChildren = false;
|
||||
$dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \RuntimeException(sprintf('Unexpected Stub type: "%s".', $item->type));
|
||||
}
|
||||
} elseif ('array' === $type) {
|
||||
$dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false);
|
||||
$dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0);
|
||||
} elseif ('string' === $type) {
|
||||
$dumper->dumpString($cursor, $item, false, 0);
|
||||
} else {
|
||||
$dumper->dumpScalar($cursor, $type, $item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps children of hash structures.
|
||||
*
|
||||
* @return int The final number of removed items
|
||||
*/
|
||||
private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, array &$refs, array $children, int $hashCut, int $hashType, bool $dumpKeys): int
|
||||
{
|
||||
$cursor = clone $parentCursor;
|
||||
++$cursor->depth;
|
||||
$cursor->hashType = $hashType;
|
||||
$cursor->hashIndex = 0;
|
||||
$cursor->hashLength = \count($children);
|
||||
$cursor->hashCut = $hashCut;
|
||||
foreach ($children as $key => $child) {
|
||||
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
|
||||
$cursor->hashKey = $dumpKeys ? $key : null;
|
||||
$this->dumpItem($dumper, $cursor, $refs, $child);
|
||||
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
|
||||
$parentCursor->stop = true;
|
||||
|
||||
return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut;
|
||||
}
|
||||
}
|
||||
|
||||
return $hashCut;
|
||||
}
|
||||
|
||||
private function getStub($item)
|
||||
{
|
||||
if (!$item || !\is_array($item)) {
|
||||
return $item;
|
||||
}
|
||||
|
||||
$stub = new Stub();
|
||||
$stub->type = Stub::TYPE_ARRAY;
|
||||
foreach ($item as $stub->class => $stub->position) {
|
||||
}
|
||||
if (isset($item[0])) {
|
||||
$stub->cut = $item[0];
|
||||
}
|
||||
$stub->value = $stub->cut + ($stub->position ? \count($this->data[$stub->position]) : 0);
|
||||
|
||||
return $stub;
|
||||
}
|
||||
}
|
||||
56
vendor/symfony/var-dumper/Cloner/DumperInterface.php
vendored
Normal file
56
vendor/symfony/var-dumper/Cloner/DumperInterface.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
/**
|
||||
* DumperInterface used by Data objects.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface DumperInterface
|
||||
{
|
||||
/**
|
||||
* Dumps a scalar value.
|
||||
*
|
||||
* @param string $type The PHP type of the value being dumped
|
||||
* @param string|int|float|bool $value The scalar value being dumped
|
||||
*/
|
||||
public function dumpScalar(Cursor $cursor, string $type, $value);
|
||||
|
||||
/**
|
||||
* Dumps a string.
|
||||
*
|
||||
* @param string $str The string being dumped
|
||||
* @param bool $bin Whether $str is UTF-8 or binary encoded
|
||||
* @param int $cut The number of characters $str has been cut by
|
||||
*/
|
||||
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut);
|
||||
|
||||
/**
|
||||
* Dumps while entering an hash.
|
||||
*
|
||||
* @param int $type A Cursor::HASH_* const for the type of hash
|
||||
* @param string|int $class The object class, resource type or array count
|
||||
* @param bool $hasChild When the dump of the hash has child item
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild);
|
||||
|
||||
/**
|
||||
* Dumps while leaving an hash.
|
||||
*
|
||||
* @param int $type A Cursor::HASH_* const for the type of hash
|
||||
* @param string|int $class The object class, resource type or array count
|
||||
* @param bool $hasChild When the dump of the hash has child item
|
||||
* @param int $cut The number of items the hash has been cut by
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut);
|
||||
}
|
||||
67
vendor/symfony/var-dumper/Cloner/Stub.php
vendored
Normal file
67
vendor/symfony/var-dumper/Cloner/Stub.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Cloner;
|
||||
|
||||
/**
|
||||
* Represents the main properties of a PHP variable.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class Stub
|
||||
{
|
||||
const TYPE_REF = 1;
|
||||
const TYPE_STRING = 2;
|
||||
const TYPE_ARRAY = 3;
|
||||
const TYPE_OBJECT = 4;
|
||||
const TYPE_RESOURCE = 5;
|
||||
|
||||
const STRING_BINARY = 1;
|
||||
const STRING_UTF8 = 2;
|
||||
|
||||
const ARRAY_ASSOC = 1;
|
||||
const ARRAY_INDEXED = 2;
|
||||
|
||||
public $type = self::TYPE_REF;
|
||||
public $class = '';
|
||||
public $value;
|
||||
public $cut = 0;
|
||||
public $handle = 0;
|
||||
public $refCount = 0;
|
||||
public $position = 0;
|
||||
public $attr = [];
|
||||
|
||||
private static $defaultProperties = [];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
$properties = [];
|
||||
|
||||
if (!isset(self::$defaultProperties[$c = static::class])) {
|
||||
self::$defaultProperties[$c] = get_class_vars($c);
|
||||
|
||||
foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
|
||||
unset(self::$defaultProperties[$c][$k]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$defaultProperties[$c] as $k => $v) {
|
||||
if ($this->$k !== $v) {
|
||||
$properties[] = $k;
|
||||
}
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user