Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Symfony 4.3 #974

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -3,6 +3,7 @@
"license": "MIT",
"type": "project",
"description": "Symfony Demo Application",
"minimum-stability": "dev",
"require": {
"php": "^7.1.3",
"ext-pdo_sqlite": "*",
Expand Down Expand Up @@ -85,7 +86,7 @@
"extra": {
"symfony": {
"allow-contrib": true,
"require": "4.2.*"
"require": "4.3.0-beta1"
}
}
}
1,495 changes: 783 additions & 712 deletions composer.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions config/bootstrap.php
Expand Up @@ -4,18 +4,18 @@

require dirname(__DIR__).'/vendor/autoload.php';

if (!array_key_exists('APP_ENV', $_SERVER)) {
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
}

if ('prod' !== $_SERVER['APP_ENV']) {
if (!class_exists(Dotenv::class)) {
throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
}

(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
19 changes: 19 additions & 0 deletions config/packages/cache.yaml
@@ -0,0 +1,19 @@
framework:
cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The app cache caches to the filesystem by default.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: ~
3 changes: 2 additions & 1 deletion config/packages/security.yaml
@@ -1,8 +1,9 @@
security:
encoders:
# Our user class and the algorithm we'll use to encode passwords
# 'auto' means to let PHP choose the best possible password hasher (Argon2 or Bcrypt)
javiereguiluz marked this conversation as resolved.
Show resolved Hide resolved
# https://symfony.com/doc/current/security.html#c-encoding-the-user-s-password
App\Entity\User: bcrypt
App\Entity\User: 'auto'

providers:
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
Expand Down
5 changes: 0 additions & 5 deletions config/packages/test/security.yaml
@@ -1,11 +1,6 @@
# this configuration simplifies testing URLs protected by the security mechanism
# See https://symfony.com/doc/current/cookbook/testing/http_authentication.html
security:
encoders:
# to make tests much faster, BCrypt cost is changed to its minimum allowed value (4)
# See https://symfony.com/doc/current/reference/configuration/security.html#using-the-bcrypt-password-encoder
App\Entity\User: { algorithm: bcrypt, cost: 4 }

firewalls:
main:
http_basic: ~
Binary file modified data/database.sqlite
Binary file not shown.
Binary file modified data/database_test.sqlite
Binary file not shown.
5 changes: 4 additions & 1 deletion phpunit.xml.dist
Expand Up @@ -9,9 +9,10 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="APP_ENV" value="test" force="true"/>
<env name="KERNEL_CLASS" value="App\Kernel" />
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<env name="SYMFONY_PHPUNIT_VERSION" value="7.1"/>
<env name="APP_ENV" value="test"/>
</php>

<testsuites>
Expand All @@ -21,6 +22,8 @@
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Thx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<!-- it begins a database transaction before every testcase and rolls it back after
the test finished, so tests can manipulate the database without affecting other tests -->
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitListener" />
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/BlogController.php
Expand Up @@ -116,7 +116,7 @@ public function commentNew(Request $request, Post $post, EventDispatcherInterfac
// passed in the event and they can even modify the execution flow, so
// there's no guarantee that the rest of this controller will be executed.
// See https://symfony.com/doc/current/components/event_dispatcher.html
$eventDispatcher->dispatch(Events::COMMENT_CREATED, $event);
$eventDispatcher->dispatch($event, Events::COMMENT_CREATED);

return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()]);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Form/Type/ChangePasswordType.php
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
new NotBlank(),
new Length([
'min' => 5,
'max' => BCryptPasswordEncoder::MAX_PASSWORD_LENGTH,
'max' => 128,
]),
],
'first_options' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/AppExtension.php
Expand Up @@ -12,7 +12,7 @@
namespace App\Twig;

use App\Utils\Markdown;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locales;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function getLocales(): array

$this->locales = [];
foreach ($this->localeCodes as $localeCode) {
$this->locales[] = ['code' => $localeCode, 'name' => Intl::getLocaleBundle()->getLocaleName($localeCode, $localeCode)];
$this->locales[] = ['code' => $localeCode, 'name' => Locales::getName($localeCode, $localeCode)];
}

return $this->locales;
Expand Down
12 changes: 6 additions & 6 deletions symfony.lock
Expand Up @@ -146,9 +146,6 @@
"psr/log": {
"version": "1.0.x-dev"
},
"psr/simple-cache": {
"version": "1.0.x-dev"
},
"sensio/framework-extra-bundle": {
"version": "5.2",
"recipe": {
Expand Down Expand Up @@ -275,6 +272,9 @@
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/mime": {
"version": "v4.3.0-beta1"
},
"symfony/monolog-bridge": {
"version": "4.2-dev"
},
Expand Down Expand Up @@ -320,6 +320,9 @@
"symfony/polyfill-php72": {
"version": "1.9-dev"
},
"symfony/polyfill-php73": {
"version": "1.11-dev"
},
"symfony/process": {
"version": "4.2-dev"
},
Expand Down Expand Up @@ -463,8 +466,5 @@
},
"zendframework/zend-code": {
"version": "3.3-dev"
},
"zendframework/zend-eventmanager": {
"version": "3.2.1"
}
}
Expand Up @@ -110,7 +110,7 @@ private function getMockedTransformer(array $findByReturnValues = []): TagArrayT
->getMock();
$tagRepository->expects($this->any())
->method('findBy')
->will($this->returnValue($findByReturnValues));
->willReturn($findByReturnValues);

return new TagArrayToStringTransformer($tagRepository);
}
Expand Down