Skip to content

Commit 5fe74e9

Browse files
committed
Merge branch 'master' of github.com:symfony/demo
2 parents d4a74f8 + ccb2cc7 commit 5fe74e9

File tree

9 files changed

+33
-32
lines changed

9 files changed

+33
-32
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ matrix:
1414
fast_finish: true
1515
include:
1616
- php: 7.1
17+
- php: 7.2
18+
- php: nightly
19+
allow_failures:
20+
- php: nightly
1721

1822
before_install:
19-
- phpenv config-rm xdebug.ini
23+
- '[[ "$TRAVIS_PHP_VERSION" == "nightly" ]] || phpenv config-rm xdebug.ini'
2024
- composer self-update
2125

2226
install:
@@ -26,7 +30,7 @@ install:
2630
script:
2731
- ./vendor/bin/simple-phpunit
2832
# this checks that the source code follows the Symfony Code Syntax rules
29-
- ./vendor/bin/php-cs-fixer fix --diff --dry-run -v
33+
- '[[ "$TRAVIS_PHP_VERSION" == "nightly" ]] || ./vendor/bin/php-cs-fixer fix --diff --dry-run -v'
3034
# this checks that the YAML config files contain no syntax errors
3135
- ./bin/console lint:yaml config
3236
# this checks that the Twig template files contain no syntax errors

src/Command/AddUserCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
199199

200200
$event = $stopwatch->stop('add-user-command');
201201
if ($output->isVerbose()) {
202-
$this->io->comment(sprintf('New user database id: %d / Elapsed time: %.2f ms / Consumed memory: %.2f MB', $user->getId(), $event->getDuration(), $event->getMemory() / pow(1024, 2)));
202+
$this->io->comment(sprintf('New user database id: %d / Elapsed time: %.2f ms / Consumed memory: %.2f MB', $user->getId(), $event->getDuration(), $event->getMemory() / (1024 ** 2)));
203203
}
204204
}
205205

