for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Happyr\TranslationBundle\Translation;
use Happyr\TranslationBundle\Model\Message;
use Happyr\TranslationBundle\Service\TranslationServiceInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Translation\DataCollectorTranslator;
/**
* @author Tobias Nyholm
*/
class AutoAdder
{
* @var DataCollectorTranslator
private $translator;
* @var TranslationServiceInterface transService
private $transService;
* @param DataCollectorTranslator $translator
* @param TranslationServiceInterface $transService
* @param FilesystemUpdater $fileSystemUpdater
public function __construct(DataCollectorTranslator $translator, TranslationServiceInterface $transService, FilesystemUpdater $fileSystemUpdater)
$this->translator = $translator;
$this->transService = $transService;
$this->fileSystemUpdater = $fileSystemUpdater;
fileSystemUpdater
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
public function onTerminate(Event $event)
$event
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
if ($this->translator === null) {
return;
$messages = $this->translator->getCollectedMessages();
$created = array();
foreach ($messages as $message) {
if ($message['state'] === DataCollectorTranslator::MESSAGE_MISSING) {
$m = new Message($message);
$this->transService->createAsset($m);
$created[] = $m;
if (count($created) > 0) {
// update filesystem
$this->fileSystemUpdater->updateMessageCatalog($created);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: