Merge branch '2.8'
* 2.8: fixed deprecation notices fixed typos [FrameworkBundle] Tag deprecated services [VarDumper] Dump PHP+Twig code excerpts in backtraces [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors
This commit is contained in:
commit
ed610df788
@ -7,6 +7,7 @@
|
|||||||
<services>
|
<services>
|
||||||
<service id="form.csrf_provider" class="Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter">
|
<service id="form.csrf_provider" class="Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter">
|
||||||
<argument type="service" id="security.csrf.token_manager" />
|
<argument type="service" id="security.csrf.token_manager" />
|
||||||
|
<deprecated>The "%service_id%" service is deprecated since Symfony 2.4 and will be removed in 3.0. Use the "security.csrf.token_manager" service instead.</deprecated>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="form.type_extension.csrf" class="Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension">
|
<service id="form.type_extension.csrf" class="Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension">
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
</argument>
|
</argument>
|
||||||
|
<deprecated>The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0.</deprecated>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="validator.validator_factory" class="Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory" public="false">
|
<service id="validator.validator_factory" class="Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory" public="false">
|
||||||
|
@ -303,9 +303,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
if (isset($this->children[$name])) {
|
if (isset($this->children[$name])) {
|
||||||
$normalized[$name] = $this->children[$name]->normalize($val);
|
$normalized[$name] = $this->children[$name]->normalize($val);
|
||||||
unset($value[$name]);
|
unset($value[$name]);
|
||||||
} elseif (false === $this->removeExtraKeys) {
|
} elseif (!$this->removeExtraKeys) {
|
||||||
$normalized[$name] = $val;
|
$normalized[$name] = $val;
|
||||||
unset($value[$name]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Config\Tests\Definition;
|
namespace Symfony\Component\Config\Tests\Definition;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\ArrayNode;
|
use Symfony\Component\Config\Definition\ArrayNode;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\Config\Definition\ScalarNode;
|
use Symfony\Component\Config\Definition\ScalarNode;
|
||||||
|
|
||||||
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -35,34 +36,30 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$node->normalize(array('foo' => 'bar'));
|
$node->normalize(array('foo' => 'bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function ignoreAndRemoveMatrixProvider()
|
||||||
* Tests that no exception is thrown for an unrecognized child if the
|
|
||||||
* ignoreExtraKeys option is set to true.
|
|
||||||
*
|
|
||||||
* Related to testExceptionThrownOnUnrecognizedChild
|
|
||||||
*/
|
|
||||||
public function testIgnoreExtraKeysNoException()
|
|
||||||
{
|
{
|
||||||
$node = new ArrayNode('roo');
|
$unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"');
|
||||||
$node->setIgnoreExtraKeys(true);
|
|
||||||
|
|
||||||
$node->normalize(array('foo' => 'bar'));
|
return array(
|
||||||
$this->assertTrue(true, 'No exception was thrown when setIgnoreExtraKeys is true');
|
array(true, true, array(), 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'),
|
||||||
|
array(true, false, array('foo' => 'bar'), 'extra keys are not removed when ignoreExtraKeys second option is set to false'),
|
||||||
|
array(false, true, $unrecognizedOptionException),
|
||||||
|
array(false, false, $unrecognizedOptionException),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that extra keys are not removed when
|
* @dataProvider ignoreAndRemoveMatrixProvider
|
||||||
* ignoreExtraKeys second option is set to false.
|
|
||||||
*
|
|
||||||
* Related to testExceptionThrownOnUnrecognizedChild
|
|
||||||
*/
|
*/
|
||||||
public function testIgnoreExtraKeysNotRemoved()
|
public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '')
|
||||||
{
|
{
|
||||||
$node = new ArrayNode('roo');
|
if ($expected instanceof \Exception) {
|
||||||
$node->setIgnoreExtraKeys(true, false);
|
$this->setExpectedException(get_class($expected), $expected->getMessage());
|
||||||
|
}
|
||||||
$data = array('foo' => 'bar');
|
$node = new ArrayNode('root');
|
||||||
$this->assertSame($data, $node->normalize($data));
|
$node->setIgnoreExtraKeys($ignore, $remove);
|
||||||
|
$result = $node->normalize(array('foo' => 'bar'));
|
||||||
|
$this->assertSame($expected, $result, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\CssSelector;
|
namespace Symfony\Component\CssSelector;
|
||||||
|
|
||||||
@trigger_error('The '.__NAMESPACE__.'\CssSelector class is deprecated since version 2.8 and will be removed in 3.0. Use directly the \Symfony\Component\CssSelector\Converter class instead.', E_USER_DEPRECATED);
|
@trigger_error('The '.__NAMESPACE__.'\CssSelector class is deprecated since version 2.8 and will be removed in 3.0. Use directly the \Symfony\Component\CssSelector\CssSelectorConverter class instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CssSelector is the main entry point of the component and can convert CSS
|
* CssSelector is the main entry point of the component and can convert CSS
|
||||||
@ -57,7 +57,7 @@ namespace Symfony\Component\CssSelector;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*
|
*
|
||||||
* @deprecated as of 2.8, will be removed in 3.0. Use the \Symfony\Component\CssSelector\Converter class instead.
|
* @deprecated as of 2.8, will be removed in 3.0. Use the \Symfony\Component\CssSelector\CssSelectorConverter class instead.
|
||||||
*/
|
*/
|
||||||
class CssSelector
|
class CssSelector
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ class CssSelector
|
|||||||
*/
|
*/
|
||||||
public static function toXPath($cssExpr, $prefix = 'descendant-or-self::')
|
public static function toXPath($cssExpr, $prefix = 'descendant-or-self::')
|
||||||
{
|
{
|
||||||
$converter = new Converter(self::$html);
|
$converter = new CssSelectorConverter(self::$html);
|
||||||
|
|
||||||
return $converter->toXPath($cssExpr, $prefix);
|
return $converter->toXPath($cssExpr, $prefix);
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\CssSelector\Tests;
|
namespace Symfony\Component\CssSelector\Tests;
|
||||||
|
|
||||||
use Symfony\Component\CssSelector\Converter;
|
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||||
|
|
||||||
class ConverterTest extends \PHPUnit_Framework_TestCase
|
class CssSelectorConverterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testCssToXPath()
|
public function testCssToXPath()
|
||||||
{
|
{
|
||||||
$converter = new Converter();
|
$converter = new CssSelectorConverter();
|
||||||
|
|
||||||
$this->assertEquals('descendant-or-self::*', $converter->toXPath(''));
|
$this->assertEquals('descendant-or-self::*', $converter->toXPath(''));
|
||||||
$this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1'));
|
$this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1'));
|
||||||
@ -29,7 +29,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testCssToXPathXml()
|
public function testCssToXPathXml()
|
||||||
{
|
{
|
||||||
$converter = new Converter(false);
|
$converter = new CssSelectorConverter(false);
|
||||||
|
|
||||||
$this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1'));
|
$this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1'));
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\DomCrawler;
|
namespace Symfony\Component\DomCrawler;
|
||||||
|
|
||||||
use Symfony\Component\CssSelector\Converter;
|
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crawler eases navigation of a list of \DOMElement objects.
|
* Crawler eases navigation of a list of \DOMElement objects.
|
||||||
@ -41,7 +41,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
private $baseHref;
|
private $baseHref;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath)
|
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@ -659,11 +659,11 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function filter($selector)
|
public function filter($selector)
|
||||||
{
|
{
|
||||||
if (!class_exists('Symfony\\Component\\CssSelector\\Converter')) {
|
if (!class_exists('Symfony\\Component\\CssSelector\\CssSelectorConverter')) {
|
||||||
throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
|
throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
|
||||||
}
|
}
|
||||||
|
|
||||||
$converter = new Converter($this->isHtml);
|
$converter = new CssSelectorConverter($this->isHtml);
|
||||||
|
|
||||||
// The CssSelector already prefixes the selector with descendant-or-self::
|
// The CssSelector already prefixes the selector with descendant-or-self::
|
||||||
return $this->filterRelativeXPath($converter->toXPath($selector));
|
return $this->filterRelativeXPath($converter->toXPath($selector));
|
||||||
@ -1142,7 +1142,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a crawler for some subnodes
|
* Creates a crawler for some subnodes.
|
||||||
*
|
*
|
||||||
* @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
|
* @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
|
||||||
*
|
*
|
||||||
|
@ -16,13 +16,13 @@ use Symfony\Component\HttpKernel\Profiler\Profile;
|
|||||||
|
|
||||||
class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
||||||
{
|
{
|
||||||
protected static $tmpDir;
|
private $tmpDir;
|
||||||
protected static $storage;
|
private $storage;
|
||||||
|
|
||||||
protected static function cleanDir()
|
protected function cleanDir()
|
||||||
{
|
{
|
||||||
$flags = \FilesystemIterator::SKIP_DOTS;
|
$flags = \FilesystemIterator::SKIP_DOTS;
|
||||||
$iterator = new \RecursiveDirectoryIterator(self::$tmpDir, $flags);
|
$iterator = new \RecursiveDirectoryIterator($this->tmpDir, $flags);
|
||||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
@ -32,23 +32,19 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage';
|
|
||||||
if (is_dir(self::$tmpDir)) {
|
|
||||||
self::cleanDir();
|
|
||||||
}
|
|
||||||
self::$storage = new FileProfilerStorage('file:'.self::$tmpDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
self::cleanDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
self::$storage->purge();
|
$this->tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage';
|
||||||
|
if (is_dir($this->tmpDir)) {
|
||||||
|
self::cleanDir();
|
||||||
|
}
|
||||||
|
$this->storage = new FileProfilerStorage('file:'.$this->tmpDir);
|
||||||
|
$this->storage->purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
self::cleanDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +52,7 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
*/
|
*/
|
||||||
protected function getStorage()
|
protected function getStorage()
|
||||||
{
|
{
|
||||||
return self::$storage;
|
return $this->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMultiRowIndexFile()
|
public function testMultiRowIndexFile()
|
||||||
@ -73,7 +69,7 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
$storage->write($profile);
|
$storage->write($profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$handle = fopen(self::$tmpDir.'/index.csv', 'r');
|
$handle = fopen($this->tmpDir.'/index.csv', 'r');
|
||||||
for ($i = 0; $i < $iteration; ++$i) {
|
for ($i = 0; $i < $iteration; ++$i) {
|
||||||
$row = fgetcsv($handle);
|
$row = fgetcsv($handle);
|
||||||
$this->assertEquals('token'.$i, $row[0]);
|
$this->assertEquals('token'.$i, $row[0]);
|
||||||
@ -85,7 +81,7 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
|
|
||||||
public function testReadLineFromFile()
|
public function testReadLineFromFile()
|
||||||
{
|
{
|
||||||
$r = new \ReflectionMethod(self::$storage, 'readLineFromFile');
|
$r = new \ReflectionMethod($this->storage, 'readLineFromFile');
|
||||||
|
|
||||||
$r->setAccessible(true);
|
$r->setAccessible(true);
|
||||||
|
|
||||||
@ -94,7 +90,7 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
fwrite($h, "line1\n\n\nline2\n");
|
fwrite($h, "line1\n\n\nline2\n");
|
||||||
fseek($h, 0, SEEK_END);
|
fseek($h, 0, SEEK_END);
|
||||||
|
|
||||||
$this->assertEquals('line2', $r->invoke(self::$storage, $h));
|
$this->assertEquals('line2', $r->invoke($this->storage, $h));
|
||||||
$this->assertEquals('line1', $r->invoke(self::$storage, $h));
|
$this->assertEquals('line1', $r->invoke($this->storage, $h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,6 @@ use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class DummyMongoDbProfilerStorage extends MongoDbProfilerStorage
|
|
||||||
{
|
|
||||||
public function getMongo()
|
|
||||||
{
|
|
||||||
return parent::getMongo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MongoDbProfilerStorageTestDataCollector extends DataCollector
|
class MongoDbProfilerStorageTestDataCollector extends DataCollector
|
||||||
{
|
{
|
||||||
public function setData($data)
|
public function setData($data)
|
||||||
@ -52,27 +44,7 @@ class MongoDbProfilerStorageTestDataCollector extends DataCollector
|
|||||||
*/
|
*/
|
||||||
class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
||||||
{
|
{
|
||||||
protected static $storage;
|
private $storage;
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
if (extension_loaded('mongo')) {
|
|
||||||
self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
|
|
||||||
try {
|
|
||||||
self::$storage->getMongo();
|
|
||||||
} catch (\MongoConnectionException $e) {
|
|
||||||
self::$storage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
if (self::$storage) {
|
|
||||||
self::$storage->purge();
|
|
||||||
self::$storage = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDsns()
|
public function getDsns()
|
||||||
{
|
{
|
||||||
@ -108,12 +80,12 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
$profile = new Profile('time_'.$i);
|
$profile = new Profile('time_'.$i);
|
||||||
$profile->setTime($dt->getTimestamp());
|
$profile->setTime($dt->getTimestamp());
|
||||||
$profile->setMethod('GET');
|
$profile->setMethod('GET');
|
||||||
self::$storage->write($profile);
|
$this->storage->write($profile);
|
||||||
}
|
}
|
||||||
$records = self::$storage->find('', '', 3, 'GET');
|
$records = $this->storage->find('', '', 3, 'GET');
|
||||||
$this->assertCount(1, $records, '->find() returns only one record');
|
$this->assertCount(1, $records, '->find() returns only one record');
|
||||||
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
|
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
|
||||||
self::$storage->purge();
|
$this->storage->purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,10 +93,10 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
*/
|
*/
|
||||||
public function testDsnParser($dsn, $expected)
|
public function testDsnParser($dsn, $expected)
|
||||||
{
|
{
|
||||||
$m = new \ReflectionMethod(self::$storage, 'parseDsn');
|
$m = new \ReflectionMethod($this->storage, 'parseDsn');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
|
|
||||||
$this->assertEquals($expected, $m->invoke(self::$storage, $dsn));
|
$this->assertEquals($expected, $m->invoke($this->storage, $dsn));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUtf8()
|
public function testUtf8()
|
||||||
@ -139,9 +111,9 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
|
|
||||||
$profile->setCollectors(array($collector));
|
$profile->setCollectors(array($collector));
|
||||||
|
|
||||||
self::$storage->write($profile);
|
$this->storage->write($profile);
|
||||||
|
|
||||||
$readProfile = self::$storage->read('utf8_test_profile');
|
$readProfile = $this->storage->read('utf8_test_profile');
|
||||||
$collectors = $readProfile->getCollectors();
|
$collectors = $readProfile->getCollectors();
|
||||||
|
|
||||||
$this->assertCount(1, $collectors);
|
$this->assertCount(1, $collectors);
|
||||||
@ -154,15 +126,31 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
*/
|
*/
|
||||||
protected function getStorage()
|
protected function getStorage()
|
||||||
{
|
{
|
||||||
return self::$storage;
|
return $this->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
if (self::$storage) {
|
if (!extension_loaded('mongo')) {
|
||||||
self::$storage->purge();
|
|
||||||
} else {
|
|
||||||
$this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost');
|
$this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->storage = new MongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
|
||||||
|
$m = new \ReflectionMethod($this->storage, 'getMongo');
|
||||||
|
$m->setAccessible(true);
|
||||||
|
try {
|
||||||
|
$m->invoke($this->storage);
|
||||||
|
} catch (\MongoConnectionException $e) {
|
||||||
|
$this->storage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->storage->purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
if ($this->storage) {
|
||||||
|
$this->storage->purge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,29 +18,27 @@ use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage;
|
|||||||
*/
|
*/
|
||||||
class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
|
class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
|
||||||
{
|
{
|
||||||
protected static $dbFile;
|
private $dbFile;
|
||||||
protected static $storage;
|
private $storage;
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_storage');
|
|
||||||
if (file_exists(self::$dbFile)) {
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
self::$storage = new SqliteProfilerStorage('sqlite:'.self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
@unlink(self::$dbFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
|
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
|
||||||
$this->markTestSkipped('This test requires SQLite support in your environment');
|
$this->markTestSkipped('This test requires SQLite support in your environment');
|
||||||
}
|
}
|
||||||
self::$storage->purge();
|
|
||||||
|
$this->dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_storage');
|
||||||
|
if (file_exists($this->dbFile)) {
|
||||||
|
@unlink($this->dbFile);
|
||||||
|
}
|
||||||
|
$this->storage = new SqliteProfilerStorage('sqlite:'.$this->dbFile);
|
||||||
|
|
||||||
|
$this->storage->purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
@unlink($this->dbFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +46,6 @@ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
|
|||||||
*/
|
*/
|
||||||
protected function getStorage()
|
protected function getStorage()
|
||||||
{
|
{
|
||||||
return self::$storage;
|
return $this->storage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ class ExceptionCaster
|
|||||||
|
|
||||||
public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0)
|
public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0)
|
||||||
{
|
{
|
||||||
return self::filterExceptionArray($a, "\0Error\0", $filter);
|
return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
|
public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0)
|
||||||
{
|
{
|
||||||
return self::filterExceptionArray($a, "\0Exception\0", $filter);
|
return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
|
||||||
@ -64,24 +64,133 @@ class ExceptionCaster
|
|||||||
$prefix = Caster::PREFIX_PROTECTED;
|
$prefix = Caster::PREFIX_PROTECTED;
|
||||||
$xPrefix = "\0Exception\0";
|
$xPrefix = "\0Exception\0";
|
||||||
|
|
||||||
if (isset($a[$xPrefix.'previous'], $a[$xPrefix.'trace'][0])) {
|
if (isset($a[$xPrefix.'previous'], $a[$xPrefix.'trace'])) {
|
||||||
$b = (array) $a[$xPrefix.'previous'];
|
$b = (array) $a[$xPrefix.'previous'];
|
||||||
$b[$xPrefix.'trace'][0] += array(
|
array_unshift($b[$xPrefix.'trace'], array(
|
||||||
|
'function' => 'new '.get_class($a[$xPrefix.'previous']),
|
||||||
'file' => $b[$prefix.'file'],
|
'file' => $b[$prefix.'file'],
|
||||||
'line' => $b[$prefix.'line'],
|
'line' => $b[$prefix.'line'],
|
||||||
);
|
));
|
||||||
array_splice($b[$xPrefix.'trace'], -1 - count($a[$xPrefix.'trace']));
|
$a[$xPrefix.'trace'] = new TraceStub($b[$xPrefix.'trace'], 1, false, 0, -1 - count($a[$xPrefix.'trace']->value));
|
||||||
static::filterTrace($b[$xPrefix.'trace'], false);
|
|
||||||
$a[Caster::PREFIX_VIRTUAL.'trace'] = $b[$xPrefix.'trace'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($a[$xPrefix.'trace'], $a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $isNested)
|
||||||
|
{
|
||||||
|
if (!$isNested) {
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
$stub->class = '';
|
||||||
|
$stub->handle = 0;
|
||||||
|
$frames = $trace->value;
|
||||||
|
|
||||||
|
$a = array();
|
||||||
|
$j = count($frames);
|
||||||
|
if (0 > $i = $trace->offset) {
|
||||||
|
$i = max(0, $j + $i);
|
||||||
|
}
|
||||||
|
if (!isset($trace->value[$i])) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$lastCall = isset($frames[$i]['function']) ? ' ==> '.(isset($frames[$i]['class']) ? $frames[0]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : '';
|
||||||
|
|
||||||
|
for ($j -= $i++; isset($frames[$i]); ++$i, --$j) {
|
||||||
|
$call = isset($frames[$i]['function']) ? (isset($frames[$i]['class']) ? $frames[$i]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : '???';
|
||||||
|
|
||||||
|
$a[Caster::PREFIX_VIRTUAL.$j.'. '.$call.$lastCall] = new FrameStub(
|
||||||
|
array(
|
||||||
|
'object' => isset($frames[$i]['object']) ? $frames[$i]['object'] : null,
|
||||||
|
'class' => isset($frames[$i]['class']) ? $frames[$i]['class'] : null,
|
||||||
|
'type' => isset($frames[$i]['type']) ? $frames[$i]['type'] : null,
|
||||||
|
'function' => isset($frames[$i]['function']) ? $frames[$i]['function'] : null,
|
||||||
|
) + $frames[$i - 1],
|
||||||
|
$trace->srcContext,
|
||||||
|
$trace->keepArgs,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$lastCall = ' ==> '.$call;
|
||||||
|
}
|
||||||
|
$a[Caster::PREFIX_VIRTUAL.$j.'. {main}'.$lastCall] = new FrameStub(
|
||||||
|
array(
|
||||||
|
'object' => null,
|
||||||
|
'class' => null,
|
||||||
|
'type' => null,
|
||||||
|
'function' => '{main}',
|
||||||
|
) + $frames[$i - 1],
|
||||||
|
$trace->srcContext,
|
||||||
|
$trace->keepArgs,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
if (null !== $trace->length) {
|
||||||
|
$a = array_slice($a, 0, $trace->length, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $isNested)
|
||||||
|
{
|
||||||
|
if (!$isNested) {
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
$f = $frame->value;
|
||||||
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
|
|
||||||
|
if (isset($f['file'], $f['line'])) {
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
if (file_exists($f['file']) && 0 <= $frame->srcContext) {
|
||||||
|
$src[$f['file'].':'.$f['line']] = self::extractSource(explode("\n", file_get_contents($f['file'])), $f['line'], $frame->srcContext);
|
||||||
|
|
||||||
|
if (!empty($f['class']) && is_subclass_of($f['class'], 'Twig_Template') && method_exists($f['class'], 'getDebugInfo')) {
|
||||||
|
$template = isset($f['object']) ? $f['object'] : new $f['class'](new \Twig_Environment(new \Twig_Loader_Filesystem()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
$templateName = $template->getTemplateName();
|
||||||
|
$templateSrc = explode("\n", method_exists($template, 'getSource') ? $template->getSource() : $template->getEnvironment()->getLoader()->getSource($templateName));
|
||||||
|
$templateInfo = $template->getDebugInfo();
|
||||||
|
if (isset($templateInfo[$f['line']])) {
|
||||||
|
$src[$templateName.':'.$templateInfo[$f['line']]] = self::extractSource($templateSrc, $templateInfo[$f['line']], $frame->srcContext);
|
||||||
|
}
|
||||||
|
} catch (\Twig_Error_Loader $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$src[$f['file']] = $f['line'];
|
||||||
|
}
|
||||||
|
$a[$prefix.'src'] = new EnumStub($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 && isset($f['args'])) {
|
||||||
|
$a[$prefix.'args'] = $f['args'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since 2.8, to be removed in 3.0. Use the castTraceStub method instead.
|
||||||
|
*/
|
||||||
public static function filterTrace(&$trace, $dumpArgs, $offset = 0)
|
public static function filterTrace(&$trace, $dumpArgs, $offset = 0)
|
||||||
{
|
{
|
||||||
|
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the castTraceStub method instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (0 > $offset || empty($trace[$offset])) {
|
if (0 > $offset || empty($trace[$offset])) {
|
||||||
return $trace = null;
|
return $trace = null;
|
||||||
}
|
}
|
||||||
@ -111,7 +220,7 @@ class ExceptionCaster
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function filterExceptionArray(array $a, $xPrefix, $filter)
|
private static function filterExceptionArray($xClass, array $a, $xPrefix, $filter)
|
||||||
{
|
{
|
||||||
if (isset($a[$xPrefix.'trace'])) {
|
if (isset($a[$xPrefix.'trace'])) {
|
||||||
$trace = $a[$xPrefix.'trace'];
|
$trace = $a[$xPrefix.'trace'];
|
||||||
@ -121,11 +230,12 @@ class ExceptionCaster
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||||
static::filterTrace($trace, static::$traceArgs);
|
array_unshift($trace, array(
|
||||||
|
'function' => $xClass ? 'new '.$xClass : null,
|
||||||
if (null !== $trace) {
|
'file' => $a[Caster::PREFIX_PROTECTED.'file'],
|
||||||
$a[$xPrefix.'trace'] = $trace;
|
'line' => $a[Caster::PREFIX_PROTECTED.'line'],
|
||||||
}
|
));
|
||||||
|
$a[$xPrefix.'trace'] = new TraceStub($trace);
|
||||||
}
|
}
|
||||||
if (empty($a[$xPrefix.'previous'])) {
|
if (empty($a[$xPrefix.'previous'])) {
|
||||||
unset($a[$xPrefix.'previous']);
|
unset($a[$xPrefix.'previous']);
|
||||||
@ -134,4 +244,18 @@ class ExceptionCaster
|
|||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function extractSource(array $srcArray, $line, $srcContext)
|
||||||
|
{
|
||||||
|
$src = '';
|
||||||
|
|
||||||
|
for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) {
|
||||||
|
$src .= (isset($srcArray[$i]) ? $srcArray[$i] : '')."\n";
|
||||||
|
}
|
||||||
|
if (!$srcContext) {
|
||||||
|
$src = trim($src);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $src;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
32
src/Symfony/Component/VarDumper/Caster/FrameStub.php
Normal file
32
src/Symfony/Component/VarDumper/Caster/FrameStub.php
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single backtrace frame as returned by debug_backtrace() or Exception->getTrace().
|
||||||
|
*
|
||||||
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
|
*/
|
||||||
|
class FrameStub extends EnumStub
|
||||||
|
{
|
||||||
|
public $srcContext;
|
||||||
|
public $keepArgs;
|
||||||
|
public $inTraceStub;
|
||||||
|
|
||||||
|
public function __construct(array $trace, $srcContext = 1, $keepArgs = true, $inTraceStub = false)
|
||||||
|
{
|
||||||
|
$this->value = $trace;
|
||||||
|
$this->srcContext = $srcContext;
|
||||||
|
$this->keepArgs = $keepArgs;
|
||||||
|
$this->inTraceStub = $inTraceStub;
|
||||||
|
}
|
||||||
|
}
|
36
src/Symfony/Component/VarDumper/Caster/TraceStub.php
Normal file
36
src/Symfony/Component/VarDumper/Caster/TraceStub.php
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 $srcContext;
|
||||||
|
public $keepArgs;
|
||||||
|
public $offset;
|
||||||
|
public $length;
|
||||||
|
|
||||||
|
public function __construct(array $trace, $srcContext = 1, $keepArgs = true, $offset = 0, $length = null)
|
||||||
|
{
|
||||||
|
$this->value = $trace;
|
||||||
|
$this->srcContext = $srcContext;
|
||||||
|
$this->keepArgs = $keepArgs;
|
||||||
|
$this->offset = $offset;
|
||||||
|
$this->length = $length;
|
||||||
|
}
|
||||||
|
}
|
@ -69,6 +69,8 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
'Error' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castError',
|
'Error' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castError',
|
||||||
'Symfony\Component\DependencyInjection\ContainerInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
'Symfony\Component\DependencyInjection\ContainerInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||||
'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castThrowingCasterException',
|
'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',
|
||||||
|
|
||||||
'PHPUnit_Framework_MockObject_MockObject' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
'PHPUnit_Framework_MockObject_MockObject' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||||
'Prophecy\Prophecy\ProphecySubjectInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
'Prophecy\Prophecy\ProphecySubjectInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
|
||||||
|
@ -163,6 +163,9 @@ EOTXT
|
|||||||
{
|
{
|
||||||
$out = fopen('php://memory', 'r+b');
|
$out = fopen('php://memory', 'r+b');
|
||||||
|
|
||||||
|
require_once __DIR__.'/Fixtures/Twig.php';
|
||||||
|
$twig = new \__TwigTemplate_VarDumperFixture_u75a09(new \Twig_Environment(new \Twig_Loader_Filesystem()));
|
||||||
|
|
||||||
$dumper = new CliDumper();
|
$dumper = new CliDumper();
|
||||||
$dumper->setColors(false);
|
$dumper->setColors(false);
|
||||||
$cloner = new VarCloner();
|
$cloner = new VarCloner();
|
||||||
@ -174,12 +177,15 @@ EOTXT
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
$cloner->addCasters(array(
|
$cloner->addCasters(array(
|
||||||
':stream' => function () {
|
':stream' => eval('return function () use ($twig) {
|
||||||
throw new \Exception('Foobar');
|
try {
|
||||||
},
|
$twig->render(array());
|
||||||
|
} catch (\Twig_Error_Runtime $e) {
|
||||||
|
throw $e->getPrevious();
|
||||||
|
}
|
||||||
|
};'),
|
||||||
));
|
));
|
||||||
$line = __LINE__ - 3;
|
$line = __LINE__ - 2;
|
||||||
$file = __FILE__;
|
|
||||||
$ref = (int) $out;
|
$ref = (int) $out;
|
||||||
|
|
||||||
$data = $cloner->cloneVar($out);
|
$data = $cloner->cloneVar($out);
|
||||||
@ -187,6 +193,19 @@ EOTXT
|
|||||||
rewind($out);
|
rewind($out);
|
||||||
$out = stream_get_contents($out);
|
$out = stream_get_contents($out);
|
||||||
|
|
||||||
|
if (method_exists($twig, 'getSource')) {
|
||||||
|
$twig = <<<EOTXT
|
||||||
|
foo.twig:2: """
|
||||||
|
foo bar\\n
|
||||||
|
twig source\\n
|
||||||
|
\\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
EOTXT;
|
||||||
|
} else {
|
||||||
|
$twig = '';
|
||||||
|
}
|
||||||
|
|
||||||
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
<<<EOTXT
|
<<<EOTXT
|
||||||
@ -203,12 +222,53 @@ stream resource {@{$ref}
|
|||||||
options: []
|
options: []
|
||||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
||||||
#message: "Unexpected Exception thrown from a caster: Foobar"
|
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||||
trace: array:1 [
|
-trace: {
|
||||||
0 => array:2 [
|
%d. __TwigTemplate_VarDumperFixture_u75a09->doDisplay() ==> new Exception(): {
|
||||||
"call" => "%slosure%s()"
|
src: {
|
||||||
"file" => "{$file}:{$line}"
|
%sTwig.php:19: """
|
||||||
]
|
// line 2\\n
|
||||||
]
|
throw new \Exception('Foobar');\\n
|
||||||
|
}\\n
|
||||||
|
"""
|
||||||
|
{$twig} }
|
||||||
|
}
|
||||||
|
%d. Twig_Template->displayWithErrorHandling() ==> __TwigTemplate_VarDumperFixture_u75a09->doDisplay(): {
|
||||||
|
src: {
|
||||||
|
%sTemplate.php:%d: """
|
||||||
|
try {\\n
|
||||||
|
\$this->doDisplay(\$context, \$blocks);\\n
|
||||||
|
} catch (Twig_Error \$e) {\\n
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%d. Twig_Template->display() ==> Twig_Template->displayWithErrorHandling(): {
|
||||||
|
src: {
|
||||||
|
%sTemplate.php:%d: """
|
||||||
|
{\\n
|
||||||
|
\$this->displayWithErrorHandling(\$this->env->mergeGlobals(\$context), array_merge(\$this->blocks, \$blocks));\\n
|
||||||
|
}\\n
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%d. Twig_Template->render() ==> Twig_Template->display(): {
|
||||||
|
src: {
|
||||||
|
%sTemplate.php:%d: """
|
||||||
|
try {\\n
|
||||||
|
\$this->display(\$context);\\n
|
||||||
|
} catch (Exception \$e) {\\n
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%d. %slosure%s() ==> Twig_Template->render(): {
|
||||||
|
src: {
|
||||||
|
%sCliDumperTest.php:{$line}: """
|
||||||
|
}\\n
|
||||||
|
};'),\\n
|
||||||
|
));\\n
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
src/Symfony/Component/VarDumper/Tests/Fixtures/Twig.php
Normal file
34
src/Symfony/Component/VarDumper/Tests/Fixtures/Twig.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/* foo.twig */
|
||||||
|
class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
|
||||||
|
{
|
||||||
|
public function __construct(Twig_Environment $env)
|
||||||
|
{
|
||||||
|
parent::__construct($env);
|
||||||
|
|
||||||
|
$this->parent = false;
|
||||||
|
|
||||||
|
$this->blocks = array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doDisplay(array $context, array $blocks = array())
|
||||||
|
{
|
||||||
|
// line 2
|
||||||
|
throw new \Exception('Foobar');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateName()
|
||||||
|
{
|
||||||
|
return 'foo.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDebugInfo()
|
||||||
|
{
|
||||||
|
return array (19 => 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* foo bar*/
|
||||||
|
/* twig source*/
|
||||||
|
/* */
|
@ -19,7 +19,8 @@
|
|||||||
"php": ">=5.5.9"
|
"php": ">=5.5.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/phpunit-bridge": "~2.8|~3.0"
|
"symfony/phpunit-bridge": "~2.8|~3.0",
|
||||||
|
"twig/twig": "~1.20|~2.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-symfony_debug": ""
|
"ext-symfony_debug": ""
|
||||||
|
Reference in New Issue
Block a user