src/DataFixtures/FixturesTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function getRandomPostSummary(int $maxLength = 255): string
123123
{
124124
$phrases = $this->getPhrases();
125125

126-
$numPhrases = mt_rand(6, 12);
126+
$numPhrases = random_int(6, 12);
127127
shuffle($phrases);
128128
$phrases = array_slice($phrases, 0, $numPhrases - 1);
129129

@@ -138,7 +138,7 @@ private function getRandomCommentContent(): string
138138
{
139139
$phrases = $this->getPhrases();
140140

141-
$numPhrases = mt_rand(2, 15);
141+
$numPhrases = random_int(2, 15);
142142
shuffle($phrases);
143143

144144
return implode(' ', array_slice($phrases, 0, $numPhrases - 1));

src/DataFixtures/ORM/PostFixtures.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function load(ObjectManager $manager): void
5757
$post->setAuthor(0 === $i ? $this->getReference('jane-admin') : $this->getRandomUser());
5858

5959
// for aesthetic reasons, the first blog post always has 2 tags
60-
foreach ($this->getRandomTags($i > 0 ? mt_rand(0, 3) : 2) as $tag) {
60+
foreach ($this->getRandomTags($i > 0 ? random_int(0, 3) : 2) as $tag) {
6161
$post->addTag($tag);
6262
}
6363

src/Entity/User.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,16 @@ public function eraseCredentials(): void
168168
*/
169169
public function serialize(): string
170170
{
171-
return serialize([
172-
$this->id,
173-
$this->username,
174-
$this->password,
175-
// see section on salt below
176-
// $this->salt,
177-
]);
171+
// add $this->salt too if you don't use Bcrypt or Argon2i
172+
return serialize([$this->id, $this->username, $this->password]);
178173
}
179174

180175
/**
181176
* {@inheritdoc}
182177
*/
183178
public function unserialize($serialized): void
184179
{
185-
list(
186-
$this->id,
187-
$this->username,
188-
$this->password,
189-
// see section on salt below
190-
// $this->salt
191-
) = unserialize($serialized);
180+
// add $this->salt too if you don't use Bcrypt or Argon2i
181+
[$this->id, $this->username, $this->password] = unserialize($serialized, ['allowed_classes' => false]);
192182
}
193183
}

src/EventSubscriber/RedirectToPreferredLocaleSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
class RedirectToPreferredLocaleSubscriber implements EventSubscriberInterface
2929
{
3030
private $urlGenerator;
31-
private $locales = [];
32-
private $defaultLocale = '';
31+
private $locales;
32+
private $defaultLocale;
3333

3434
public function __construct(UrlGeneratorInterface $urlGenerator, string $locales, string $defaultLocale = null)
3535
{

src/Form/Type/DateTimePickerType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(MomentFormatConverter $converter)
4141
public function buildView(FormView $view, FormInterface $form, array $options)
4242
{
4343
$view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']);
44-
$view->vars['attr']['data-date-locale'] = mb_strtolower(strtr(\Locale::getDefault(), '_', '-'));
44+
$view->vars['attr']['data-date-locale'] = mb_strtolower(str_replace('_', '-', \Locale::getDefault()));
4545
}
4646

4747
/**

tests/Form/DataTransformer/TagArrayToStringTransformerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testTransform()
106106
*
107107
* @return TagArrayToStringTransformer
108108
*/
109-
private function getMockedTransformer($findByReturnValues = [])
109+
private function getMockedTransformer(array $findByReturnValues = []): TagArrayToStringTransformer
110110
{
111111
$tagRepository = $this->getMockBuilder(EntityRepository::class)
112112
->disableOriginalConstructor()
@@ -133,7 +133,7 @@ private function getMockedTransformer($findByReturnValues = [])
133133
*
134134
* @return Tag
135135
*/
136-
private function createTag($name)
136+
private function createTag($name): Tag
137137
{
138138
$tag = new Tag();
139139
$tag->setName($name);

tests/Utils/ValidatorTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ public function testValidateUsername()
3434

3535
public function testValidateUsernameEmpty()
3636
{
37-
$this->setExpectedException('Exception', 'The username can not be empty.');
37+
$this->expectException('Exception');
38+
$this->expectExceptionMessage('The username can not be empty.');
3839
$this->object->validateUsername(null);
3940
}
4041

4142
public function testValidateUsernameInvalid()
4243
{
43-
$this->setExpectedException('Exception', 'The username must contain only lowercase latin characters and underscores.');
44+
$this->expectException('Exception');
45+
$this->expectExceptionMessage('The username must contain only lowercase latin characters and underscores.');
4446
$this->object->validateUsername('INVALID');
4547
}
4648

@@ -53,13 +55,15 @@ public function testValidatePassword()
5355

5456
public function testValidatePasswordEmpty()
5557
{
56-
$this->setExpectedException('Exception', 'The password can not be empty.');
58+
$this->expectException('Exception');
59+
$this->expectExceptionMessage('The password can not be empty.');
5760
$this->object->validatePassword(null);
5861
}
5962

6063
public function testValidatePasswordInvalid()
6164
{
62-
$this->setExpectedException('Exception', 'The password must be at least 6 characters long.');
65+
$this->expectException('Exception');
66+
$this->expectExceptionMessage('The password must be at least 6 characters long.');
6367
$this->object->validatePassword('12345');
6468
}
6569

@@ -72,13 +76,15 @@ public function testValidateEmail()
7276

7377
public function testValidateEmailEmpty()
7478
{
75-
$this->setExpectedException('Exception', 'The email can not be empty.');
79+
$this->expectException('Exception');
80+
$this->expectExceptionMessage('The email can not be empty.');
7681
$this->object->validateEmail(null);
7782
}
7883

7984
public function testValidateEmailInvalid()
8085
{
81-
$this->setExpectedException('Exception', 'The email should look like a real email.');
86+
$this->expectException('Exception');
87+
$this->expectExceptionMessage('The email should look like a real email.');
8288
$this->object->validateEmail('invalid');
8389
}
8490

@@ -91,7 +97,8 @@ public function testValidateFullName()
9197

9298
public function testValidateEmailFullName()
9399
{
94-
$this->setExpectedException('Exception', 'The full name can not be empty.');
100+
$this->expectException('Exception');
101+
$this->expectExceptionMessage('The full name can not be empty.');
95102
$this->object->validateFullName(null);
96103
}
97104
}

0 commit comments

Comments
 (0)