diff --git a/.php_cs.dist b/.php_cs.dist
index fbcb7a240..3a5ae58fa 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -26,12 +26,18 @@ return PhpCsFixer\Config::create()
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
+ 'linebreak_after_opening_tag' => true,
+ 'mb_str_functions' => true,
+ 'no_php4_constructor' => true,
+ 'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
- 'phpdoc_order' => true,
'php_unit_strict' => true,
+ 'phpdoc_order' => true,
+ 'semicolon_after_instruction' => true,
'strict_comparison' => true,
+ 'strict_param' => true,
])
->setFinder($finder)
->setCacheFile(__DIR__.'/var/.php_cs.cache')
diff --git a/app/AppKernel.php b/app/AppKernel.php
index 57276a337..1ad4f6b3e 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -38,7 +38,7 @@ public function registerBundles()
// the unit and functional tests. Therefore, they are only registered
// when the application runs in 'dev' or 'test' environments. This allows
// to increase application performance in the production environment.
- if (in_array($this->getEnvironment(), ['dev', 'test'])) {
+ if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
diff --git a/src/AppBundle/Command/AddUserCommand.php b/src/AppBundle/Command/AddUserCommand.php
index 6d84ea869..0cfa0c3f3 100644
--- a/src/AppBundle/Command/AddUserCommand.php
+++ b/src/AppBundle/Command/AddUserCommand.php
@@ -151,7 +151,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$password = $console->ask($input, $output, $question);
$input->setArgument('password', $password);
} else {
- $output->writeln(' > Password: '.str_repeat('*', strlen($password)));
+ $output->writeln(' > Password: '.str_repeat('*', mb_strlen($password)));
}
// Ask for the email if it's not defined
@@ -233,7 +233,7 @@ public function passwordValidator($plainPassword)
throw new \Exception('The password can not be empty.');
}
- if (strlen(trim($plainPassword)) < 6) {
+ if (mb_strlen(trim($plainPassword)) < 6) {
throw new \Exception('The password must be at least 6 characters long.');
}
@@ -249,7 +249,7 @@ public function emailValidator($email)
throw new \Exception('The email can not be empty.');
}
- if (false === strpos($email, '@')) {
+ if (false === mb_strpos($email, '@')) {
throw new \Exception('The email should look like a real email.');
}
diff --git a/src/AppBundle/DataFixtures/FixturesTrait.php b/src/AppBundle/DataFixtures/FixturesTrait.php
index cb5a401ec..9e81915fd 100644
--- a/src/AppBundle/DataFixtures/FixturesTrait.php
+++ b/src/AppBundle/DataFixtures/FixturesTrait.php
@@ -127,7 +127,7 @@ private function getRandomPostSummary($maxLength = 255)
shuffle($phrases);
$phrases = array_slice($phrases, 0, $numPhrases - 1);
- while (strlen($summary = implode('. ', $phrases).'.') > $maxLength) {
+ while (mb_strlen($summary = implode('. ', $phrases).'.') > $maxLength) {
array_pop($phrases);
}
diff --git a/src/AppBundle/Entity/Comment.php b/src/AppBundle/Entity/Comment.php
index 85410d406..3f9d95551 100644
--- a/src/AppBundle/Entity/Comment.php
+++ b/src/AppBundle/Entity/Comment.php
@@ -86,7 +86,7 @@ public function __construct()
*/
public function isLegitComment()
{
- $containsInvalidCharacters = false !== strpos($this->content, '@');
+ $containsInvalidCharacters = false !== mb_strpos($this->content, '@');
return !$containsInvalidCharacters;
}
diff --git a/src/AppBundle/EventListener/CheckRequirementsSubscriber.php b/src/AppBundle/EventListener/CheckRequirementsSubscriber.php
index 666342c67..eac7644d9 100644
--- a/src/AppBundle/EventListener/CheckRequirementsSubscriber.php
+++ b/src/AppBundle/EventListener/CheckRequirementsSubscriber.php
@@ -67,7 +67,7 @@ public function handleConsoleException(ConsoleExceptionEvent $event)
{
$commandNames = ['doctrine:fixtures:load', 'doctrine:database:create', 'doctrine:schema:create', 'doctrine:database:drop'];
- if (in_array($event->getCommand()->getName(), $commandNames)) {
+ if (in_array($event->getCommand()->getName(), $commandNames, true)) {
if ($this->isSQLitePlatform() && !extension_loaded('sqlite3')) {
$io = new SymfonyStyle($event->getInput(), $event->getOutput());
$io->error('This command requires to have the "sqlite3" PHP extension enabled because, by default, the Symfony Demo application uses SQLite to store its information.');
diff --git a/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php b/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php
index 592939a19..35b5c2745 100644
--- a/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php
+++ b/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php
@@ -60,7 +60,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, $locales, $defa
$this->defaultLocale = $defaultLocale ?: $this->locales[0];
- if (!in_array($this->defaultLocale, $this->locales)) {
+ if (!in_array($this->defaultLocale, $this->locales, true)) {
throw new \UnexpectedValueException(sprintf('The default locale ("%s") must be one of "%s".', $this->defaultLocale, $locales));
}
@@ -84,7 +84,7 @@ public function onKernelRequest(GetResponseEvent $event)
}
// Ignore requests from referrers with the same HTTP host in order to prevent
// changing language for users who possibly already selected it for this application.
- if (0 === stripos($request->headers->get('referer'), $request->getSchemeAndHttpHost())) {
+ if (0 === mb_stripos($request->headers->get('referer'), $request->getSchemeAndHttpHost())) {
return;
}
diff --git a/src/AppBundle/Security/PostVoter.php b/src/AppBundle/Security/PostVoter.php
index 7ce1a9c16..1601923e1 100644
--- a/src/AppBundle/Security/PostVoter.php
+++ b/src/AppBundle/Security/PostVoter.php
@@ -38,7 +38,7 @@ class PostVoter extends Voter
protected function supports($attribute, $subject)
{
// this voter is only executed for three specific permissions on Post objects
- return $subject instanceof Post && in_array($attribute, [self::SHOW, self::EDIT, self::DELETE]);
+ return $subject instanceof Post && in_array($attribute, [self::SHOW, self::EDIT, self::DELETE], true);
}
/**
diff --git a/src/CodeExplorerBundle/Twig/SourceCodeExtension.php b/src/CodeExplorerBundle/Twig/SourceCodeExtension.php
index 4da4fe364..354ea418b 100644
--- a/src/CodeExplorerBundle/Twig/SourceCodeExtension.php
+++ b/src/CodeExplorerBundle/Twig/SourceCodeExtension.php
@@ -126,12 +126,12 @@ private function unindentCode($code)
$codeLines = explode("\n", $code);
$indentedLines = array_filter($codeLines, function ($lineOfCode) {
- return '' === $lineOfCode || ' ' === substr($lineOfCode, 0, 4);
+ return '' === $lineOfCode || ' ' === mb_substr($lineOfCode, 0, 4);
});
if (count($indentedLines) === count($codeLines)) {
$formattedCode = array_map(function ($lineOfCode) {
- return substr($lineOfCode, 4);
+ return mb_substr($lineOfCode, 4);
}, $codeLines);
$formattedCode = implode("\n", $formattedCode);
}
diff --git a/web/app_dev.php b/web/app_dev.php
index 73798fc46..ee8543421 100644
--- a/web/app_dev.php
+++ b/web/app_dev.php
@@ -27,7 +27,7 @@
// something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
- || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
+ || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');