Skip to content

Commit

Permalink
added docblocks, minor changes here and there, removal of unused prop…
Browse files Browse the repository at this point in the history
…erties/variables

Included psr1 and psr2 fixes
  • Loading branch information
gnat42 authored and Nyholm committed Apr 3, 2016
1 parent ac09e3d commit 58dcd6c
Show file tree
Hide file tree
Showing 107 changed files with 1,471 additions and 320 deletions.
2 changes: 1 addition & 1 deletion Annotation/Desc.php
Expand Up @@ -47,4 +47,4 @@ public function __construct()

$this->text = $values['text'];
}
}
}
2 changes: 1 addition & 1 deletion Annotation/Ignore.php
Expand Up @@ -25,4 +25,4 @@
*/
final class Ignore
{
}
}
6 changes: 5 additions & 1 deletion Annotation/Meaning.php
Expand Up @@ -30,11 +30,15 @@ final class Meaning
/** @var string @Required */
public $text;

/**
* Meaning constructor.
*/
public function __construct()
{
if (0 === func_num_args()) {
return;
}

$values = func_get_arg(0);

if (isset($values['value'])) {
Expand All @@ -47,4 +51,4 @@ public function __construct()

$this->text = $values['text'];
}
}
}
30 changes: 21 additions & 9 deletions Command/ExtractTranslationCommand.php
Expand Up @@ -35,6 +35,9 @@
*/
class ExtractTranslationCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -55,10 +58,15 @@ protected function configure()
->addOption('output-format', null, InputOption::VALUE_REQUIRED, 'The output format that should be used (in most cases, it is better to change only the default-output-format).')
->addOption('default-output-format', null, InputOption::VALUE_REQUIRED, 'The default output format (defaults to xlf).')
->addOption('keep', null, InputOption::VALUE_NONE, 'Define if the updater service should keep the old translation (defaults to false).')
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED , 'Load external translation ressources')
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Load external translation ressources')
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$builder = $input->getOption('config') ?
Expand Down Expand Up @@ -100,20 +108,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
$changeSet = $updater->getChangeSet($config);

$output->writeln('Added Messages: '.count($changeSet->getAddedMessages()));
if($input->hasParameterOption('--verbose')){
foreach($changeSet->getAddedMessages() as $message){
if ($input->hasParameterOption('--verbose')) {
foreach ($changeSet->getAddedMessages() as $message) {
$output->writeln($message->getId(). '-> '.$message->getDesc());
}
}
}

if ($config->isKeepOldMessages()) {
$output->writeln('Deleted Messages: # none as "Keep Old Translations" is true #');
} else {
$output->writeln('Deleted Messages: '.count($changeSet->getDeletedMessages()));
if($input->hasParameterOption('--verbose')){
foreach($changeSet->getDeletedMessages() as $message){
if ($input->hasParameterOption('--verbose')) {
foreach ($changeSet->getDeletedMessages() as $message) {
$output->writeln($message->getId(). '-> '.$message->getDesc());
}
}
}
}

Expand All @@ -126,6 +134,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('done!');
}

/**
* @param InputInterface $input
* @param ConfigBuilder $builder
*/
private function updateWithInput(InputInterface $input, ConfigBuilder $builder)
{
if ($bundle = $input->getOption('bundle')) {
Expand Down Expand Up @@ -188,12 +200,12 @@ private function updateWithInput(InputInterface $input, ConfigBuilder $builder)

if ($input->hasParameterOption('--keep') || $input->hasParameterOption('--keep=true')) {
$builder->setKeepOldTranslations(true);
} else if ($input->hasParameterOption('--keep=false')) {
} elseif ($input->hasParameterOption('--keep=false')) {
$builder->setKeepOldTranslations(false);
}

if ($loadResource = $input->getOption('external-translations-dir')) {
$builder->setLoadResources($loadResource);
}
}
}
}
11 changes: 6 additions & 5 deletions Command/ResourcesListCommand.php
Expand Up @@ -22,7 +22,6 @@
use JMS\TranslationBundle\Exception\RuntimeException;
use JMS\TranslationBundle\Translation\Config;
use JMS\TranslationBundle\Logger\OutputLogger;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -31,13 +30,15 @@
use Symfony\Component\Finder\Finder;
use JMS\TranslationBundle\Util\FileUtils;


/**
* @author Fabien Potencier <fabien@symfony.com>
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*/
class ResourcesListCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -50,7 +51,7 @@ protected function configure()
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return mixed
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down Expand Up @@ -93,7 +94,7 @@ private function retrieveFiles(array $dirs)
$files = array();
// Register translation resources
foreach ($dirs as $dir) {
foreach(FileUtils::findTranslationFiles($dir) as $catalogue => $locales) {
foreach (FileUtils::findTranslationFiles($dir) as $catalogue => $locales) {
foreach ($locales as $file) {
$files[] = $file[1];
}
Expand Down Expand Up @@ -125,4 +126,4 @@ private function retrieveDirs()

return $dirs;
}
}
}
24 changes: 19 additions & 5 deletions Controller/ApiController.php
Expand Up @@ -19,6 +19,8 @@
namespace JMS\TranslationBundle\Controller;

