Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  Leverage str_contains/str_starts_with
  Leverage str_ends_with
  • Loading branch information
nicolas-grekas committed Jul 21, 2021
2 parents a495e17 + 236017d commit c8cde33
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Csp/ContentSecurityPolicyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private function authorizesInline(array $directivesSet, string $type): bool
private function hasHashOrNonce(array $directives): bool
{
foreach ($directives as $directive) {
if ('\'' !== substr($directive, -1)) {
if (!str_ends_with($directive, '\'')) {
continue;
}
if ('\'nonce-' === substr($directive, 0, 7)) {
Expand Down
2 changes: 1 addition & 1 deletion EventListener/WebDebugToolbarListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function onKernelResponse(ResponseEvent $event)
if (self::DISABLED === $this->mode
|| !$response->headers->has('X-Debug-Token')
|| $response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $request->getRequestFormat()
|| false !== stripos($response->headers->get('Content-Disposition', ''), 'attachment;')
) {
Expand Down
2 changes: 1 addition & 1 deletion Profiler/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getNames(Profile $profile)
continue;
}

if ('.html.twig' === substr($template, -10)) {
if (str_ends_with($template, '.html.twig')) {
$template = substr($template, 0, -10);
}

Expand Down
2 changes: 1 addition & 1 deletion Twig/WebProfilerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function dumpLog(Environment $env, string $message, Data $context = null)
$message = twig_escape_filter($env, $message);
$message = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);

if (null === $context || false === strpos($message, '{')) {
if (null === $context || !str_contains($message, '{')) {
return '<span class="dump-inline">'.$message.'</span>';
}

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"symfony/config": "^4.4|^5.0",
"symfony/framework-bundle": "^5.1",
"symfony/http-kernel": "^5.2",
"symfony/polyfill-php80": "^1.16",
"symfony/routing": "^4.4|^5.0",
"symfony/twig-bundle": "^4.4|^5.0",
"twig/twig": "^2.13|^3.0.4"
Expand Down

0 comments on commit c8cde33

Please sign in to comment.