Skip to content

Commit

Permalink
Fix Style
Browse files Browse the repository at this point in the history
  • Loading branch information
François GERBES committed Jul 17, 2017
1 parent 3adba98 commit 284d4a3
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/Admin/BaseWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function close()

protected function _write($data, $separator = "\n")
{
fwrite($this->file, ($this->position > 0 ? $separator : '').$data);
fwrite($this->file, ($this->position > 0 ? $separator : '') . $data);
++$this->position;
}
}
6 changes: 3 additions & 3 deletions src/Admin/CoreAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class CoreAdmin extends SonataAdmin
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->add('duplicate', $this->getRouterIdParameter().'/duplicate');
$collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate');
$collection->add('generateEntityCode');
}

Expand Down Expand Up @@ -392,9 +392,9 @@ public function renameFormGroup($group, $tab, $newGroupName)

// When the default tab is used, the tabname is not prepended to the index in the group array
if ($tab !== 'default') {
$group = $tab.'.'.$group;
$group = $tab . '.' . $group;
}
$newGroup = ($tab !== 'default') ? $tab.'.'.$newGroupName : $newGroupName;
$newGroup = ($tab !== 'default') ? $tab . '.' . $newGroupName : $newGroupName;

if (isset($groups[$newGroup])) {
throw new \Exception(sprintf('%s form group already exists.', $newGroup));
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/Traits/CollectionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ protected function preUpdateOrPersistCollectionsManager($object)
}

$rcentity = new \ReflectionClass($this->getClass());
$method = 'get'.ucfirst($coll);
$method = 'get' . ucfirst($coll);

$subObjects = $object->$method();

