8000 Merge branch '2.7' into 2.8 · symfony/symfony@570bebd · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 570bebd

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: prefer getSourceContext() over getSource() [HttpFoundation] Avoid implicit null to array conversion in request matcher Revert "bug #20184 [FrameworkBundle] Convert null prefix to an empty string in translation:update (chalasr)" Update UPGRADE-2.7.md
2 parents a66e9ff + 40dc73a commit 570bebd

File tree

7 files changed

+26
-23
lines changed

7 files changed

+26
-23
lines changed

UPGRADE-2.7.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Form
4040
----
4141

4242
* In form types and extension overriding the "setDefaultOptions" of the
43-
AbstractType or AbstractExtensionType has been deprecated in favor of
43+
AbstractType or AbstractTypeExtension has been deprecated in favor of
4444
overriding the new "configureOptions" method.
4545

4646
The method "setDefaultOptions(OptionsResolverInterface $resolver)" will

src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testTrans($template, $expected, array $variables = array())
3636
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
3737
$twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector())));
3838

39-
echo $twig->compile($twig->parse($twig->tokenize(new \Twig_Source($twig->getLoader()->getSource('index'), 'index'))))."\n\n";
39+
echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n";
4040
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
4141
}
4242

src/Symfony/Bridge/Twig/TwigEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ public function exists($name)
7575

7676
$loader = $this->environment->getLoader();
7777

78-
if ($loader instanceof \Twig_ExistsLoaderInterface) {
78+
if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) {
7979
return $loader->exists((string) $name);
8080
}
8181

8282
try {
8383
// cast possible TemplateReferenceInterface to string because the
8484
// EngineInterface supports them but Twig_LoaderInterface does not
85-
$loader->getSource((string) $name);
85+
$loader->getSourceContext((string) $name)->getCode();
8686
} catch (\Twig_Error_Loader $e) {
8787
return false;
8888
}

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
119119
// load any messages from templates
120120
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
121121
$io->comment('Parsing templates...');
122-
$prefix = $input->getOption('prefix');
123122
$extractor = $this->getContainer()->get('translation.extractor');
124-
$extractor->setPrefix(null === $prefix ? '' : $prefix);
123+
$extractor->setPrefix($input->getOption('prefix'));
125124
foreach ($transPaths as $path) {
126125
$path .= 'views';
127126
if (is_dir($path)) {

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ protected function templateExists($template)
129129
$template = (string) $template;
130130

131131
$loader = $this->twig->getLoader();
132-
if ($loader instanceof \Twig_ExistsLoaderInterface) {
132+
if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) {
133133
return $loader->exists($template);
134134
}
135135

136136
try {
137-
$loader->getSource($template);
137+
$loader->getSourceContext($template)->getCode();
138138

139139
return true;
140140
} catch (\Twig_Error_Loader $e) {

src/Symfony/Component/HttpFoundation/RequestMatcher.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
class RequestMatcher implements RequestMatcherInterface
2020
{
2121
/**
22-
* @var string
22+
* @var string|null
2323
*/
2424
private $path;
2525

2626
/**
27-
* @var string
27+
* @var string|null
2828
*/
2929
private $host;
3030

3131
/**
32-
* @var array
32+
* @var string[]
3333
*/
3434
private $methods = array();
3535

3636
/**
37-
* @var string
37+
* @var string[]
3838
*/
3939
private $ips = array();
4040

@@ -76,13 +76,13 @@ public function __construct($path = null, $host = null, $methods = null, $ips =
7676
*/
7777
public function matchScheme($scheme)
7878
{
79-
$this->schemes = array_map('strtolower', (array) $scheme);
79+
$this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : array();
8080
}
8181

8282
/**
8383
* Adds a check for the URL host name.
8484
*
85-
* @param string $regexp A Regexp
85+
* @param string|null $regexp A Regexp
8686
*/
8787
public function matchHost($regexp)
8888
{
@@ -92,7 +92,7 @@ public function matchHost($regexp)
9292
/**
9393
* Adds a check for the URL path info.
9494
*
95-
* @param string $regexp A Regexp
95+
* @param string|null $regexp A Regexp
9696
*/
9797
public function matchPath($regexp)
9898
{
@@ -112,21 +112,21 @@ public function matchIp($ip)
112112
/**
113113
* Adds a check for the client IP.
114114
*
115-
* @param string|string[] $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
115+
* @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
116116
*/
117117
public function matchIps($ips)
118118
{
119-
$this->ips = (array) $ips;
119+
$this->ips = null !== $ips ? (array) $ips : array();
120120
}
121121

122122
/**
123123
* Adds a check for the HTTP method.
124124
*
125-
* @param string|string[] $method An HTTP method or an array of HTTP methods
125+
* @param string|string[]|null $method An HTTP method or an array of HTTP methods
126126
*/
127127
public function matchMethod($method)
128128
{
129-
$this->methods = array_map('strtoupper', (array) $method);
129+
$this->methods = null !== $method ? array_map('strtoupper', (array) $method) : array();
130130
}
131131

132132
/**
@@ -145,11 +145,11 @@ public function matchAttribute($key, $regexp)
145145
*/
146146
public function matches(Request $request)
147147
{
148-
if ($this->schemes && !in_array($request->getScheme(), $this->schemes)) {
148+
if ($this->schemes && !in_array($request->getScheme(), $this->schemes, true)) {
149149
return false;
150150
}
151151

152-
if ($this->methods && !in_array($request->getMethod(), $this->methods)) {
152+
if ($this->methods && !in_array($request->getMethod(), $this->methods, true)) {
153153
return false;
154154
}
155155

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,16 @@ private function templateExists($template)
140140
}
141141

142142
$loader = $this->templating->getLoader();
143-
if ($loader instanceof \Twig_ExistsLoaderInterface) {
143+
if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) {
144144
return $loader->exists($template);
145145
}
146146

147147
try {
148-
$loader->getSource($template);
148+
if (method_exists($loader, 'getSourceContext')) {
149+
$loader->getSourceContext($template);
150+
} else {
151+
$loader->getSource($template);
152+
}
149153

150154
return true;
151155
} catch (\Twig_Error_Loader $e) {

0 commit comments

Comments
 (0)
0