Merge branch '2.7' into 2.8
* 2.7: [DoctrineBridge] Fix required guess of boolean fields [DI] don't use array_map to resolve services Remove dead code in the PropertyPath constructor [Process] Inherit env vars by default in PhpProcess Changed one console output style to avoid visual issues [VarDumper] Fix return type and anonymous classes dumping [HttpFoundation] Fixes /0 subnet handling in IpUtils [Form] Simplify DateTimeToStringTransformer Avoid unneeded catch and re-throw of the same exception. [HttpKernel] Remove a duplicate test for the EsiFragmentRenderer Conflicts: src/Symfony/Component/BrowserKit/composer.json src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
This commit is contained in:
commit
dee62e7916
@ -12,8 +12,9 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\Form;
|
namespace Symfony\Bridge\Doctrine\Form;
|
||||||
|
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
|
||||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||||
|
use Doctrine\DBAL\Types\Type;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||||
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
|
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
|
||||||
use Symfony\Component\Form\FormTypeGuesserInterface;
|
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||||
use Symfony\Component\Form\Guess\Guess;
|
use Symfony\Component\Form\Guess\Guess;
|
||||||
@ -51,28 +52,28 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($metadata->getTypeOfField($property)) {
|
switch ($metadata->getTypeOfField($property)) {
|
||||||
case 'array':
|
case Type::TARRAY:
|
||||||
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
|
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
|
||||||
case 'boolean':
|
case Type::BOOLEAN:
|
||||||
return new TypeGuess('checkbox', array(), Guess::HIGH_CONFIDENCE);
|
return new TypeGuess('checkbox', array(), Guess::HIGH_CONFIDENCE);
|
||||||
case 'datetime':
|
case Type::DATETIME:
|
||||||
|
case Type::DATETIMETZ:
|
||||||
case 'vardatetime':
|
case 'vardatetime':
|
||||||
case 'datetimetz':
|
|
||||||
return new TypeGuess('datetime', array(), Guess::HIGH_CONFIDENCE);
|
return new TypeGuess('datetime', array(), Guess::HIGH_CONFIDENCE);
|
||||||
case 'date':
|
case Type::DATE:
|
||||||
return new TypeGuess('date', array(), Guess::HIGH_CONFIDENCE);
|
return new TypeGuess('date', array(), Guess::HIGH_CONFIDENCE);
|
||||||
case 'time':
|
case Type::TIME:
|
||||||
return new TypeGuess('time', array(), Guess::HIGH_CONFIDENCE);
|
return new TypeGuess('time', array(), Guess::HIGH_CONFIDENCE);
|
||||||
case 'decimal':
|
case Type::DECIMAL:
|
||||||
case 'float':
|
case Type::FLOAT:
|
||||||
return new TypeGuess('number', array(), Guess::MEDIUM_CONFIDENCE);
|
return new TypeGuess('number', array(), Guess::MEDIUM_CONFIDENCE);
|
||||||
case 'integer':
|
case Type::INTEGER:
|
||||||
case 'bigint':
|
case Type::BIGINT:
|
||||||
case 'smallint':
|
case Type::SMALLINT:
|
||||||
return new TypeGuess('integer', array(), Guess::MEDIUM_CONFIDENCE);
|
return new TypeGuess('integer', array(), Guess::MEDIUM_CONFIDENCE);
|
||||||
case 'string':
|
case Type::STRING:
|
||||||
return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE);
|
return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE);
|
||||||
case 'text':
|
case Type::TEXT:
|
||||||
return new TypeGuess('textarea', array(), Guess::MEDIUM_CONFIDENCE);
|
return new TypeGuess('textarea', array(), Guess::MEDIUM_CONFIDENCE);
|
||||||
default:
|
default:
|
||||||
return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE);
|
return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE);
|
||||||
@ -95,7 +96,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
|
|
||||||
// Check whether the field exists and is nullable or not
|
// Check whether the field exists and is nullable or not
|
||||||
if ($classMetadata->hasField($property)) {
|
if ($classMetadata->hasField($property)) {
|
||||||
if (!$classMetadata->isNullable($property)) {
|
if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) {
|
||||||
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
|
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($ret[0]->getTypeOfField($property), array('decimal', 'float'))) {
|
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
{
|
{
|
||||||
$ret = $this->getMetadata($class);
|
$ret = $this->getMetadata($class);
|
||||||
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
|
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
|
||||||
if (in_array($ret[0]->getTypeOfField($property), array('decimal', 'float'))) {
|
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,8 +347,7 @@ abstract class Client
|
|||||||
*/
|
*/
|
||||||
protected function doRequestInProcess($request)
|
protected function doRequestInProcess($request)
|
||||||
{
|
{
|
||||||
// We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user.
|
$process = new PhpProcess($this->getScript($request), null, null);
|
||||||
$process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir()));
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
|
if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0"
|
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/process": "~2.0,>=2.0.5|~3.0.0",
|
"symfony/process": "~2.3.34|~2.7,>=2.7.6|~3.0.0",
|
||||||
"symfony/css-selector": "~2.0,>=2.0.5|~3.0.0"
|
"symfony/css-selector": "~2.0,>=2.0.5|~3.0.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
@ -283,7 +283,7 @@ class ClassCollectionLoader
|
|||||||
|
|
||||||
$traits = array();
|
$traits = array();
|
||||||
|
|
||||||
if (function_exists('get_declared_traits')) {
|
if (method_exists('ReflectionClass', 'getTraits')) {
|
||||||
foreach ($classes as $c) {
|
foreach ($classes as $c) {
|
||||||
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
||||||
if ($trait !== $c) {
|
if ($trait !== $c) {
|
||||||
|
@ -173,7 +173,7 @@ class SymfonyStyle extends OutputStyle
|
|||||||
*/
|
*/
|
||||||
public function success($message)
|
public function success($message)
|
||||||
{
|
{
|
||||||
$this->block($message, 'OK', 'fg=white;bg=green', ' ', true);
|
$this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -973,7 +973,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
public function resolveServices($value)
|
public function resolveServices($value)
|
||||||
{
|
{
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = array_map(array($this, 'resolveServices'), $value);
|
foreach ($value as $k => $v) {
|
||||||
|
$value[$k] = $this->resolveServices($v);
|
||||||
|
}
|
||||||
} elseif ($value instanceof Reference) {
|
} elseif ($value instanceof Reference) {
|
||||||
$value = $this->get((string) $value, $value->getInvalidBehavior());
|
$value = $this->get((string) $value, $value->getInvalidBehavior());
|
||||||
} elseif ($value instanceof Definition) {
|
} elseif ($value instanceof Definition) {
|
||||||
|
@ -86,7 +86,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
|||||||
* Transforms a DateTime object into a date string with the configured format
|
* Transforms a DateTime object into a date string with the configured format
|
||||||
* and timezone.
|
* and timezone.
|
||||||
*
|
*
|
||||||
* @param \DateTime|\DateTimeInterface $dateTime A DateTime object
|
* @param \DateTime|\DateTimeInterface $value A DateTime object
|
||||||
*
|
*
|
||||||
* @return string A value as produced by PHP's date() function
|
* @return string A value as produced by PHP's date() function
|
||||||
*
|
*
|
||||||
@ -138,7 +138,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
|||||||
throw new TransformationFailedException('Expected a string.');
|
throw new TransformationFailedException('Expected a string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$outputTz = new \DateTimeZone($this->outputTimezone);
|
$outputTz = new \DateTimeZone($this->outputTimezone);
|
||||||
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
|
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
|
||||||
|
|
||||||
@ -153,6 +152,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// On PHP versions < 5.3.7 we need to emulate the pipe operator
|
// On PHP versions < 5.3.7 we need to emulate the pipe operator
|
||||||
// and reset parts not given in the format to their equivalent
|
// and reset parts not given in the format to their equivalent
|
||||||
// of the UNIX base timestamp.
|
// of the UNIX base timestamp.
|
||||||
@ -220,8 +220,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
|||||||
if ($this->inputTimezone !== $this->outputTimezone) {
|
if ($this->inputTimezone !== $this->outputTimezone) {
|
||||||
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
|
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
|
||||||
}
|
}
|
||||||
} catch (TransformationFailedException $e) {
|
|
||||||
throw $e;
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
|
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
@ -57,18 +57,19 @@ class IpUtils
|
|||||||
* @param string $requestIp IPv4 address to check
|
* @param string $requestIp IPv4 address to check
|
||||||
* @param string $ip IPv4 address or subnet in CIDR notation
|
* @param string $ip IPv4 address or subnet in CIDR notation
|
||||||
*
|
*
|
||||||
* @return bool Whether the IP is valid
|
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet.
|
||||||
*/
|
*/
|
||||||
public static function checkIp4($requestIp, $ip)
|
public static function checkIp4($requestIp, $ip)
|
||||||
{
|
{
|
||||||
if (false !== strpos($ip, '/')) {
|
if (false !== strpos($ip, '/')) {
|
||||||
if ('0.0.0.0/0' === $ip) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
list($address, $netmask) = explode('/', $ip, 2);
|
list($address, $netmask) = explode('/', $ip, 2);
|
||||||
|
|
||||||
if ($netmask < 1 || $netmask > 32) {
|
if ($netmask === '0') {
|
||||||
|
// Ensure IP is valid - using ip2long below implicitly validates, but we need to do it manually here
|
||||||
|
return filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($netmask < 0 || $netmask > 32) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,13 +30,13 @@ class IpUtilsTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(true, '192.168.1.1', '192.168.1.1/1'),
|
array(true, '192.168.1.1', '192.168.1.1/1'),
|
||||||
array(true, '192.168.1.1', '192.168.1.0/24'),
|
array(true, '192.168.1.1', '192.168.1.0/24'),
|
||||||
array(false, '192.168.1.1', '1.2.3.4/1'),
|
array(false, '192.168.1.1', '1.2.3.4/1'),
|
||||||
array(false, '192.168.1.1', '192.168.1/33'),
|
array(false, '192.168.1.1', '192.168.1.1/33'), // invalid subnet
|
||||||
array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
|
array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
|
||||||
array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
|
array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
|
||||||
array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
|
array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
|
||||||
array(true, '1.2.3.4', '0.0.0.0/0'),
|
array(true, '1.2.3.4', '0.0.0.0/0'),
|
||||||
array(false, '1.2.3.4', '256.256.256/0'),
|
array(true, '1.2.3.4', '192.168.1.0/0'),
|
||||||
array(false, '1.2.3.4', '192.168.1.0/0'),
|
array(false, '1.2.3.4', '256.256.256/0'), // invalid CIDR notation
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,6 @@ use Symfony\Component\HttpKernel\UriSigner;
|
|||||||
|
|
||||||
class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testRenderFallbackToInlineStrategyIfNoRequest()
|
|
||||||
{
|
|
||||||
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true));
|
|
||||||
$strategy->render('/', Request::create('/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
|
public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
|
||||||
{
|
{
|
||||||
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true));
|
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true));
|
||||||
|
@ -28,12 +28,12 @@ class PhpProcess extends Process
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $script The PHP script to run (as a string)
|
* @param string $script The PHP script to run (as a string)
|
||||||
* @param string $cwd The working directory
|
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
|
||||||
* @param array $env The environment variables
|
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
|
||||||
* @param int $timeout The timeout in seconds
|
* @param int $timeout The timeout in seconds
|
||||||
* @param array $options An array of options for proc_open
|
* @param array $options An array of options for proc_open
|
||||||
*/
|
*/
|
||||||
public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array())
|
public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
|
||||||
{
|
{
|
||||||
$executableFinder = new PhpExecutableFinder();
|
$executableFinder = new PhpExecutableFinder();
|
||||||
if (false === $php = $executableFinder->find()) {
|
if (false === $php = $executableFinder->find()) {
|
||||||
|
@ -131,7 +131,7 @@ class Process
|
|||||||
*
|
*
|
||||||
* @param string $commandline The command line to run
|
* @param string $commandline The command line to run
|
||||||
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
|
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
|
||||||
* @param array|null $env The environment variables or null to inherit
|
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
|
||||||
* @param string|null $input The input
|
* @param string|null $input The input
|
||||||
* @param int|float|null $timeout The timeout in seconds or null to disable
|
* @param int|float|null $timeout The timeout in seconds or null to disable
|
||||||
* @param array $options An array of options for proc_open
|
* @param array $options An array of options for proc_open
|
||||||
@ -1030,7 +1030,7 @@ class Process
|
|||||||
|
|
||||||
$this->env = array();
|
$this->env = array();
|
||||||
foreach ($env as $key => $value) {
|
foreach ($env as $key => $value) {
|
||||||
$this->env[(binary) $key] = (binary) $value;
|
$this->env[$key] = (string) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -36,13 +36,6 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
|||||||
*/
|
*/
|
||||||
private $elements = array();
|
private $elements = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The singular forms of the elements in the property path.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $singulars = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of elements in the property path.
|
* The number of elements in the property path.
|
||||||
*
|
*
|
||||||
@ -79,7 +72,6 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
|||||||
if ($propertyPath instanceof self) {
|
if ($propertyPath instanceof self) {
|
||||||
/* @var PropertyPath $propertyPath */
|
/* @var PropertyPath $propertyPath */
|
||||||
$this->elements = $propertyPath->elements;
|
$this->elements = $propertyPath->elements;
|
||||||
$this->singulars = $propertyPath->singulars;
|
|
||||||
$this->length = $propertyPath->length;
|
$this->length = $propertyPath->length;
|
||||||
$this->isIndex = $propertyPath->isIndex;
|
$this->isIndex = $propertyPath->isIndex;
|
||||||
$this->pathAsString = $propertyPath->pathAsString;
|
$this->pathAsString = $propertyPath->pathAsString;
|
||||||
@ -115,16 +107,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
|||||||
$this->isIndex[] = true;
|
$this->isIndex[] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pos = false;
|
|
||||||
$singular = null;
|
|
||||||
|
|
||||||
if (false !== $pos) {
|
|
||||||
$singular = substr($element, $pos + 1);
|
|
||||||
$element = substr($element, 0, $pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->elements[] = $element;
|
$this->elements[] = $element;
|
||||||
$this->singulars[] = $singular;
|
|
||||||
|
|
||||||
$position += strlen($matches[1]);
|
$position += strlen($matches[1]);
|
||||||
$remaining = $matches[4];
|
$remaining = $matches[4];
|
||||||
@ -173,7 +156,6 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
|||||||
--$parent->length;
|
--$parent->length;
|
||||||
$parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '[')));
|
$parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '[')));
|
||||||
array_pop($parent->elements);
|
array_pop($parent->elements);
|
||||||
array_pop($parent->singulars);
|
|
||||||
array_pop($parent->isIndex);
|
array_pop($parent->isIndex);
|
||||||
|
|
||||||
return $parent;
|
return $parent;
|
||||||
|
@ -54,6 +54,8 @@ class Caster
|
|||||||
foreach ($p as $i => $k) {
|
foreach ($p as $i => $k) {
|
||||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($k))) {
|
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($k))) {
|
||||||
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
||||||
|
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
||||||
|
$p[$i] = "\0anonymous-".$reflector->name.strrchr($k, "\0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$a = array_combine($p, $a);
|
$a = array_combine($p, $a);
|
||||||
|
@ -114,6 +114,9 @@ class ReflectionCaster
|
|||||||
'this' => 'getClosureThis',
|
'this' => 'getClosureThis',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if (isset($a[$prefix.'returnType'])) {
|
||||||
|
$a[$prefix.'returnType'] = (string) $a[$prefix.'returnType'];
|
||||||
|
}
|
||||||
if (isset($a[$prefix.'this'])) {
|
if (isset($a[$prefix.'this'])) {
|
||||||
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
|
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
|
||||||
}
|
}
|
||||||
|
@ -223,9 +223,12 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
$obj = $stub->value;
|
$obj = $stub->value;
|
||||||
$class = $stub->class;
|
$class = $stub->class;
|
||||||
|
|
||||||
|
if (isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00")) {
|
||||||
|
$class = get_parent_class($class);
|
||||||
|
$stub->class = 'anonymous-'.$class;
|
||||||
|
}
|
||||||
if (isset($this->classInfo[$class])) {
|
if (isset($this->classInfo[$class])) {
|
||||||
$classInfo = $this->classInfo[$class];
|
$classInfo = $this->classInfo[$class];
|
||||||
$stub->class = $classInfo[0];
|
|
||||||
} else {
|
} else {
|
||||||
$classInfo = array(
|
$classInfo = array(
|
||||||
$class,
|
$class,
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
namespace Symfony\Component\VarDumper\Tests\Caster;
|
namespace Symfony\Component\VarDumper\Tests\Caster;
|
||||||
|
|
||||||
use Symfony\Component\VarDumper\Caster\Caster;
|
use Symfony\Component\VarDumper\Caster\Caster;
|
||||||
|
use Symfony\Component\VarDumper\Test\VarDumperTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
*/
|
*/
|
||||||
class CasterTest extends \PHPUnit_Framework_TestCase
|
class CasterTest extends VarDumperTestCase
|
||||||
{
|
{
|
||||||
private $referenceArray = array(
|
private $referenceArray = array(
|
||||||
'null' => null,
|
'null' => null,
|
||||||
@ -28,7 +29,9 @@ class CasterTest extends \PHPUnit_Framework_TestCase
|
|||||||
"\0Foo\0private" => 'priv',
|
"\0Foo\0private" => 'priv',
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @dataProvider provideFilter */
|
/**
|
||||||
|
* @dataProvider provideFilter
|
||||||
|
*/
|
||||||
public function testFilter($filter, $expectedDiff, $listedProperties = null)
|
public function testFilter($filter, $expectedDiff, $listedProperties = null)
|
||||||
{
|
{
|
||||||
if (null === $listedProperties) {
|
if (null === $listedProperties) {
|
||||||
@ -144,4 +147,21 @@ class CasterTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires PHP 7.0
|
||||||
|
*/
|
||||||
|
public function testAnonymousClass()
|
||||||
|
{
|
||||||
|
$c = eval('return new class extends stdClass { private $foo = "foo"; };');
|
||||||
|
|
||||||
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
|
anonymous-stdClass {
|
||||||
|
-foo: "foo"
|
||||||
|
}
|
||||||
|
EOTXT
|
||||||
|
, $c
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,4 +78,25 @@ EOTXT
|
|||||||
, $var
|
, $var
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires PHP 7.0
|
||||||
|
*/
|
||||||
|
public function testReturnType()
|
||||||
|
{
|
||||||
|
$f = eval('return function ():int {};');
|
||||||
|
|
||||||
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
|
Closure {
|
||||||
|
returnType: "int"
|
||||||
|
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
|
||||||
|
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
|
||||||
|
file: "%sReflectionCasterTest.php(87) : eval()'d code"
|
||||||
|
line: "1 to 1"
|
||||||
|
}
|
||||||
|
EOTXT
|
||||||
|
, $f
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user