Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fa0f2d

Browse files
committed
merged 2.0
2 parents 2a74ac3 + 33f68fe commit 5fa0f2d

File tree

19 files changed

+211
-43
lines changed

19 files changed

+211
-43
lines changed

src/Symfony/Bundle/FrameworkBundle/HttpKernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle;
1313

1414
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
1516
use Symfony\Component\HttpFoundation\StreamedResponse;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private function addGlobalsSection(ArrayNodeDefinition $rootNode)
7979
->useAttributeAsKey('key')
8080
->prototype('array')
8181
->beforeNormalization()
82-
->ifTrue(function($v){ return is_string($v) && '@' === substr($v, 0, 1); })
82+
->ifTrue(function($v){ return is_string($v) && 0 === strpos($v, '@'); })
8383
->then(function($v){ return array('id' => substr($v, 1), 'type' => 'service'); })
8484
->end()
8585
->beforeNormalization()

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public function restart()
441441
protected function getAbsoluteUri($uri)
442442
{
443443
// already absolute?
444-
if ('http' === substr($uri, 0, 4)) {
444+
if (0 === strpos($uri, 'http')) {
445445
return $uri;
446446
}
447447

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function parse()
7777
{
7878
$this->parsed = $this->tokens;
7979
while (null !== $token = array_shift($this->parsed)) {
80-
if ('--' === substr($token, 0, 2)) {
80+
if (0 === strpos($token, '--')) {
8181
$this->parseLongOption($token);
8282
} elseif ('-' === $token[0]) {
8383
$this->parseShortOption($token);

src/Symfony/Component/Console/Input/ArrayInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function getParameterOption($values, $default = false)
116116
protected function parse()
117117
{
118118
foreach ($this->parameters as $key => $value) {
119-
if ('--' === substr($key, 0, 2)) {
119+
if (0 === strpos($key, '--')) {
120120
$this->addLongOption(substr($key, 2), $value);
121121
} elseif ('-' === $key[0]) {
122122
$this->addShortOption(substr($key, 1), $value);

src/Symfony/Component/Console/Input/InputOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class InputOption
4646
*/
4747
public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
4848
{
49-
if ('--' === substr($name, 0, 2)) {
49+
if (0 === strpos($name, '--')) {
5050
$name = substr($name, 2);
5151
}
5252

src/Symfony/Component/DomCrawler/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getUri()
8080
$uri = trim($this->getRawUri());
8181

8282
// absolute URL?
83-
if ('http' === substr($uri, 0, 4)) {
83+
if (0 === strpos($uri, 'http')) {
8484
return $uri;
8585
}
8686

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,11 @@ public function getScheme()
632632
*/
633633
public function getPort()
634634
{
635-
return $this->headers->get('X-Forwarded-Port') ?: $this->server->get('SERVER_PORT');
635+
if (self::$trustProxy && $this->headers->has('X-Forwarded-Port')) {
636+
return $this->headers->get('X-Forwarded-Port');
637+
} else {
638+
return $this->server->get('SERVER_PORT');
639+
}
636640
}
637641

638642
/**

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function prepare(Request $request)
175175
$charset = $this->charset ?: 'UTF-8';
176176
if (!$headers->has('Content-Type')) {
177177
$headers->set('Content-Type', 'text/html; charset='.$charset);
178-
} elseif ('text/' === substr($headers->get('Content-Type'), 0, 5) && false === strpos($headers->get('Content-Type'), 'charset')) {
178+
} elseif (0 === strpos($headers->get('Content-Type'), 'text/') && false === strpos($headers->get('Content-Type'), 'charset')) {
179179
// add the charset
180180
$headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset);
181181
}

src/Symfony/Component/HttpFoundation/ServerBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getHeaders()
2828
{
2929
$headers = array();
3030
foreach ($this->parameters as $key => $value) {
31-
if ('HTTP_' === substr($key, 0, 5)) {
31+
if (0 === strpos($key, 'HTTP_')) {
3232
$headers[substr($key, 5)] = $value;
3333
}
3434
// CONTENT_* are not prefixed with HTTP_

src/Symfony/Component/HttpKernel/HttpCache/Esi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function hasSurrogateEsiCapability(Request $request)
6464
return false;
6565
}
6666

67-
return (Boolean) preg_match('#ESI/1.0#', $value);
67+
return false !== strpos($value, 'ESI/1.0');
6868
}
6969

7070
/**

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ protected function getEnvParameters()
614614
{
615615
$parameters = array();
616616
foreach ($_SERVER as $key => $value) {
617-
if ('SYMFONY__' === substr($key, 0, 9)) {
617+
if (0 === strpos($key, 'SYMFONY__')) {
618618
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
619619
}
620620
}

src/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MysqlProfilerStorage extends PdoProfilerStorage
2424
protected function initDb()
2525
{
2626
if (null === $this->db) {
27-
if ('mysql' !== substr($this->dsn, 0, 5)) {
27+
if (0 !== strpos($this->dsn, 'mysql')) {
2828
throw new \RuntimeException('Please check your configuration. You are trying to use Mysql with a wrong dsn. "'.$this->dsn.'"');
2929
}
3030

src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SqliteProfilerStorage extends PdoProfilerStorage
2525
protected function initDb()
2626
{
2727
if (null === $this->db || $this->db instanceof \SQLite3) {
28-
if ('sqlite' !== substr($this->dsn, 0, 6 )) {
28+
if (0 !== strpos($this->dsn, 'sqlite')) {
2929
throw new \RuntimeException('You are trying to use Sqlite with a wrong dsn. "'.$this->dsn.'"');
3030
}
3131
if (class_exists('SQLite3')) {

src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public function setTimeZoneId($timeZoneId)
431431
$timeZone = $timeZoneId;
432432

433433
// Get an Etc/GMT time zone that is accepted for \DateTimeZone
434-
if ('GMT' !== $timeZoneId && 'GMT' === substr($timeZoneId, 0, 3)) {
434+
if ('GMT' !== $timeZoneId && 0 === strpos($timeZoneId, 'GMT')) {
435435
try {
436436
$timeZoneId = DateFormat\TimeZoneTransformer::getEtcTimeZoneId($timeZoneId);
437437
} catch (\InvalidArgumentException $e) {

src/Symfony/Component/Validator/Constraints/CollectionValidator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function isValid($value, Constraint $constraint)
5252
}
5353

5454
foreach ($constraint->fields as $field => $constraints) {
55-
if (array_key_exists($field, $value)) {
55+
if (
56+
// bug fix issue #2779
57+
(is_array($value) && array_key_exists($field, $value)) ||
58+
($value instanceof \ArrayAccess && $value->offsetExists($field))
59+
) {
5660
// cannot simply cast to array, because then the object is converted to an
5761
// array instead of wrapped inside
5862
$constraints = is_array($constraints) ? $constraints : array($constraints);

src/Symfony/Component/Yaml/Parser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function parse($value)
114114
}
115115

116116
if ('<<' === $key) {
117-
if (isset($values['value']) && '*' === substr($values['value'], 0, 1)) {
117+
if (isset($values['value']) && 0 === strpos($values['value'], '*')) {
118118
$isInPlace = substr($values['value'], 1);
119119
if (!array_key_exists($isInPlace, $this->refs)) {
120120
throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine);
@@ -188,7 +188,7 @@ public function parse($value)
188188

189189
if (is_array($value)) {
190190
$first = reset($value);
191-
if (is_string($first) && '*' === substr($first, 0, 1)) {
191+
if (is_string($first) && 0 === strpos($first, '*')) {
192192
$data = array();
193193
foreach ($value as $alias) {
194194
$data[] = $this->refs[substr($alias, 1)];
@@ -347,7 +347,7 @@ private function moveToPreviousLine()
347347
*/
348348
private function parseValue($value)
349349
{
350-
if ('*' === substr($value, 0, 1)) {
350+
if (0 === strpos($value, '*')) {
351351
if (false !== $pos = strpos($value, '#')) {
352352
$value = substr($value, 1, $pos - 2);
353353
} else {

src/Symfony/Component/Yaml/Yaml.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ static public function parse($input)
5353
{
5454
// if input is a file, process it
5555
$file = '';
56-
if (strpos($input, "\n") === false && is_file($input) && is_readable($input)) {
56+
if (strpos($input, "\n") === false && is_file($input)) {
57+
if (false === is_readable($input)) {
58+
throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
59+
}
60+
5761
$file = $input;
5862
if (self::$enablePhpParsing) {
5963
ob_start();

0 commit comments

Comments
 (0)