Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/php-short-array-syntax'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Jun 5, 2015
2 parents ccd1618 + 8a464ff commit f46acd0
Show file tree
Hide file tree
Showing 122 changed files with 2,247 additions and 2,246 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $config->fixers(
'object_operator',
'php_closing_tag',
'remove_lines_between_uses',
'short_array_syntax',
'short_tag',
'standardize_not_equal',
'trailing_spaces',
Expand Down
18 changes: 9 additions & 9 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class Application implements
*
* @var array
*/
protected $defaultListeners = array(
protected $defaultListeners = [
'RouteListener',
'DispatchListener',
'HttpMethodListener',
'ViewManager',
'SendResponseListener',
);
];

/**
* MVC event token
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getConfig()
* @param array $listeners List of listeners to attach.
* @return Application
*/
public function bootstrap(array $listeners = array())
public function bootstrap(array $listeners = [])
{
$serviceManager = $this->serviceManager;
$events = $this->events;
Expand Down Expand Up @@ -206,10 +206,10 @@ public function getMvcEvent()
*/
public function setEventManager(EventManagerInterface $eventManager)
{
$eventManager->setIdentifiers(array(
$eventManager->setIdentifiers([
__CLASS__,
get_class($this),
));
]);
$this->events = $eventManager;
return $this;
}
Expand Down Expand Up @@ -245,16 +245,16 @@ public function getEventManager()
* @param array $configuration
* @return Application
*/
public static function init($configuration = array())
public static function init($configuration = [])
{
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : [];
$serviceManager = new ServiceManager(new Service\ServiceManagerConfig($smConfig));
$serviceManager->setService('ApplicationConfig', $configuration);
$serviceManager->get('ModuleManager')->loadModules();

$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : array();
$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : [];
$config = $serviceManager->get('Config');
$listenersFromConfigService = isset($config['listeners']) ? $config['listeners'] : array();
$listenersFromConfigService = isset($config['listeners']) ? $config['listeners'] : [];

$listeners = array_unique(array_merge($listenersFromConfigService, $listenersFromAppConfig));

Expand Down
8 changes: 4 additions & 4 deletions src/Controller/AbstractActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ abstract class AbstractActionController extends AbstractController
*/
public function indexAction()
{
return new ViewModel(array(
return new ViewModel([
'content' => 'Placeholder page'
));
]);
}

/**
Expand Down Expand Up @@ -94,7 +94,7 @@ public function onDispatch(MvcEvent $e)
*/
protected function createHttpNotFoundModel(HttpResponse $response)
{
return $this->__call('createHttpNotFoundModel', array($response));
return $this->__call('createHttpNotFoundModel', [$response]);
}

/**
Expand All @@ -105,6 +105,6 @@ protected function createHttpNotFoundModel(HttpResponse $response)
*/
protected function createConsoleNotFoundModel($response)
{
return $this->__call('createConsoleNotFoundModel', array($response));
return $this->__call('createConsoleNotFoundModel', [$response]);
}
}
8 changes: 4 additions & 4 deletions src/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ public function setEventManager(EventManagerInterface $events)

$nsPos = strpos($className, '\\') ?: 0;
$events->setIdentifiers(array_merge(
array(
[
__CLASS__,
$className,
substr($className, 0, $nsPos)
),
],
array_values(class_implements($className)),
(array) $this->eventIdentifier
));
Expand Down Expand Up @@ -320,7 +320,7 @@ public function __call($method, $params)
protected function attachDefaultListeners()
{
$events = $this->getEventManager();
$events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch'));
$events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch']);
}

/**
Expand All @@ -331,7 +331,7 @@ protected function attachDefaultListeners()
*/
public static function getMethodFromAction($action)
{
$method = str_replace(array('.', '-', '_'), ' ', $action);
$method = str_replace(['.', '-', '_'], ' ', $action);
$method = ucwords($method);
$method = str_replace(' ', '', $method);
$method = lcfirst($method);
Expand Down
58 changes: 29 additions & 29 deletions src/Controller/AbstractRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ abstract class AbstractRestfulController extends AbstractController
/**
* @var array
*/
protected $contentTypes = array(
self::CONTENT_TYPE_JSON => array(
protected $contentTypes = [
self::CONTENT_TYPE_JSON => [
'application/hal+json',
'application/json'
)
);
]
];

/**
* Name of request or query parameter containing identifier
Expand All @@ -54,7 +54,7 @@ abstract class AbstractRestfulController extends AbstractController
*
* @var array
*/
protected $customHttpMethodsMap = array();
protected $customHttpMethodsMap = [];

/**
* Set the route match/query parameter name containing the identifier
Expand Down Expand Up @@ -88,9 +88,9 @@ public function create($data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -103,9 +103,9 @@ public function delete($id)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -120,9 +120,9 @@ public function deleteList($data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -135,9 +135,9 @@ public function get($id)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -149,9 +149,9 @@ public function getList()
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -167,9 +167,9 @@ public function head($id = null)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -187,9 +187,9 @@ public function options()
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -206,9 +206,9 @@ public function patch($id, $data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -224,9 +224,9 @@ public function replaceList($data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -242,9 +242,9 @@ public function patchList($data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -258,9 +258,9 @@ public function update($id, $data)
{
$this->response->setStatusCode(405);

return array(
return [
'content' => 'Method Not Allowed'
);
];
}

/**
Expand All @@ -272,9 +272,9 @@ public function notFoundAction()
{
$this->response->setStatusCode(404);

return array(
return [
'content' => 'Page not found'
);
];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ControllerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(ConfigInterface $configuration = null)
{
parent::__construct($configuration);
// Pushing to bottom of stack to ensure this is done last
$this->addInitializer(array($this, 'injectControllerDependencies'), false);
$this->addInitializer([$this, 'injectControllerDependencies'], false);
}

/**
Expand Down Expand Up @@ -132,7 +132,7 @@ public function has($name, $checkAbstractFactories = true, $usePeeringServiceMan
* @param bool $usePeeringServiceManagers
* @return mixed
*/
public function get($name, $options = array(), $usePeeringServiceManagers = false)
public function get($name, $options = [], $usePeeringServiceManagers = false)
{
return parent::get($name, $options, $usePeeringServiceManagers);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Plugin/CreateHttpNotFoundModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function __invoke(Response $response)
{
$response->setStatusCode(404);

return new ViewModel(array('content' => 'Page not found'));
return new ViewModel(['content' => 'Page not found']);
}
}
12 changes: 6 additions & 6 deletions src/Controller/Plugin/FilePostRedirectGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function handlePostRequest(FormInterface $form, $redirect, $redirectTo

// Change required flag to false for any previously uploaded files
$inputFilter = $form->getInputFilter();
$previousFiles = ($container->files) ?: array();
$previousFiles = ($container->files) ?: [];
$this->traverseInputs(
$inputFilter,
$previousFiles,
Expand All @@ -93,14 +93,14 @@ function ($input, $value) {
$prevFileData = $this->getEmptyUploadData($inputFilter, $previousFiles);
$newFileData = $this->getNonEmptyUploadData($inputFilter, $data);
$postFiles = ArrayUtils::merge(
$prevFileData ?: array(),
$newFileData ?: array(),
$prevFileData ?: [],
$newFileData ?: [],
true
);
$post = ArrayUtils::merge($postOther, $postFiles, true);

// Save form data in session
$container->setExpirationHops(1, array('post', 'errors', 'isValid'));
$container->setExpirationHops(1, ['post', 'errors', 'isValid']);
$container->post = $post;
$container->errors = $errors;
$container->isValid = $isValid;
Expand Down Expand Up @@ -299,8 +299,8 @@ function ($input, $value) {
protected function redirect($redirect, $redirectToUrl)
{
$controller = $this->getController();
$params = array();
$options = array();
$params = [];
$options = [];
$reuseMatchedParams = false;

if (null === $redirect) {
Expand Down
Loading

0 comments on commit f46acd0

Please sign in to comment.