use JMS\TranslationBundle\Exception\RuntimeException;
use JMS\TranslationBundle\Translation\ConfigFactory;
use JMS\TranslationBundle\Translation\Updater;
use Symfony\Component\HttpFoundation\Response;
use JMS\TranslationBundle\Util\FileUtils;
use JMS\DiExtraBundle\Annotation as DI;
Expand All @@ -33,18 +35,30 @@
*/
class ApiController
{
/** @DI\Inject("jms_translation.config_factory") */
/**
* @DI\Inject("jms_translation.config_factory")
* @var ConfigFactory
*/
private $configFactory;

/** @DI\Inject("jms_translation.updater") */
/**
* @DI\Inject("jms_translation.updater")
* @var Updater
*/
private $updater;

/**
* @Route("/configs/{config}/domains/{domain}/locales/{locale}/messages",
* name="jms_translation_update_message",
* defaults = {"id" = null},
* options = {"i18n" = false})
* name="jms_translation_update_message",
* defaults = {"id" = null},
* options = {"i18n" = false})
* @Method("PUT")
* @param Request $request
* @param string $config
* @param string $domain
* @param string $locale
*
* @return Response
*/
public function updateMessageAction(Request $request, $config, $domain, $locale)
{
Expand Down
19 changes: 15 additions & 4 deletions Controller/TranslateController.php
Expand Up @@ -19,6 +19,8 @@
namespace JMS\TranslationBundle\Controller;

use JMS\TranslationBundle\Exception\RuntimeException;
use JMS\TranslationBundle\Translation\ConfigFactory;
use JMS\TranslationBundle\Translation\LoaderManager;
use JMS\TranslationBundle\Util\FileUtils;
use JMS\DiExtraBundle\Annotation as DI;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
Expand All @@ -33,13 +35,22 @@
*/
class TranslateController
{
/** @DI\Inject("jms_translation.config_factory") */
/**
* @DI\Inject("jms_translation.config_factory")
* @var ConfigFactory
*/
private $configFactory;

/** @DI\Inject("jms_translation.loader_manager") */
/**
* @DI\Inject("jms_translation.loader_manager")
* @var LoaderManager
*/
private $loader;

/** @DI\Inject("%jms_translation.source_language%") */
/**
* @DI\Inject("%jms_translation.source_language%")
* @var string
*/
private $sourceLanguage;

/**
Expand Down Expand Up @@ -128,4 +139,4 @@ public function indexAction(Request $request)
'sourceLanguage' => $this->sourceLanguage,
);
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/IntegrationPass.php
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container)
}

$def = $container->getDefinition('translation.loader.xliff');
if ('%translation.loader.xliff.class%' !== $def->getClass() && 'Symfony\Component\Translation\Loader\XliffFileLoader' !== $def->getClass()) {
if ('%translation.loader.xliff.class%' !== $def->getClass() && 'Symfony\Component\Translation\Loader\XliffFileLoader' !== $def->getClass()) {
// user needs to manually integrate as desired
return;
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/MountDumpersPass.php
Expand Up @@ -59,4 +59,4 @@ public function process(ContainerBuilder $container)
->addArgument($dumpers)
;
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/MountExtractorsPass.php
Expand Up @@ -43,4 +43,4 @@ public function process(ContainerBuilder $container)

$def->addArgument($extractors);
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/MountFileVisitorsPass.php
Expand Up @@ -37,4 +37,4 @@ public function process(ContainerBuilder $container)
}
$def->addArgument($visitors);
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/MountLoadersPass.php
Expand Up @@ -59,4 +59,4 @@ public function process(ContainerBuilder $container)
->addArgument($loaders)
;
}
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Expand Up @@ -62,7 +62,7 @@ public function getConfigTreeBuilder()
->requiresAtLeastOneElement()
->prototype('scalar')
->validate()
->always(function($v) use ($c) {
->always(function ($v) use ($c) {
$v = str_replace(DIRECTORY_SEPARATOR, '/', $v);

if ('@' === $v[0]) {
Expand Down Expand Up @@ -118,4 +118,4 @@ public function getConfigTreeBuilder()

return $tb;
}
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/JMSTranslationExtension.php
Expand Up @@ -101,4 +101,4 @@ public function load(array $configs, ContainerBuilder $container)
->addArgument($requests)
;
}
}
}
2 changes: 1 addition & 1 deletion Exception/Exception.php
Expand Up @@ -25,4 +25,4 @@
*/
interface Exception
{
}
}
2 changes: 1 addition & 1 deletion Exception/InvalidArgumentException.php
Expand Up @@ -25,4 +25,4 @@
*/
class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
}
}
2 changes: 1 addition & 1 deletion Exception/RuntimeException.php
Expand Up @@ -25,4 +25,4 @@
*/
class RuntimeException extends \RuntimeException implements Exception
{
}
}
4 changes: 2 additions & 2 deletions Logger/LoggerAwareInterface.php
Expand Up @@ -28,5 +28,5 @@ interface LoggerAwareInterface
/**
* @param LoggerInterface $logger
*/
function setLogger(LoggerInterface $logger);
}
public function setLogger(LoggerInterface $logger);
}

0 comments on commit 58dcd6c

Please sign in to comment.