Skip to content

Commit d38e646

Browse files
authored
Apply fixes from StyleCI (#155)
1 parent fd51033 commit d38e646

File tree

10 files changed

+21
-20
lines changed

10 files changed

+21
-20
lines changed

Catalogue/CatalogueCounter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public function getCatalogueStatistics(MessageCatalogueInterface $catalogue)
6969
foreach ($catalogue->all($domain) as $key => $text) {
7070
$metadata = new Metadata($catalogue->getMetadata($key, $domain));
7171
$state = $metadata->getState();
72-
if ($state === 'new') {
72+
if ('new' === $state) {
7373
++$result[$domain]['new'];
7474
}
7575

76-
if ($state === 'obsolete') {
76+
if ('obsolete' === $state) {
7777
++$result[$domain]['obsolete'];
7878
}
7979

Controller/SymfonyProfilerController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function syncAction(Request $request, $token)
7878
$sfMessage = $this->getMessage($request, $token);
7979
$message = $storage->syncAndFetchMessage($sfMessage->getLocale(), $sfMessage->getDomain(), $sfMessage->getKey());
8080

81-
if ($message !== null) {
81+
if (null !== $message) {
8282
return new Response($message->getTranslation());
8383
}
8484

@@ -165,7 +165,7 @@ private function getMessage(Request $request, $token)
165165
}
166166
$message = SfProfilerMessage::create($messages[$messageId]);
167167

168-
if ($message->getState() === DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK) {
168+
if (DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK === $message->getState()) {
169169
$message->setLocale($profile->getCollector('request')->getLocale())
170170
->setTranslation(sprintf('[%s]', $message->getTranslation()));
171171
}
@@ -185,7 +185,7 @@ protected function getSelectedMessages(Request $request, $token)
185185
$profiler->disable();
186186

187187
$selected = $request->request->get('selected');
188-
if (!$selected || count($selected) == 0) {
188+
if (!$selected || 0 == count($selected)) {
189189
return [];
190190
}
191191

DependencyInjection/TranslationExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function handleConfigNode(ContainerBuilder $container, array $config)
8888
// $first will be the "default" configuration.
8989
$first = null;
9090
foreach ($config['configs'] as $name => &$c) {
91-
if ($first === null || $name === 'default') {
91+
if (null === $first || 'default' === $name) {
9292
$first = $name;
9393
}
9494
if (empty($c['project_root'])) {
@@ -115,7 +115,7 @@ private function handleConfigNode(ContainerBuilder $container, array $config)
115115
}
116116

117117
foreach ($c['local_storage'] as $serviceId) {
118-
if ($serviceId !== 'php_translation.local_file_storage.abstract') {
118+
if ('php_translation.local_file_storage.abstract' !== $serviceId) {
119119
$storageDefinition->addMethodCall('addLocalStorage', [new Reference($serviceId)]);
120120

121121
continue;
@@ -129,10 +129,10 @@ private function handleConfigNode(ContainerBuilder $container, array $config)
129129
}
130130
}
131131

132-
if ($first !== null) {
132+
if (null !== $first) {
133133
// Create some aliases for the default storage
134134
$container->setAlias('php_translation.storage', 'php_translation.storage.'.$first);
135-
if ($first !== 'default') {
135+
if ('default' !== $first) {
136136
$container->setAlias('php_translation.storage.default', 'php_translation.storage.'.$first);
137137
}
138138
}
@@ -172,7 +172,7 @@ private function enableEditInPlace(ContainerBuilder $container, array $config)
172172
{
173173
$name = $config['edit_in_place']['config_name'];
174174

175-
if ($name !== 'default' && !isset($config['configs'][$name])) {
175+
if ('default' !== $name && !isset($config['configs'][$name])) {
176176
throw new InvalidArgumentException(sprintf('There is no config named "%s".', $name));
177177
}
178178

EventListener/AutoAddMissingTranslations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function __construct(StorageService $storage, DataCollectorTranslator $tr
4343

4444
public function onTerminate(Event $event)
4545
{
46-
if ($this->dataCollector === null) {
46+
if (null === $this->dataCollector) {
4747
return;
4848
}
4949

5050
$messages = $this->dataCollector->getCollectedMessages();
5151
foreach ($messages as $message) {
52-
if ($message['state'] === DataCollectorTranslator::MESSAGE_MISSING) {
52+
if (DataCollectorTranslator::MESSAGE_MISSING === $message['state']) {
5353
$m = new Message($message['id'], $message['domain'], $message['locale'], $message['translation']);
5454
$this->storage->create($m);
5555
}

Model/CatalogueMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function isNew()
135135
return false;
136136
}
137137

138-
return $this->metadata->getState() === 'new';
138+
return 'new' === $this->metadata->getState();
139139
}
140140

141141
public function isObsolete()
@@ -144,7 +144,7 @@ public function isObsolete()
144144
return false;
145145
}
146146

147-
return $this->metadata->getState() === 'obsolete';
147+
return 'obsolete' === $this->metadata->getState();
148148
}
149149

150150
public function isApproved()

Model/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function isApproved()
7373
$notes = $this->getAllInCategory('approved');
7474
foreach ($notes as $note) {
7575
if (isset($note['content'])) {
76-
return $note['content'] === 'true';
76+
return 'true' === $note['content'];
7777
}
7878
}
7979

Service/ConfigurationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getConfiguration($name = null)
4949
return $this->configuration[$name];
5050
}
5151

52-
if ($name === 'default') {
52+
if ('default' === $name) {
5353
$name = $this->getFirstName();
5454
if (isset($this->configuration[$name])) {
5555
return $this->configuration[$name];

Service/StorageService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
final class StorageService implements Storage
2929
{
3030
const DIRECTION_UP = 'up';
31+
3132
const DIRECTION_DOWN = 'down';
3233

3334
/**

Tests/Functional/Command/ExtractCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ public function testExecute()
9393

9494
// Test meta, source-location
9595
$meta = new Metadata($catalogue->getMetadata('translated.paragraph1'));
96-
$this->assertFalse($meta->getState() === 'new');
96+
$this->assertFalse('new' === $meta->getState());
9797
foreach ($meta->getSourceLocations() as $sourceLocation) {
9898
$this->assertNotEquals('foobar.html.twig', $sourceLocation['path']);
9999
}
100100

101101
$meta = new Metadata($catalogue->getMetadata('not.in.source'));
102-
$this->assertTrue($meta->getState() === 'obsolete');
102+
$this->assertTrue('obsolete' === $meta->getState());
103103

104104
$meta = new Metadata($catalogue->getMetadata('translated.title'));
105-
$this->assertTrue($meta->getState() === 'new');
105+
$this->assertTrue('new' === $meta->getState());
106106
}
107107
}

Translator/FallbackTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private function translateWithSubstitutedParameters($orgString, $locale, array $
151151
$replacedString = str_replace(array_keys($replacements), array_values($replacements), $orgString);
152152
$translatedString = $this->externalTranslator->translate($replacedString, $this->defaultLocale, $locale);
153153

154-
if ($translatedString === null) {
154+
if (null === $translatedString) {
155155
// Could not be translated
156156
return $orgString;
157157
}

0 commit comments

Comments
 (0)