// insert/update (forcing the foreign key to be set to $this->getId(), for instance)
if ($subObjects != null) {
foreach ($subObjects as $subobj) {
if ($this->formFieldDescriptions[$coll]->getMappingType() != ClassMetadataInfo::MANY_TO_MANY) {
$subobj->{'set'.ucfirst($rcentity->getShortName())}($object);
$subobj->{'set' . ucfirst($rcentity->getShortName())}($object);
}

if ($targetAdmin != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Traits/ListActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function configureRoutes(RouteCollection $collection)
} else {
$routeSuffix = $key;
}
$collection->add($key, $this->getRouterIdParameter().'/'.$routeSuffix);
$collection->add($key, $this->getRouterIdParameter() . '/' . $routeSuffix);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/Traits/ManyToManyManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ protected function preUpdateManyToManyManager($object)
$this->configureManyToManyManager();

$rc = new \ReflectionClass($this->getClass());
$remove_method = 'remove'.ucfirst($rc->getShortName());
$remove_method = 'remove' . ucfirst($rc->getShortName());

foreach ($this->manyToManyCollections as $fieldname) {
$get_method = 'get'.ucfirst($fieldname);
$get_method = 'get' . ucfirst($fieldname);
$orig_collection = $object->$get_method()->getSnapshot();
$new_collection = $object->$get_method();
foreach ($orig_collection as $entity) {
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/Traits/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,14 @@ protected function handleBatchActions(array $actions = [])
$buf = $config['add'][$actionKey];

foreach ($buf as $action => $props) {
$name = 'batch_action_'.$action;
$name = 'batch_action_' . $action;

foreach ([
'label' => $name,
'params' => [],
'translation_domain' => $this->getTranslationDomain(),
'action' => $name,
'route' => 'batch_'.$action,
'route' => 'batch_' . $action,
] as $field => $value) {
if (empty($props[$field])) {
$props[$field] = $value;
Expand Down Expand Up @@ -623,7 +623,7 @@ protected function addPresetExportFormats(array $formats = [])
if (isset($blast[$class][ListMapper::class]['add']['_export_format'])) {
foreach ($blast[$class][ListMapper::class]['add']['_export_format'] as $format => $fields) {
// if no fields are defined (not an associative array)
if (intval($format).'' == ''.$format && !is_array($fields)) {
if (intval($format) . '' == '' . $format && !is_array($fields)) {
$format = $fields;
$this->exportFields[$format] = $fields = [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Traits/PreEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function prePersistOrUpdate($object, $method)
$analyzer = new ClassAnalyzer();
foreach ($analyzer->getTraits($this) as $traitname) {
$rc = new \ReflectionClass($traitname);
if (method_exists($this, $exec = $method.$rc->getShortName())) {
if (method_exists($this, $exec = $method . $rc->getShortName())) {
$this->$exec($object);
} // executes $this->prePersistMyTrait() or $this->preUpdateMyTrait() method
}
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Traits/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function fixTemplates($mapper)
$templates = $librinfo['configuration']['templates'][$mapType];

// checks if something has to be done
foreach ($this->{$mapType.'FieldDescriptions'} as $fd) {
foreach ($this->{$mapType . 'FieldDescriptions'} as $fd) {
if (isset($templates[$fd->getType()])) {
$fd->setTemplate($templates[$fd->getType()]);
}
Expand Down
5 changes: 3 additions & 2 deletions src/CodeGenerator/CodeGeneratorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public static function register(CodeGeneratorInterface $codeGenerator)
{
$class = get_class($codeGenerator);
if (!defined("$class::ENTITY_CLASS")) {
throw new \Exception($class.' must define a ENTITY_CLASS constant.');
throw new \Exception($class . ' must define a ENTITY_CLASS constant.');
}
if (!defined("$class::ENTITY_FIELD")) {
throw new \Exception($class.' must define a ENTITY_FIELD constant.');
throw new \Exception($class . ' must define a ENTITY_FIELD constant.');
}
self::$generators[$codeGenerator::ENTITY_CLASS][$codeGenerator::ENTITY_FIELD] = $codeGenerator;
}
Expand All @@ -50,6 +50,7 @@ public static function getCodeGenerator($entityClass, $entityField = 'code')
if (!isset(self::$generators[$entityClass][$entityField])) {
throw new \Exception("There is no registered entity code generator for class $entityClass and field $entityField");
}

return self::$generators[$entityClass][$entityField];
}

Expand Down
16 changes: 8 additions & 8 deletions src/Command/GenerateAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$modelClass = Validators::validateClass($input->getArgument('model'));
$modelClassBasename = current(array_slice(explode('\\', $modelClass), -1));
$bundle = $this->getBundle($input->getOption('bundle') ?: $this->getBundleNameFromClass($modelClass));
$adminClassBasename = $input->getOption('admin') ?: $modelClassBasename.'Admin';
$adminClassBasename = $input->getOption('admin') ?: $modelClassBasename . 'Admin';
$adminClassBasename = Validators::validateAdminClassBasename($adminClassBasename);
$managerType = $input->getOption('manager') ?: $this->getDefaultManagerType();
$modelManager = $this->getModelManager($managerType);
$skeletonDirectory = __DIR__.'/../Resources/skeleton';
$skeletonDirectory = __DIR__ . '/../Resources/skeleton';
$adminGenerator = new AdminGenerator($modelManager, $skeletonDirectory);

try {
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input,
$output,
'The admin class basename',
$input->getOption('admin') ?: $modelClassBasename.'Admin',
$input->getOption('admin') ?: $modelClassBasename . 'Admin',
'Sonata\AdminBundle\Command\Validators::validateAdminClassBasename'
);

Expand All @@ -219,19 +219,19 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input,
$output,
'The controller class basename',
$input->getOption('controller') ?: $modelClassBasename.'AdminController',
$input->getOption('controller') ?: $modelClassBasename . 'AdminController',
'Sonata\AdminBundle\Command\Validators::validateControllerClassBasename'
);
$input->setOption('controller', $controllerClassBasename);
}

if ($this->askConfirmation($input, $output, 'Do you want to update the services YAML configuration file', 'yes', '?')) {
$path = $this->getBundle($bundleName)->getPath().'/Resources/config/';
$path = $this->getBundle($bundleName)->getPath() . '/Resources/config/';
$servicesFile = $this->askAndValidate(
$input,
$output,
'The services YAML configuration file',
is_file($path.'admin.yml') ? 'admin.yml' : 'services.yml',
is_file($path . 'admin.yml') ? 'admin.yml' : 'services.yml',
'Sonata\AdminBundle\Command\Validators::validateServicesFile'
);
$id = $this->askAndValidate(
Expand Down Expand Up @@ -263,7 +263,7 @@ private function getBundleNameFromClass($class)
/* @var $application Application */

foreach ($application->getKernel()->getBundles() as $bundle) {
if (strpos($class, $bundle->getNamespace().'\\') === 0) {
if (strpos($class, $bundle->getNamespace() . '\\') === 0) {
return $bundle->getName();
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ private function getDefaultManagerType()
*/
private function getModelManager($managerType)
{
return $this->getContainer()->get('sonata.admin.manager.'.$managerType);
return $this->getContainer()->get('sonata.admin.manager.' . $managerType);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Command/GenerateTranslationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$finder = new Finder();
$crawler = new Crawler();

$path = $this->getContainer()->get('kernel')->locateResource('@'.$bundle);
$transPath = $path.'Resources/translations/';
$path = $this->getContainer()->get('kernel')->locateResource('@' . $bundle);
$transPath = $path . 'Resources/translations/';

if (!$fs->exists($transPath)) {
try {
Expand Down Expand Up @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$translations[$source] = $target;
}

$ymlGenerator = new ArrayToYamlGenerator($file, __DIR__.'/../Resources/skeleton');
$ymlGenerator = new ArrayToYamlGenerator($file, __DIR__ . '/../Resources/skeleton');
$ymlGenerator->generate($translations, 'Messages.yml.twig');
}

Expand Down
8 changes: 4 additions & 4 deletions src/Command/PatcherApplyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ protected function execute(InputInterface $input, OutputInterface $output)

private function applyPatch($targetFile, $patchFile, $patchId)
{
$targetFile = $this->config['paths']['rootDir'].'/'.$targetFile;
$targetFile = $this->config['paths']['rootDir'] . '/' . $targetFile;

if (!file_exists($targetFile) || !file_exists($patchFile)) {
$this->error('Missing patches :');
if (!file_exists($targetFile)) {
$this->comment(' - '.$targetFile);
$this->comment(' - ' . $targetFile);
}
if (!file_exists($patchFile)) {
$this->comment(' - '.$patchFile);
$this->comment(' - ' . $patchFile);
}

return;
Expand All @@ -76,7 +76,7 @@ private function applyPatch($targetFile, $patchFile, $patchId)
system($command, $out);

if ($out != 0) {
$this->error('The patch '.$patchFile.' has not been applyed on file '.$targetFile);
$this->error('The patch ' . $patchFile . ' has not been applyed on file ' . $targetFile);
} else {
foreach ($this->config['patches'] as $key => $patch) {
if ($patch['id'] == $patchId) {
Expand Down
6 changes: 3 additions & 3 deletions src/Command/PatcherConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait PatcherConfig

private function loadConfig()
{
$configPath = __DIR__.'/../Tools/Patches/patches.yml';
$configPath = __DIR__ . '/../Tools/Patches/patches.yml';

$this->config = Yaml::parse(
file_get_contents($configPath)
Expand All @@ -31,8 +31,8 @@ private function loadConfig()
}

$this->config['paths'] = [
'patchFilesDir' => __DIR__.'/../Tools/Patches/patches',
'rootDir' => str_replace('/app/..', '', $this->getContainer()->getParameter('kernel.root_dir').'/..'),
'patchFilesDir' => __DIR__ . '/../Tools/Patches/patches',
'rootDir' => str_replace('/app/..', '', $this->getContainer()->getParameter('kernel.root_dir') . '/..'),
'configFile' => $configPath,
];
}
Expand Down
16 changes: 8 additions & 8 deletions src/Command/PatcherGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ private function createPatch($originalPath, $modifiedPath, $targetPath)
if (!file_exists($originalPath) || !file_exists($modifiedPath)) {
$this->error('Files not found :');
if (!file_exists($originalPath)) {
$this->comment(' - '.$originalPath);
$this->comment(' - ' . $originalPath);
}
if (!file_exists($modifiedPath)) {
$this->comment(' - '.$modifiedPath);
$this->comment(' - ' . $modifiedPath);
}

return;
Expand All @@ -101,7 +101,7 @@ private function createPatch($originalPath, $modifiedPath, $targetPath)
$this->command,
$originalPath,
$modifiedPath,
$this->config['paths']['patchFilesDir'].'/'.$this->now->getTimestamp().'.txt'
$this->config['paths']['patchFilesDir'] . '/' . $this->now->getTimestamp() . '.txt'
);

$this->info('Executing command : ');
Expand All @@ -110,17 +110,17 @@ private function createPatch($originalPath, $modifiedPath, $targetPath)

$this->addPatchToConfigFile(
$targetPath,
$this->config['paths']['patchFilesDir'].'/'.$this->now->getTimestamp().'.txt'
$this->config['paths']['patchFilesDir'] . '/' . $this->now->getTimestamp() . '.txt'
);
}

private function managePath($path, $type)
{
if (substr($path, 0, 1) !== '/' && !filter_var($path, FILTER_VALIDATE_URL)) {
$path = $this->config['paths']['rootDir'].'/'.$path;
$path = $this->config['paths']['rootDir'] . '/' . $path;
} elseif (filter_var($path, FILTER_VALIDATE_URL)) {
if (copy($path, $this->config['paths']['patchFilesDir']."/$type/".$this->now->getTimestamp())) {
$path = $this->config['paths']['patchFilesDir']."/$type/".$this->now->getTimestamp();
if (copy($path, $this->config['paths']['patchFilesDir'] . "/$type/" . $this->now->getTimestamp())) {
$path = $this->config['paths']['patchFilesDir'] . "/$type/" . $this->now->getTimestamp();
}
}

Expand All @@ -136,7 +136,7 @@ private function addPatchToConfigFile($targetPath, $patchFile)
'enabled' => true,
'patched' => false,
'targetFile' => $targetPath,
'patchFile' => str_replace($this->config['paths']['rootDir'].'/', '', $patchFile),
'patchFile' => str_replace($this->config['paths']['rootDir'] . '/', '', $patchFile),
],
],
];
Expand Down
4 changes: 2 additions & 2 deletions src/Command/PatcherLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function comment($message, $ln = true)

public function error($message, $ln = true)
{
$this->addMessage('error', "\n\r\n\r ".$message."\n\r", $ln);
$this->addMessage('error', "\n\r\n\r " . $message . "\n\r", $ln);
}

public function addMessage($severity, $message, $ln = true)
{
$this->messages[] = [
'ln' => $ln,
'message' => '<'.$severity.'>'.$message.'</'.$severity.'>',
'message' => '<' . $severity . '>' . $message . '</' . $severity . '>',
];
}

Expand Down
14 changes: 7 additions & 7 deletions src/DependencyInjection/BlastCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function initialize()
$rc = new \ReflectionClass($this);
$this->dir = dirname($rc->getFileName());
$this->prefix = '/../Resources/config/';
$this->bundlesPrefix = $this->prefix.'bundles/';
$this->bundlesPrefix = $this->prefix . 'bundles/';
$this->suffix = '.yml';
$this->file = 'blast';

Expand All @@ -69,7 +69,7 @@ public function initialize()
*/
public function buildLoader(ContainerBuilder $container)
{
return new YamlFileLoader($container, new FileLocator($this->dir.$this->prefix));
return new YamlFileLoader($container, new FileLocator($this->dir . $this->prefix));
}

/**
Expand All @@ -83,8 +83,8 @@ public function loadServices(FileLoader $loader)
{
// services, admin & config files
foreach (['services', 'admin', 'config'] as $fileName) {
if (file_exists($this->dir.$this->prefix.$fileName.$this->suffix)) {
$loader->load($fileName.$this->suffix);
if (file_exists($this->dir . $this->prefix . $fileName . $this->suffix)) {
$loader->load($fileName . $this->suffix);
}
}

Expand Down Expand Up @@ -127,8 +127,8 @@ public function loadDataFixtures(ContainerBuilder $container, FileLoader $loader
public function loadParameters(ContainerBuilder $container)
{
// the blast.yml
if (file_exists($this->dir.$this->prefix.$this->file.$this->suffix)) {
$this->mergeParameter('blast', $container, $this->dir.$this->prefix);
if (file_exists($this->dir . $this->prefix . $this->file . $this->suffix)) {
$this->mergeParameter('blast', $container, $this->dir . $this->prefix);
}

return $this;
Expand Down Expand Up @@ -156,7 +156,7 @@ public function loadSecurity(ContainerBuilder $container)
*/
public function loadSonataAdmin(ContainerBuilder $container, FileLoader $loader)
{
if (file_exists($path = $this->dir.$this->bundlesPrefix.'sonata_admin'.$this->suffix)) {
if (file_exists($path = $this->dir . $this->bundlesPrefix . 'sonata_admin' . $this->suffix)) {
$configSonataAdmin = Yaml::parse(
file_get_contents($path)
);
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/ArrayToYamlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function generate($array, $skeleton)
$parts = explode('.', $this->file->getPathName());
array_pop($parts);

$file = implode('.', $parts).'.yml';
$file = implode('.', $parts) . '.yml';

if (file_exists($file)) {
return;
Expand Down

0 comments on commit 284d4a3

Please sign in to comment.