Skip to content

Commit

Permalink
Fixed code with the latest version of php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Mar 31, 2015
1 parent 1c06a4e commit 779be3e
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 70 deletions.
50 changes: 31 additions & 19 deletions Configuration/Configurator.php
Expand Up @@ -69,8 +69,9 @@ public function __construct(array $backendConfig, EntityMetadataInspector $inspe
* This configuration includes all the information about the form fields
* and properties of the entity.
*
* @param string $entityName
* @return array The full entity configuration
* @param string $entityName
*
* @return array The full entity configuration
*/
public function getEntityConfiguration($entityName)
{
Expand Down Expand Up @@ -111,8 +112,9 @@ public function getEntityConfiguration($entityName)
* Takes the entity metadata introspected via Doctrine and completes its
* contents to simplify data processing for the rest of the application.
*
* @param ClassMetadata $entityMetadata The entity metadata introspected via Doctrine
* @return array The entity properties metadata provided by Doctrine
* @param ClassMetadata $entityMetadata The entity metadata introspected via Doctrine
*
* @return array The entity properties metadata provided by Doctrine
*/
private function processEntityPropertiesMetadata(ClassMetadata $entityMetadata)
{
Expand Down Expand Up @@ -153,7 +155,8 @@ private function processEntityPropertiesMetadata(ClassMetadata $entityMetadata)
/**
* Returns the list of fields to show in the 'list' view of this entity.
*
* @param array $entityConfiguration
* @param array $entityConfiguration
*
* @return array The list of fields to show and their metadata
*/
private function getFieldsForListView(array $entityConfiguration)
Expand All @@ -169,7 +172,8 @@ private function getFieldsForListView(array $entityConfiguration)
/**
* Returns the list of fields to show in the 'show' view of this entity.
*
* @param array $entityConfiguration
* @param array $entityConfiguration
*
* @return array The list of fields to show and their metadata
*/
private function getFieldsForShowView(array $entityConfiguration)
Expand All @@ -186,7 +190,8 @@ private function getFieldsForShowView(array $entityConfiguration)
* Returns the list of fields to show in the forms of this entity for the
* views which display forms ('edit' and 'new').
*
* @param array $entityConfiguration
* @param array $entityConfiguration
*
* @return array The list of fields to show and their metadata
*/
protected function getFieldsForFormBasedViews($view, array $entityConfiguration)
Expand Down Expand Up @@ -222,7 +227,8 @@ private function getFieldsForSearchAction()
* If the backend configuration doesn't define any options for the fields of some entity,
* create some basic field configuration based on the entity's Doctrine metadata.
*
* @param array $entityProperties
* @param array $entityProperties
*
* @return array The array of fields
*/
private function createFieldsFromEntityProperties($entityProperties)
Expand All @@ -247,7 +253,8 @@ private function createFieldsFromEntityProperties($entityProperties)
* define any configuration. It does so limiting the number of fields to
* display and discarding several field types.
*
* @param array $entityFields
* @param array $entityFields
*
* @return array The list of fields to display
*/
private function filterListFieldsBasedOnSmartGuesses(array $entityFields)
Expand Down Expand Up @@ -282,9 +289,10 @@ private function filterListFieldsBasedOnSmartGuesses(array $entityFields)
/**
* Filters a list of fields excluding the given list of field names and field types.
*
* @param array $fields
* @param array $excludedFieldNames
* @param array $excludedFieldTypes
* @param array $fields
* @param array $excludedFieldNames
* @param array $excludedFieldTypes
*
* @return array The filtered list of fields
*/
private function filterFieldsByNameAndType(array $fields, array $excludedFieldNames, array $excludedFieldTypes)
Expand All @@ -304,9 +312,10 @@ private function filterFieldsByNameAndType(array $fields, array $excludedFieldNa
* Merges all the information about the fields associated with the given view
* to return the complete set of normalized field configuration.
*
* @param string $view
* @param array $entityConfiguration
* @return array The complete field configuration
* @param string $view
* @param array $entityConfiguration
*
* @return array The complete field configuration
*/
private function normalizeFieldsConfiguration($view, $entityConfiguration)
{
Expand Down Expand Up @@ -362,7 +371,7 @@ private function normalizeFieldsConfiguration($view, $entityConfiguration)
if ('list' === $view && 'boolean' === $normalizedConfiguration['dataType']) {
// conditions: 1) the end-user hasn't configured the field type explicitly
// 2) the 'edit' action is allowed for the 'list' view of this entity
if(!isset($fieldConfiguration['type']) && array_key_exists('edit', $entityConfiguration['list']['actions'])) {
if (!isset($fieldConfiguration['type']) && array_key_exists('edit', $entityConfiguration['list']['actions'])) {
$normalizedConfiguration['dataType'] = 'toggle';
}
}
Expand All @@ -381,7 +390,8 @@ private function normalizeFieldsConfiguration($view, $entityConfiguration)
* Returns the date/time/datetime/number format for the given field
* according to its type and the default formats defined for the backend.
*
* @param string $fieldType
* @param string $fieldType
*
* @return string The format that should be applied to the field value
*/
private function getFieldFormat($fieldType)
Expand All @@ -403,7 +413,8 @@ private function getFieldFormat($fieldType)
* This preprocessing saves a lot of further processing when accessing or
* setting the value of the entity properties.
*
* @param array $entityConfiguration
* @param array $entityConfiguration
*
* @return array
*/
private function introspectGettersAndSetters($entityConfiguration)
Expand Down Expand Up @@ -434,7 +445,8 @@ private function introspectGettersAndSetters($entityConfiguration)
/**
* Returns the most appropriate Symfony Form type for the given Doctrine type.
*
* @param string $doctrineType
* @param string $doctrineType
*
* @return string
*/
private function getFormTypeFromDoctrineType($doctrineType)
Expand Down
17 changes: 11 additions & 6 deletions Controller/AdminController.php
Expand Up @@ -29,7 +29,7 @@
use Pagerfanta\Adapter\DoctrineORMAdapter;

/**
* Class AdminController
* Class AdminController.
*/
class AdminController extends Controller
{
Expand All @@ -44,6 +44,7 @@ class AdminController extends Controller

/**
* @Route("/", name="admin")
*
* @param Request $request
*
* @return RedirectResponse|Response
Expand Down Expand Up @@ -84,7 +85,8 @@ public function indexAction(Request $request)
* If everything goes right, it returns null. If there is any error, it
* returns a 404 error page using a Response object.
*
* @param Request $request
* @param Request $request
*
* @return Response|null
*/
protected function initialize(Request $request)
Expand Down Expand Up @@ -267,6 +269,7 @@ protected function deleteAction()

/**
* The method that is executed when the user performs a query on an entity.
*
* @return Response
*/
protected function searchAction()
Expand Down Expand Up @@ -320,7 +323,8 @@ protected function ajaxEdit()
* Allows applications to modify the entity associated with the item being
* edited before persisting it.
*
* @param object $entity
* @param object $entity
*
* @return object
*/
protected function prepareEditEntityForPersist($entity)
Expand All @@ -332,7 +336,8 @@ protected function prepareEditEntityForPersist($entity)
* Allows applications to modify the entity associated with the item being
* created before persisting it.
*
* @param object $entity
* @param object $entity
*
* @return object
*/
protected function prepareNewEntityForPersist($entity)
Expand Down Expand Up @@ -473,8 +478,8 @@ protected function getNameOfTheFirstConfiguredEntity()
* the deletion of the entity are always performed with the 'DELETE' HTTP method,
* which requires a form to work in the current browsers.
*
* @param string $entityName
* @param integer $entityId
* @param string $entityName
* @param int $entityId
*
* @return Form
*/
Expand Down
45 changes: 27 additions & 18 deletions DependencyInjection/EasyAdminExtension.php
Expand Up @@ -45,7 +45,8 @@ public function load(array $configs, ContainerBuilder $container)
* that are managed by the backend. Several configuration formats are allowed,
* so this method normalizes them all.
*
* @param array $entitiesConfiguration
* @param array $entitiesConfiguration
*
* @return array The full entity configuration
*/
public function getEntitiesConfiguration(array $entitiesConfiguration)
Expand Down Expand Up @@ -92,7 +93,8 @@ public function getEntitiesConfiguration(array $entitiesConfiguration)
* class: AppBundle\Entity\User
* label: 'Clients'
*
* @param array $entitiesConfiguration The entity configuration in one of the simplified formats
* @param array $entitiesConfiguration The entity configuration in one of the simplified formats
*
* @return array The normalized configuration
*/
private function normalizeEntitiesConfiguration(array $entitiesConfiguration)
Expand Down Expand Up @@ -135,7 +137,8 @@ private function normalizeEntitiesConfiguration(array $entitiesConfiguration)
* Merges all the actions that can be configured in the backend and normalizes
* them to get the final action configuration for each entity view.
*
* @param array $backendConfiguration
* @param array $backendConfiguration
*
* @return array
*/
public function processEntityActions(array $backendConfiguration)
Expand Down Expand Up @@ -178,7 +181,8 @@ public function processEntityActions(array $backendConfiguration)
* This allows to provide some nice defaults for backends that don't
* define their own actions.
*
* @param string $view
* @param string $view
*
* @return array
*/
private function getDefaultActions($view)
Expand All @@ -187,10 +191,10 @@ private function getDefaultActions($view)
$actions = $this->normalizeActionsConfiguration(array(
array('name' => 'delete', 'label' => 'action.delete', 'type' => 'method', 'icon' => 'trash'),
array('name' => 'edit', 'label' => 'action.edit', 'type' => 'method', 'icon' => 'edit'),
array('name' => 'new', 'label' => 'action.new', 'type' => 'method',),
array('name' => 'search', 'label' => 'action.search', 'type' => 'method',),
array('name' => 'show', 'label' => 'action.show', 'type' => 'method',),
array('name' => 'list', 'label' => 'action.list', 'type' => 'method',),
array('name' => 'new', 'label' => 'action.new', 'type' => 'method'),
array('name' => 'search', 'label' => 'action.search', 'type' => 'method'),
array('name' => 'show', 'label' => 'action.show', 'type' => 'method'),
array('name' => 'list', 'label' => 'action.list', 'type' => 'method'),
));

// configure which actions are enabled for each view
Expand Down Expand Up @@ -225,7 +229,8 @@ private function getDefaultActions($view)
* list:
* actions: ['search', { name: 'show', label: 'Show', 'icon': 'user' }, 'grantAccess']
*
* @param array $actionConfiguration
* @param array $actionConfiguration
*
* @return array
*/
private function normalizeActionsConfiguration(array $actionConfiguration)
Expand Down Expand Up @@ -283,21 +288,22 @@ private function normalizeActionsConfiguration(array $actionConfiguration)
/**
* Removes the actions marked as deleted from the given actions configuration.
*
* @param array $actionsConfiguration
* @param array $actionsConfiguration
*
* @return array
*/
private function filterRemovedActions(array $actionsConfiguration)
{
// if the name of the action starts with a '-' dash, remove it
$removedActions = array_filter($actionsConfiguration, function($action) {
$removedActions = array_filter($actionsConfiguration, function ($action) {
return '-' === $action['name']{0};
});

if (empty($removedActions)) {
return $actionsConfiguration;
}

return array_filter($actionsConfiguration, function($action) use ($removedActions) {
return array_filter($actionsConfiguration, function ($action) use ($removedActions) {
// e.g. '-search' action name removes both '-search' and 'search' (if exists)
return !array_key_exists($action['name'], $removedActions)
&& !array_key_exists('-'.$action['name'], $removedActions);
Expand All @@ -308,7 +314,8 @@ private function filterRemovedActions(array $actionsConfiguration)
* Normalizes and initializes the configuration of the given entities to
* simplify the option processing of the other methods and functions.
*
* @param array $entitiesConfiguration
* @param array $entitiesConfiguration
*
* @return array The configured entities
*/
private function processEntitiesConfiguration(array $entitiesConfiguration)
Expand Down Expand Up @@ -356,7 +363,8 @@ private function processEntitiesConfiguration(array $entitiesConfiguration)
* This method ensures that all entity names are unique by appending some suffix
* to repeated names until they are unique.
*
* @param array $entitiesConfiguration
* @param array $entitiesConfiguration
*
* @return array The entities configuration with unique entity names
*/
private function getUniqueEntityName($entityName, $existingEntityNames)
Expand Down Expand Up @@ -390,10 +398,11 @@ private function getUniqueEntityName($entityName, $existingEntityNames)
* This method processes both formats to produce a common form field configuration
* format used in the rest of the application.
*
* @param array $fieldsConfiguration
* @param string $view The current view (this argument is needed to create good error messages)
* @param array $entityConfiguration The full configuration of the entity this field belongs to
* @return array The configured entity fields
* @param array $fieldsConfiguration
* @param string $view The current view (this argument is needed to create good error messages)
* @param array $entityConfiguration The full configuration of the entity this field belongs to
*
* @return array The configured entity fields
*/
private function normalizeFieldsConfiguration(array $fieldsConfiguration, $view, array $entityConfiguration)
{
Expand Down
2 changes: 1 addition & 1 deletion EasyAdminBundle.php
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* Class EasyAdminBundle
* Class EasyAdminBundle.
*/
class EasyAdminBundle extends Bundle
{
Expand Down
15 changes: 9 additions & 6 deletions Reflection/ClassPropertyReflector.php
Expand Up @@ -19,8 +19,9 @@ class ClassPropertyReflector
/**
* Returns the name of the getter for the class property or null if there is none.
*
* @param string $classNamespace
* @param string $propertyName
* @param string $classNamespace
* @param string $propertyName
*
* @return string|null
*/
public function getGetter($classNamespace, $propertyName)
Expand All @@ -42,8 +43,9 @@ public function getGetter($classNamespace, $propertyName)
/**
* Returns the name of the setter for the class property or null if there is none.
*
* @param string $classNamespace
* @param string $propertyName
* @param string $classNamespace
* @param string $propertyName
*
* @return string|null
*/
public function getSetter($classNamespace, $propertyName)
Expand All @@ -64,8 +66,9 @@ public function getSetter($classNamespace, $propertyName)
/**
* Returns 'true' if the class property is public (it exists and its scope is 'public').
*
* @param string $classNamespace
* @param string $propertyName
* @param string $classNamespace
* @param string $propertyName
*
* @return bool
*/
public function isPublic($classNamespace, $propertyName)
Expand Down
3 changes: 2 additions & 1 deletion Reflection/EntityMetadataInspector.php
Expand Up @@ -29,7 +29,8 @@ public function __construct(ManagerRegistry $manager)
* Takes the FQCN of an entity and returns all its metadata introspected
* with Doctrine.
*
* @param string $entityClass
* @param string $entityClass
*
* @return array
*/
public function getEntityMetadata($entityClass)
Expand Down

0 comments on commit 779be3e

Please sign in to comment.