diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f5e11f987..f4f6af907 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PhpCsFixer\Config; +use PhpCsFixer\Finder; + +$finder = Finder::create() ->ignoreVCSIgnored(true) ->in(__DIR__.'/lib') ->in(__DIR__.'/data/bin') ->in(__DIR__.'/test') - ->append(array(__FILE__)) + ->append([__FILE__]) // Exclude PHP classes templates/generators, which are not valid PHP files ->exclude('task/generator/skeleton/') ->exclude('plugins/sfDoctrinePlugin/data/generator/') @@ -14,14 +26,31 @@ ->notPath('unit/config/fixtures/sfFilterConfigHandler/result.php') ; -$config = new PhpCsFixer\Config(); -$config->setRules(array( +$config = new Config(); +$config->setRules([ '@PhpCsFixer' => true, '@Symfony' => true, - 'array_syntax' => array( - 'syntax' => 'long', - ), -)) + '@PSR12' => true, + 'array_syntax' => [ + 'syntax' => 'short', + ], + 'fully_qualified_strict_types' => [ + 'import_symbols' => true, + 'leading_backslash_in_global_namespace' => true, + ], + 'header_comment' => [ + 'header' => <<<'EOF' +This file is part of the Symfony1 package. + +(c) Fabien Potencier + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +EOF + ], + 'modernize_strpos' => true, +]) + ->setRiskyAllowed(true) ->setCacheFile('.php-cs-fixer.cache') ->setFinder($finder) ; diff --git a/data/bin/changelog.php b/data/bin/changelog.php index 4eaf5868a..9e232b988 100644 --- a/data/bin/changelog.php +++ b/data/bin/changelog.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -31,16 +32,16 @@ exit(1); } -$filesystem = new sfFilesystem(); +$filesystem = new \sfFilesystem(); list($out, $err) = $filesystem->execute('svn info --xml'); -$info = new SimpleXMLElement($out); +$info = new \SimpleXMLElement($out); -list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', array( +list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', [ $argv[1], (string) $info->entry->repository->root.$argv[2], -)))); -$log = new SimpleXMLElement($out); +]))); +$log = new \SimpleXMLElement($out); foreach ($log->logentry as $logentry) { echo sprintf(' * [%d] %s', $logentry['revision'], trim(preg_replace('/\s*\[[\d\., ]+\]\s*/', '', (string) $logentry->msg))); diff --git a/data/bin/check_configuration.php b/data/bin/check_configuration.php index ccccb38ec..797700ae1 100644 --- a/data/bin/check_configuration.php +++ b/data/bin/check_configuration.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + function is_cli() { return !isset($_SERVER['HTTP_HOST']); @@ -67,7 +76,7 @@ function get_ini_path() echo "\n** Optional checks **\n\n"; check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Doctrine)', false); if (class_exists('PDO')) { - $drivers = PDO::getAvailableDrivers(); + $drivers = \PDO::getAvailableDrivers(); check(count($drivers), 'PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Doctrine)'); } check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false); diff --git a/data/bin/release.php b/data/bin/release.php index df6dec94f..1c8cb7e87 100644 --- a/data/bin/release.php +++ b/data/bin/release.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -26,16 +27,16 @@ require_once __DIR__.'/../../lib/vendor/lime/lime.php'; if (!isset($argv[1])) { - throw new Exception('You must provide version prefix.'); + throw new \Exception('You must provide version prefix.'); } if (!isset($argv[2])) { - throw new Exception('You must provide stability status (alpha/beta/stable).'); + throw new \Exception('You must provide stability status (alpha/beta/stable).'); } $stability = $argv[2]; -$filesystem = new sfFilesystem(); +$filesystem = new \sfFilesystem(); if (('beta' == $stability || 'alpha' == $stability) && count(explode('.', $argv[1])) < 2) { $version_prefix = $argv[1]; @@ -46,7 +47,7 @@ } if (!isset($version)) { - throw new Exception('Unable to find last SVN revision.'); + throw new \Exception('Unable to find last SVN revision.'); } // make a PEAR compatible version @@ -61,7 +62,7 @@ list($result) = $filesystem->execute('php data/bin/symfony symfony:test'); if (0 != $result) { - throw new Exception('Some tests failed. Release process aborted!'); + throw new \Exception('Some tests failed. Release process aborted!'); } if (is_file('package.xml')) { @@ -71,9 +72,9 @@ $filesystem->copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml'); // add class files -$finder = sfFinder::type('file')->relative(); +$finder = \sfFinder::type('file')->relative(); $xml_classes = ''; -$dirs = array('lib' => 'php', 'data' => 'data'); +$dirs = ['lib' => 'php', 'data' => 'data']; foreach ($dirs as $dir => $role) { $class_files = $finder->in($dir); foreach ($class_files as $file) { @@ -82,12 +83,12 @@ } // replace tokens -$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', array( +$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', [ 'SYMFONY_VERSION' => $version, 'CURRENT_DATE' => date('Y-m-d'), 'CLASS_FILES' => $xml_classes, 'STABILITY' => $stability, -)); +]); list($results) = $filesystem->execute('pear package'); echo $results; diff --git a/data/bin/sandbox_installer.php b/data/bin/sandbox_installer.php index 576b28c01..3fb0ac269 100644 --- a/data/bin/sandbox_installer.php +++ b/data/bin/sandbox_installer.php @@ -1,15 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $this->installDir(__DIR__.'/sandbox_skeleton'); $this->logSection('install', 'add symfony CLI for Windows users'); -$this->getFilesystem()->copy(__DIR__.'/symfony.bat', sfConfig::get('sf_root_dir').'/symfony.bat'); +$this->getFilesystem()->copy(__DIR__.'/symfony.bat', \sfConfig::get('sf_root_dir').'/symfony.bat'); $this->logSection('install', 'add LICENSE'); -$this->getFilesystem()->copy(__DIR__.'/../../LICENSE', sfConfig::get('sf_root_dir').'/LICENSE'); +$this->getFilesystem()->copy(__DIR__.'/../../LICENSE', \sfConfig::get('sf_root_dir').'/LICENSE'); $this->logSection('install', 'default to sqlite'); -$this->runTask('configure:database', sprintf("'sqlite:%s/sandbox.db'", sfConfig::get('sf_data_dir'))); +$this->runTask('configure:database', sprintf("'sqlite:%s/sandbox.db'", \sfConfig::get('sf_data_dir'))); $this->logSection('install', 'create an application'); $this->runTask('generate:app', 'frontend'); @@ -18,13 +27,13 @@ $this->runTask('plugin:publish-assets'); $this->logSection('install', 'fix sqlite database permissions'); -touch(sfConfig::get('sf_data_dir').'/sandbox.db'); -chmod(sfConfig::get('sf_data_dir'), 0777); -chmod(sfConfig::get('sf_data_dir').'/sandbox.db', 0777); +touch(\sfConfig::get('sf_data_dir').'/sandbox.db'); +chmod(\sfConfig::get('sf_data_dir'), 0777); +chmod(\sfConfig::get('sf_data_dir').'/sandbox.db', 0777); $this->logSection('install', 'add an empty file in empty directories'); -$seen = array(); -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(sfConfig::get('sf_root_dir')), RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) { +$seen = []; +foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(\sfConfig::get('sf_root_dir')), \RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) { if (!isset($seen[$path]) && $item->isDir() && !$item->isLink()) { touch($item->getRealPath().'/.sf'); } diff --git a/lib/action/sfAction.class.php b/lib/action/sfAction.class.php index cc007b101..488d38a11 100644 --- a/lib/action/sfAction.class.php +++ b/lib/action/sfAction.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -20,16 +20,16 @@ * @method sfWebController getController() * @method sfWebResponse getResponse() */ -abstract class sfAction extends sfComponent +abstract class sfAction extends \sfComponent { - protected $security = array(); + protected $security = []; /** * Initializes this action. * - * @param sfContext $context the current application context - * @param string $moduleName the module name - * @param string $actionName the action name + * @param \sfContext $context the current application context + * @param string $moduleName the module name + * @param string $actionName the action name */ public function initialize($context, $moduleName, $actionName) { @@ -64,11 +64,11 @@ public function postExecute() * * @param string $message Message of the generated exception * - * @throws sfError404Exception + * @throws \sfError404Exception */ public function forward404($message = null) { - throw new sfError404Exception($this->get404Message($message)); + throw new \sfError404Exception($this->get404Message($message)); } /** @@ -77,12 +77,12 @@ public function forward404($message = null) * @param bool $condition A condition that evaluates to true or false * @param string $message Message of the generated exception * - * @throws sfError404Exception + * @throws \sfError404Exception */ public function forward404Unless($condition, $message = null) { if (!$condition) { - throw new sfError404Exception($this->get404Message($message)); + throw new \sfError404Exception($this->get404Message($message)); } } @@ -92,12 +92,12 @@ public function forward404Unless($condition, $message = null) * @param bool $condition A condition that evaluates to true or false * @param string $message Message of the generated exception * - * @throws sfError404Exception + * @throws \sfError404Exception */ public function forward404If($condition, $message = null) { if ($condition) { - throw new sfError404Exception($this->get404Message($message)); + throw new \sfError404Exception($this->get404Message($message)); } } @@ -108,7 +108,7 @@ public function forward404If($condition, $message = null) */ public function redirect404() { - return $this->redirect('/'.sfConfig::get('sf_error_404_module').'/'.sfConfig::get('sf_error_404_action')); + return $this->redirect('/'.\sfConfig::get('sf_error_404_module').'/'.\sfConfig::get('sf_error_404_action')); } /** @@ -119,17 +119,17 @@ public function redirect404() * @param string $module A module name * @param string $action An action name * - * @throws sfStopException + * @throws \sfStopException */ public function forward($module, $action) { - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Forward to action "%s/%s"', $module, $action)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Forward to action "%s/%s"', $module, $action)])); } $this->getController()->forward($module, $action); - throw new sfStopException(); + throw new \sfStopException(); } /** @@ -141,7 +141,7 @@ public function forward($module, $action) * @param string $module A module name * @param string $action An action name * - * @throws sfStopException + * @throws \sfStopException */ public function forwardIf($condition, $module, $action) { @@ -159,7 +159,7 @@ public function forwardIf($condition, $module, $action) * @param string $module A module name * @param string $action An action name * - * @throws sfStopException + * @throws \sfStopException */ public function forwardUnless($condition, $module, $action) { @@ -180,19 +180,19 @@ public function forwardUnless($condition, $module, $action) * @param string $url Url * @param int $statusCode Status code (default to 302) * - * @throws sfStopException + * @throws \sfStopException */ public function redirect($url, $statusCode = 302) { // compatibility with url_for2() style signature if (is_object($statusCode) || is_array($statusCode)) { - $url = array_merge(array('sf_route' => $url), is_object($statusCode) ? array('sf_subject' => $statusCode) : $statusCode); + $url = array_merge(['sf_route' => $url], is_object($statusCode) ? ['sf_subject' => $statusCode] : $statusCode); $statusCode = func_num_args() >= 3 ? func_get_arg(2) : 302; } $this->getController()->redirect($url, 0, $statusCode); - throw new sfStopException(); + throw new \sfStopException(); } /** @@ -204,16 +204,16 @@ public function redirect($url, $statusCode = 302) * @param string $url Url * @param int $statusCode Status code (default to 302) * - * @throws sfStopException + * @throws \sfStopException * - * @see redirect + * @see \redirect */ public function redirectIf($condition, $url, $statusCode = 302) { if ($condition) { // compatibility with url_for2() style signature $arguments = func_get_args(); - call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1)); + call_user_func_array([$this, 'redirect'], array_slice($arguments, 1)); } } @@ -226,16 +226,16 @@ public function redirectIf($condition, $url, $statusCode = 302) * @param string $url Url * @param int $statusCode Status code (default to 302) * - * @throws sfStopException + * @throws \sfStopException * - * @see redirect + * @see \redirect */ public function redirectUnless($condition, $url, $statusCode = 302) { if (!$condition) { // compatibility with url_for2() style signature $arguments = func_get_args(); - call_user_func_array(array($this, 'redirect'), array_slice($arguments, 1)); + call_user_func_array([$this, 'redirect'], array_slice($arguments, 1)); } } @@ -254,7 +254,7 @@ public function renderText($text) { $this->getResponse()->setContent($this->getResponse()->getContent().$text); - return sfView::NONE; + return \sfView::NONE; } /** @@ -271,7 +271,7 @@ public function renderJson($data) $this->getResponse()->setContentType('application/json'); $this->getResponse()->setContent(json_encode($data)); - return sfView::NONE; + return \sfView::NONE; } /** @@ -309,7 +309,7 @@ public function getPartial($templateName, $vars = null) * * @return string sfView::NONE * - * @see getPartial + * @see \getPartial */ public function renderPartial($templateName, $vars = null) { @@ -353,7 +353,7 @@ public function getComponent($moduleName, $componentName, $vars = null) * * @return string sfView::NONE * - * @see getComponent + * @see \getComponent */ public function renderComponent($moduleName, $componentName, $vars = null) { @@ -431,16 +431,16 @@ public function getCredential() */ public function setTemplate($name, $module = null) { - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name)])); } if (null !== $module) { - $dir = $this->context->getConfiguration()->getTemplateDir($module, $name.sfView::SUCCESS.'.php'); + $dir = $this->context->getConfiguration()->getTemplateDir($module, $name.\sfView::SUCCESS.'.php'); $name = $dir.'/'.$name; } - sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template', $name); + \sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template', $name); } /** @@ -455,7 +455,7 @@ public function setTemplate($name, $module = null) */ public function getTemplate() { - return sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template'); + return \sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template'); } /** @@ -469,11 +469,11 @@ public function getTemplate() */ public function setLayout($name) { - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change layout to "%s"', $name)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Change layout to "%s"', $name)])); } - sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name); + \sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name); } /** @@ -486,7 +486,7 @@ public function setLayout($name) */ public function getLayout() { - return sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout'); + return \sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout'); } /** @@ -496,13 +496,13 @@ public function getLayout() */ public function setViewClass($class) { - sfConfig::set('mod_'.strtolower($this->getModuleName()).'_view_class', $class); + \sfConfig::set('mod_'.strtolower($this->getModuleName()).'_view_class', $class); } /** * Returns the current route for this request. * - * @return sfRoute The route for the request + * @return \sfRoute The route for the request */ public function getRoute() { diff --git a/lib/action/sfActionStack.class.php b/lib/action/sfActionStack.class.php index 41c17e228..3569d6a62 100644 --- a/lib/action/sfActionStack.class.php +++ b/lib/action/sfActionStack.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -21,21 +21,21 @@ class sfActionStack { /** @var sfActionStackEntry[] */ - protected $stack = array(); + protected $stack = []; /** * Adds an entry to the action stack. * - * @param string $moduleName A module name - * @param string $actionName An action name - * @param sfAction $actionInstance An sfAction implementation instance + * @param string $moduleName A module name + * @param string $actionName An action name + * @param \sfAction $actionInstance An sfAction implementation instance * - * @return sfActionStackEntry sfActionStackEntry instance + * @return \sfActionStackEntry sfActionStackEntry instance */ public function addEntry($moduleName, $actionName, $actionInstance) { // create our action stack entry and add it to our stack - $actionEntry = new sfActionStackEntry($moduleName, $actionName, $actionInstance); + $actionEntry = new \sfActionStackEntry($moduleName, $actionName, $actionInstance); $this->stack[] = $actionEntry; @@ -47,7 +47,7 @@ public function addEntry($moduleName, $actionName, $actionInstance) * * @param int $index An entry index * - * @return sfActionStackEntry an action stack entry implementation + * @return \sfActionStackEntry an action stack entry implementation */ public function getEntry($index) { @@ -63,7 +63,7 @@ public function getEntry($index) /** * Removes the entry at a specific index. * - * @return sfActionStackEntry an action stack entry implementation + * @return \sfActionStackEntry an action stack entry implementation */ public function popEntry() { diff --git a/lib/action/sfActionStackEntry.class.php b/lib/action/sfActionStackEntry.class.php index 1624e710b..119b19028 100644 --- a/lib/action/sfActionStackEntry.class.php +++ b/lib/action/sfActionStackEntry.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -27,9 +27,9 @@ class sfActionStackEntry /** * Class constructor. * - * @param string $moduleName A module name - * @param string $actionName An action name - * @param sfAction $actionInstance An sfAction implementation instance + * @param string $moduleName A module name + * @param string $actionName An action name + * @param \sfAction $actionInstance An sfAction implementation instance */ public function __construct($moduleName, $actionName, $actionInstance) { @@ -51,7 +51,7 @@ public function getActionName() /** * Retrieves this entry's action instance. * - * @return sfAction An sfAction implementation instance + * @return \sfAction An sfAction implementation instance */ public function getActionInstance() { diff --git a/lib/action/sfActions.class.php b/lib/action/sfActions.class.php index 2a2de62da..55cb7e622 100644 --- a/lib/action/sfActions.class.php +++ b/lib/action/sfActions.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * * @version SVN: $Id$ */ -abstract class sfActions extends sfAction +abstract class sfActions extends \sfAction { /** * Dispatches to the action defined by the 'action' parameter of the sfRequest object. @@ -25,13 +25,13 @@ abstract class sfActions extends sfAction * This method try to execute the executeXXX() method of the current object where XXX is the * defined action name. * - * @param sfRequest $request The current sfRequest object + * @param \sfRequest $request The current sfRequest object * * @return string A string containing the view name associated with this action * - * @throws sfInitializationException + * @throws \sfInitializationException * - * @see sfAction + * @see \sfAction */ public function execute($request) { @@ -40,16 +40,16 @@ public function execute($request) if ('execute' === $actionToRun) { // no action given - throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName())); + throw new \sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName())); } - if (!is_callable(array($this, $actionToRun))) { + if (!is_callable([$this, $actionToRun])) { // action not found - throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.', $this->getModuleName(), $this->getActionName(), $actionToRun)); + throw new \sfInitializationException(sprintf('sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.', $this->getModuleName(), $this->getActionName(), $actionToRun)); } - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Call "%s->%s()"', get_class($this), $actionToRun)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Call "%s->%s()"', get_class($this), $actionToRun)])); } // run action diff --git a/lib/action/sfComponent.class.php b/lib/action/sfComponent.class.php index b933f9a83..d70f71f24 100644 --- a/lib/action/sfComponent.class.php +++ b/lib/action/sfComponent.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,22 +24,22 @@ abstract class sfComponent /** @var string */ protected $actionName = ''; - /** @var sfContext */ + /** @var \sfContext */ protected $context; - /** @var sfEventDispatcher */ + /** @var \sfEventDispatcher */ protected $dispatcher; - /** @var sfRequest */ + /** @var \sfRequest */ protected $request; - /** @var sfResponse */ + /** @var \sfResponse */ protected $response; - /** @var sfParameterHolder */ + /** @var \sfParameterHolder */ protected $varHolder; - /** @var sfParameterHolder */ + /** @var \sfParameterHolder */ protected $requestParameterHolder; /** @@ -46,9 +47,9 @@ abstract class sfComponent * * @see initialize() * - * @param sfContext $context - * @param string $moduleName - * @param string $actionName + * @param \sfContext $context + * @param string $moduleName + * @param string $actionName */ public function __construct($context, $moduleName, $actionName) { @@ -64,7 +65,7 @@ public function __construct($context, $moduleName, $actionName) * * @return string The translated string */ - public function __($string, $args = array(), $catalogue = 'messages') + public function __($string, $args = [], $catalogue = 'messages') { return $this->context->getI18N()->__($string, $args, $catalogue); } @@ -126,13 +127,13 @@ public function __unset($name) * * @return mixed The returned value of the called method * - * @throws sfException If called method is undefined + * @throws \sfException If called method is undefined */ public function __call($method, $arguments) { - $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', array('method' => $method, 'arguments' => $arguments))); + $event = $this->dispatcher->notifyUntil(new \sfEvent($this, 'component.method_not_found', ['method' => $method, 'arguments' => $arguments])); if (!$event->isProcessed()) { - throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); + throw new \sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); } return $event->getReturnValue(); @@ -141,9 +142,9 @@ public function __call($method, $arguments) /** * Initializes this component. * - * @param sfContext $context the current application context - * @param string $moduleName the module name - * @param string $actionName the action name + * @param \sfContext $context the current application context + * @param string $moduleName the module name + * @param string $actionName the action name */ public function initialize($context, $moduleName, $actionName) { @@ -151,7 +152,7 @@ public function initialize($context, $moduleName, $actionName) $this->actionName = $actionName; $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); - $this->varHolder = new sfParameterHolder(); + $this->varHolder = new \sfParameterHolder(); $this->request = $context->getRequest(); $this->response = $context->getResponse(); $this->requestParameterHolder = $this->request->getParameterHolder(); @@ -168,7 +169,7 @@ public function initialize($context, $moduleName, $actionName) * user account, a shopping cart, or even a something as simple as a * single product. * - * @param sfRequest $request The current sfRequest object + * @param \sfRequest $request The current sfRequest object * * @return mixed A string containing the view name associated with this action */ @@ -197,7 +198,7 @@ public function getActionName() /** * Retrieves the current application context. * - * @return sfContext The current sfContext instance + * @return \sfContext The current sfContext instance */ final public function getContext() { @@ -207,7 +208,7 @@ final public function getContext() /** * Retrieves the current service container instance. * - * @return sfServiceContainer The current sfServiceContainer instance + * @return \sfServiceContainer The current sfServiceContainer instance */ final public function getServiceContainer() { @@ -229,7 +230,7 @@ public function getService($id) /** * Retrieves the current logger instance. * - * @return sfLogger The current sfLogger instance + * @return \sfLogger The current sfLogger instance */ final public function getLogger() { @@ -244,12 +245,12 @@ final public function getLogger() * (available priorities: emerg, alert, crit, err, * warning, notice, info, debug) * - * @see sfLogger + * @see \sfLogger */ public function logMessage($message, $priority = 'info') { - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => constant('sfLogger::'.strtoupper($priority))))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [$message, 'priority' => constant('sfLogger::'.strtoupper($priority))])); } } @@ -293,7 +294,7 @@ public function hasRequestParameter($name) * * $this->getContext()->getRequest() * - * @return sfRequest The current sfRequest implementation instance + * @return \sfRequest The current sfRequest implementation instance */ public function getRequest() { @@ -307,7 +308,7 @@ public function getRequest() * * $this->getContext()->getResponse() * - * @return sfResponse The current sfResponse implementation instance + * @return \sfResponse The current sfResponse implementation instance */ public function getResponse() { @@ -321,7 +322,7 @@ public function getResponse() * * $this->getContext()->getController() * - * @return sfController The current sfController implementation instance + * @return \sfController The current sfController implementation instance */ public function getController() { @@ -341,7 +342,7 @@ public function getController() * * @return string The URL */ - public function generateUrl($route, $params = array(), $absolute = false) + public function generateUrl($route, $params = [], $absolute = false) { return $this->context->getRouting()->generate($route, $params, $absolute); } @@ -353,7 +354,7 @@ public function generateUrl($route, $params = array(), $absolute = false) * * $this->getContext()->getUser() * - * @return sfUser The current sfUser implementation instance + * @return \sfUser The current sfUser implementation instance */ public function getUser() { @@ -363,7 +364,7 @@ public function getUser() /** * Gets the current mailer instance. * - * @return sfMailer A sfMailer instance + * @return \sfMailer A sfMailer instance */ public function getMailer() { @@ -383,7 +384,7 @@ public function getMailer() */ public function setVar($name, $value, $safe = false) { - $this->varHolder->set($name, $safe ? new sfOutputEscaperSafe($value) : $value); + $this->varHolder->set($name, $safe ? new \sfOutputEscaperSafe($value) : $value); } /** @@ -401,7 +402,7 @@ public function getVar($name) /** * Gets the sfParameterHolder object that stores the template variables. * - * @return sfParameterHolder the variable holder + * @return \sfParameterHolder the variable holder */ public function getVarHolder() { diff --git a/lib/action/sfComponents.class.php b/lib/action/sfComponents.class.php index ce96e70e5..51a260caa 100644 --- a/lib/action/sfComponents.class.php +++ b/lib/action/sfComponents.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,17 +16,17 @@ * * @version SVN: $Id$ */ -abstract class sfComponents extends sfComponent +abstract class sfComponents extends \sfComponent { /** - * @param sfRequest $request + * @param \sfRequest $request * - * @throws sfInitializationException + * @throws \sfInitializationException * - * @see sfComponent + * @see \sfComponent */ public function execute($request) { - throw new sfInitializationException('sfComponents initialization failed.'); + throw new \sfInitializationException('sfComponents initialization failed.'); } } diff --git a/lib/addon/sfData.class.php b/lib/addon/sfData.class.php index b03a4a55e..16c3b5427 100644 --- a/lib/addon/sfData.class.php +++ b/lib/addon/sfData.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,7 +20,7 @@ abstract class sfData { protected $deleteCurrentData = true; - protected $object_references = array(); + protected $object_references = []; /** * Sets a flag to indicate if the current data in the database @@ -60,15 +61,15 @@ abstract public function loadDataFromArray($data); * * @return array A list of *.yml files * - * @throws sfInitializationException if the directory or file does not exist + * @throws \sfInitializationException if the directory or file does not exist */ public function getFiles($element = null) { if (null === $element) { - $element = sfConfig::get('sf_data_dir').'/fixtures'; + $element = \sfConfig::get('sf_data_dir').'/fixtures'; } - $files = array(); + $files = []; if (is_array($element)) { foreach ($element as $e) { $files = array_merge($files, $this->getFiles($e)); @@ -76,9 +77,9 @@ public function getFiles($element = null) } elseif (is_file($element)) { $files[] = $element; } elseif (is_dir($element)) { - $files = sfFinder::type('file')->name('*.yml')->sort_by_name()->in($element); + $files = \sfFinder::type('file')->name('*.yml')->sort_by_name()->in($element); } else { - throw new sfInitializationException(sprintf('You must give an array, a directory or a file to sfData::getFiles() (%s given).', $element)); + throw new \sfInitializationException(sprintf('You must give an array, a directory or a file to sfData::getFiles() (%s given).', $element)); } $files = array_unique($files); @@ -95,7 +96,7 @@ public function getFiles($element = null) protected function doLoadDataFromFile($file) { // import new datas - $data = sfYaml::load($file, sfConfig::get('sf_charset', 'UTF-8')); + $data = \sfYaml::load($file, \sfConfig::get('sf_charset', 'UTF-8')); $this->loadDataFromArray($data); } @@ -108,8 +109,8 @@ protected function doLoadDataFromFile($file) */ protected function doLoadData(array $files) { - $this->object_references = array(); - $this->maps = array(); + $this->object_references = []; + $this->maps = []; foreach ($files as $file) { $this->doLoadDataFromFile($file); diff --git a/lib/addon/sfPager.class.php b/lib/addon/sfPager.class.php index 1800e3fc3..d020e86b0 100644 --- a/lib/addon/sfPager.class.php +++ b/lib/addon/sfPager.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -abstract class sfPager implements Iterator, Countable +abstract class sfPager implements \Iterator, \Countable { protected $page = 1; protected $maxPerPage = 0; @@ -25,7 +26,7 @@ abstract class sfPager implements Iterator, Countable protected $tableName = ''; protected $objects; protected $cursor = 1; - protected $parameters = array(); + protected $parameters = []; protected $currentMaxLink = 1; protected $parameterHolder; protected $maxRecordLimit = false; @@ -43,7 +44,7 @@ public function __construct($class, $maxPerPage = 10) { $this->setClass($class); $this->setMaxPerPage($maxPerPage); - $this->parameterHolder = new sfParameterHolder(); + $this->parameterHolder = new \sfParameterHolder(); } /** @@ -99,7 +100,7 @@ public function setMaxRecordLimit($limit) */ public function getLinks($nb_links = 5) { - $links = array(); + $links = []; $tmp = $this->page - floor($nb_links / 2); $check = $this->lastPage - $nb_links + 1; $limit = $check > 0 ? $check : 1; @@ -174,7 +175,7 @@ public function getCurrent() /** * Returns the next object. * - * @return mixed|null + * @return \mixed|null */ public function getNext() { @@ -188,7 +189,7 @@ public function getNext() /** * Returns the previous object. * - * @return mixed|null + * @return \mixed|null */ public function getPrevious() { @@ -382,7 +383,7 @@ public function isLastPage() /** * Returns the current pager's parameter holder. * - * @return sfParameterHolder + * @return \sfParameterHolder */ public function getParameterHolder() { @@ -392,8 +393,8 @@ public function getParameterHolder() /** * Returns a parameter. * - * @param string $name - * @param mixed|null $default + * @param string $name + * @param \mixed|null $default */ public function getParameter($name, $default = null) { @@ -425,7 +426,7 @@ public function setParameter($name, $value) /** * Returns the current result. * - * @see Iterator + * @see \Iterator */ #[\ReturnTypeWillChange] public function current() @@ -440,7 +441,7 @@ public function current() /** * Returns the current key. * - * @see Iterator + * @see \Iterator */ #[\ReturnTypeWillChange] public function key() @@ -455,7 +456,7 @@ public function key() /** * Advances the internal pointer and returns the current result. * - * @see Iterator + * @see \Iterator */ #[\ReturnTypeWillChange] public function next() @@ -472,7 +473,7 @@ public function next() /** * Resets the internal pointer and returns the current result. * - * @see Iterator + * @see \Iterator */ #[\ReturnTypeWillChange] public function rewind() @@ -489,7 +490,7 @@ public function rewind() /** * Returns true if pointer is within bounds. * - * @see Iterator + * @see \Iterator */ #[\ReturnTypeWillChange] public function valid() @@ -504,7 +505,7 @@ public function valid() /** * Returns the total number of results. * - * @see Countable + * @see \Countable */ #[\ReturnTypeWillChange] public function count() diff --git a/lib/autoload/sfAutoload.class.php b/lib/autoload/sfAutoload.class.php index f3e238e27..2442a88a3 100644 --- a/lib/autoload/sfAutoload.class.php +++ b/lib/autoload/sfAutoload.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,8 +24,8 @@ class sfAutoload protected static $freshCache = false; protected static $instance; - protected $overriden = array(); - protected $classes = array(); + protected $overriden = []; + protected $classes = []; protected function __construct() { @@ -33,12 +34,12 @@ protected function __construct() /** * Retrieves the singleton instance of this class. * - * @return sfAutoload a sfAutoload implementation instance + * @return \sfAutoload a sfAutoload implementation instance */ public static function getInstance() { if (!isset(self::$instance)) { - self::$instance = new sfAutoload(); + self::$instance = new \sfAutoload(); } return self::$instance; @@ -47,14 +48,14 @@ public static function getInstance() /** * Register sfAutoload in spl autoloader. * - * @throws sfException + * @throws \sfException */ public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { - throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); + if (false === spl_autoload_register([self::getInstance(), 'autoload'])) { + throw new \sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); } } @@ -63,7 +64,7 @@ public static function register() */ public static function unregister() { - spl_autoload_unregister(array(self::getInstance(), 'autoload')); + spl_autoload_unregister([self::getInstance(), 'autoload']); } /** @@ -86,7 +87,7 @@ public function setClassPath($class, $path) * * @param string $class A PHP class name * - * @return string|null An absolute path + * @return \string|null An absolute path */ public function getClassPath($class) { @@ -109,8 +110,8 @@ public function reloadClasses($force = false) return false; } - $configuration = sfProjectConfiguration::getActive(); - if (!$configuration || !$configuration instanceof sfApplicationConfiguration) { + $configuration = \sfProjectConfiguration::getActive(); + if (!$configuration || !$configuration instanceof \sfApplicationConfiguration) { return false; } @@ -177,10 +178,10 @@ public function loadClass($class) if (isset($this->classes[$class])) { try { require $this->classes[$class]; - } catch (sfException $e) { + } catch (\sfException $e) { $e->printStackTrace(); - } catch (Exception $e) { - sfException::createFromException($e)->printStackTrace(); + } catch (\Exception $e) { + \sfException::createFromException($e)->printStackTrace(); } return true; @@ -188,16 +189,16 @@ public function loadClass($class) // see if the file exists in the current module lib directory if ( - sfContext::hasInstance() - && ($module = sfContext::getInstance()->getModuleName()) + \sfContext::hasInstance() + && ($module = \sfContext::getInstance()->getModuleName()) && isset($this->classes[$module.'/'.$class]) ) { try { require $this->classes[$module.'/'.$class]; - } catch (sfException $e) { + } catch (\sfException $e) { $e->printStackTrace(); - } catch (Exception $e) { - sfException::createFromException($e)->printStackTrace(); + } catch (\Exception $e) { + \sfException::createFromException($e)->printStackTrace(); } return true; diff --git a/lib/autoload/sfAutoloadAgain.class.php b/lib/autoload/sfAutoloadAgain.class.php index edf0c9461..1526a560c 100644 --- a/lib/autoload/sfAutoloadAgain.class.php +++ b/lib/autoload/sfAutoloadAgain.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -32,7 +33,7 @@ protected function __construct() /** * Returns the singleton autoloader. * - * @return sfAutoloadAgain + * @return \sfAutoloadAgain */ public static function getInstance() { @@ -67,7 +68,7 @@ public function autoload($class) } } } else { - $position = array_search(array(__CLASS__, 'autoload'), $autoloads, true); + $position = array_search([__CLASS__, 'autoload'], $autoloads, true); } if (isset($autoloads[$position + 1])) { @@ -80,7 +81,7 @@ public function autoload($class) return class_exists($class, false) || interface_exists($class, false); } - $autoload = sfAutoload::getInstance(); + $autoload = \sfAutoload::getInstance(); $autoload->reloadClasses(true); $this->reloaded = true; @@ -104,7 +105,7 @@ public function isRegistered() public function register() { if (!$this->isRegistered()) { - spl_autoload_register(array($this, 'autoload')); + spl_autoload_register([$this, 'autoload']); $this->registered = true; } } @@ -114,7 +115,7 @@ public function register() */ public function unregister() { - spl_autoload_unregister(array($this, 'autoload')); + spl_autoload_unregister([$this, 'autoload']); $this->registered = false; } } diff --git a/lib/autoload/sfCoreAutoload.class.php b/lib/autoload/sfCoreAutoload.class.php index fafe37026..3120093b2 100755 --- a/lib/autoload/sfCoreAutoload.class.php +++ b/lib/autoload/sfCoreAutoload.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -30,7 +31,7 @@ class sfCoreAutoload // Don't edit this property by hand. // To update it, use sfCoreAutoload::make() - protected $classes = array( + protected $classes = [ 'sfaction' => 'action/sfAction.class.php', 'sfactionstack' => 'action/sfActionStack.class.php', 'sfactionstackentry' => 'action/sfActionStackEntry.class.php', @@ -394,7 +395,7 @@ class sfCoreAutoload 'sfyamldumper' => 'yaml/sfYamlDumper.class.php', 'sfyamlinline' => 'yaml/sfYamlInline.class.php', 'sfyamlparser' => 'yaml/sfYamlParser.class.php', - ); + ]; protected function __construct() { @@ -404,12 +405,12 @@ protected function __construct() /** * Retrieves the singleton instance of this class. * - * @return sfCoreAutoload a sfCoreAutoload implementation instance + * @return \sfCoreAutoload a sfCoreAutoload implementation instance */ public static function getInstance() { if (!isset(self::$instance)) { - self::$instance = new sfCoreAutoload(); + self::$instance = new \sfCoreAutoload(); } return self::$instance; @@ -418,7 +419,7 @@ public static function getInstance() /** * Register sfCoreAutoload in spl autoloader. * - * @throws sfException If unable to register SPL autoload function + * @throws \sfException If unable to register SPL autoload function */ public static function register() { @@ -427,8 +428,8 @@ public static function register() } ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { - throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); + if (false === spl_autoload_register([self::getInstance(), 'autoload'])) { + throw new \sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); } self::$registered = true; @@ -439,7 +440,7 @@ public static function register() */ public static function unregister() { - spl_autoload_unregister(array(self::getInstance(), 'autoload')); + spl_autoload_unregister([self::getInstance(), 'autoload']); self::$registered = false; } @@ -466,7 +467,7 @@ public function autoload($class) * * @param string $class The class name (case insensitive) * - * @return string|null An absolute path or null + * @return \string|null An absolute path or null */ public function getClassPath($class) { @@ -500,7 +501,7 @@ public static function make() require_once $libDir.'/util/sfFinder.class.php'; - $files = sfFinder::type('file') + $files = \sfFinder::type('file') ->prune('plugins') ->prune('vendor') ->prune('skeleton') @@ -515,7 +516,7 @@ public static function make() $classes = ''; foreach ($files as $file) { $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); - $class = basename($file, false === strpos($file, '.class.php') ? '.php' : '.class.php'); + $class = basename($file, !str_contains($file, '.class.php') ? '.php' : '.class.php'); $contents = file_get_contents($file); if (false !== stripos($contents, 'class '.$class) diff --git a/lib/autoload/sfSimpleAutoload.class.php b/lib/autoload/sfSimpleAutoload.class.php index 05c3983c7..475afa5a7 100755 --- a/lib/autoload/sfSimpleAutoload.class.php +++ b/lib/autoload/sfSimpleAutoload.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -26,10 +27,10 @@ class sfSimpleAutoload protected $cacheFile; protected $cacheLoaded = false; protected $cacheChanged = false; - protected $dirs = array(); - protected $files = array(); - protected $classes = array(); - protected $overriden = array(); + protected $dirs = []; + protected $files = []; + protected $classes = []; + protected $overriden = []; protected function __construct($cacheFile = null) { @@ -45,12 +46,12 @@ protected function __construct($cacheFile = null) * * @param string $cacheFile The file path to save the cache * - * @return sfSimpleAutoload a sfSimpleAutoload implementation instance + * @return \sfSimpleAutoload a sfSimpleAutoload implementation instance */ public static function getInstance($cacheFile = null) { if (!isset(self::$instance)) { - self::$instance = new sfSimpleAutoload($cacheFile); + self::$instance = new \sfSimpleAutoload($cacheFile); } return self::$instance; @@ -59,7 +60,7 @@ public static function getInstance($cacheFile = null) /** * Register sfSimpleAutoload in spl autoloader. * - * @throws sfException + * @throws \sfException */ public static function register() { @@ -68,12 +69,12 @@ public static function register() } ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { - throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); + if (false === spl_autoload_register([self::getInstance(), 'autoload'])) { + throw new \sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); } if (self::getInstance()->cacheFile) { - register_shutdown_function(array(self::getInstance(), 'saveCache')); + register_shutdown_function([self::getInstance(), 'saveCache']); } self::$registered = true; @@ -84,7 +85,7 @@ public static function register() */ public static function unregister() { - spl_autoload_unregister(array(self::getInstance(), 'autoload')); + spl_autoload_unregister([self::getInstance(), 'autoload']); self::$registered = false; } @@ -108,10 +109,10 @@ public function autoload($class) if (isset($this->classes[$class])) { try { require $this->classes[$class]; - } catch (sfException $e) { + } catch (\sfException $e) { $e->printStackTrace(); - } catch (Exception $e) { - sfException::createFromException($e)->printStackTrace(); + } catch (\Exception $e) { + \sfException::createFromException($e)->printStackTrace(); } return true; @@ -142,7 +143,7 @@ public function saveCache() { if ($this->cacheChanged) { if (is_writable(dirname($this->cacheFile))) { - file_put_contents($this->cacheFile, serialize(array($this->classes, $this->dirs, $this->files))); + file_put_contents($this->cacheFile, serialize([$this->classes, $this->dirs, $this->files])); } $this->cacheChanged = false; @@ -154,7 +155,7 @@ public function saveCache() */ public function reload() { - $this->classes = array(); + $this->classes = []; $this->cacheLoaded = false; foreach ($this->dirs as $dir) { @@ -189,7 +190,7 @@ public function removeCache() */ public function addDirectory($dir, $ext = '.php') { - $finder = sfFinder::type('file')->follow_link()->name('*'.$ext); + $finder = \sfFinder::type('file')->follow_link()->name('*'.$ext); if ($dirs = glob($dir)) { foreach ($dirs as $dir) { @@ -275,7 +276,7 @@ public function setClassPath($class, $path) * * @param string $class A PHP class name * - * @return string|null An absolute path + * @return \string|null An absolute path */ public function getClassPath($class) { @@ -289,11 +290,11 @@ public function getClassPath($class) * * @param array $files An array of autoload.yml files * - * @see sfAutoloadConfigHandler + * @see \sfAutoloadConfigHandler */ public function loadConfiguration(array $files) { - $config = new sfAutoloadConfigHandler(); + $config = new \sfAutoloadConfigHandler(); foreach ($config->evaluate($files) as $class => $file) { $this->setClassPath($class, $file); } diff --git a/lib/cache/sfAPCCache.class.php b/lib/cache/sfAPCCache.class.php index 721bea021..abaaf0edc 100644 --- a/lib/cache/sfAPCCache.class.php +++ b/lib/cache/sfAPCCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfAPCCache extends sfCache +class sfAPCCache extends \sfCache { protected $enabled; @@ -26,9 +27,9 @@ class sfAPCCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); @@ -36,9 +37,9 @@ public function initialize($options = array()) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -52,7 +53,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -66,9 +67,9 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { @@ -80,7 +81,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -92,21 +93,21 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { if (!$this->enabled) { return true; } - if (sfCache::ALL === $mode) { + if (\sfCache::ALL === $mode) { return apc_clear_cache('user'); } } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -118,7 +119,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -130,7 +131,7 @@ public function getTimeout($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { diff --git a/lib/cache/sfAPCuCache.class.php b/lib/cache/sfAPCuCache.class.php index fe813331c..90ac62419 100644 --- a/lib/cache/sfAPCuCache.class.php +++ b/lib/cache/sfAPCuCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +17,7 @@ * * @version SVN: $Id$ */ -class sfAPCuCache extends sfCache +class sfAPCuCache extends \sfCache { protected $enabled; @@ -27,9 +28,9 @@ class sfAPCuCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); @@ -37,9 +38,9 @@ public function initialize($options = array()) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -53,7 +54,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -67,9 +68,9 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { @@ -81,7 +82,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -93,21 +94,21 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { if (!$this->enabled) { return true; } - if (sfCache::ALL === $mode) { + if (\sfCache::ALL === $mode) { return apcu_clear_cache(); } } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -119,7 +120,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -131,7 +132,7 @@ public function getTimeout($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { diff --git a/lib/cache/sfCache.class.php b/lib/cache/sfCache.class.php index 99832f2e5..b586c9c72 100644 --- a/lib/cache/sfCache.class.php +++ b/lib/cache/sfCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -21,7 +22,7 @@ abstract class sfCache public const ALL = 2; public const SEPARATOR = ':'; - protected $options = array(); + protected $options = []; /** * Class constructor. @@ -30,7 +31,7 @@ abstract class sfCache * * @param array $options */ - public function __construct($options = array()) + public function __construct($options = []) { $this->initialize($options); } @@ -50,15 +51,15 @@ public function __construct($options = array()) * * * lifetime (optional): The default life time (default value: 86400) * - * @throws sfInitializationException If an error occurs while initializing this sfCache instance + * @throws \sfInitializationException If an error occurs while initializing this sfCache instance */ - public function initialize($options = array()) + public function initialize($options = []) { - $this->options = array_merge(array( + $this->options = array_merge([ 'automatic_cleaning_factor' => 1000, 'lifetime' => 86400, 'prefix' => md5(__DIR__), - ), $options); + ], $options); $this->options['prefix'] .= self::SEPARATOR; } @@ -109,7 +110,7 @@ abstract public function remove($key); * * @return bool true if no problem * - * @see patternToRegexp + * @see \patternToRegexp */ abstract public function removePattern($pattern); @@ -151,7 +152,7 @@ abstract public function getLastModified($key); */ public function getMany($keys) { - $data = array(); + $data = []; foreach ($keys as $key) { $data[$key] = $this->get($key); } @@ -176,11 +177,11 @@ public function getLifetime($lifetime) * * @return mixed The backend object * - * @throws sfException + * @throws \sfException */ public function getBackend() { - throw new sfException('This cache class does not have a backend object.'); + throw new \sfException('This cache class does not have a backend object.'); } /** @@ -222,8 +223,8 @@ public function setOption($name, $value) protected function patternToRegexp($pattern) { $regexp = str_replace( - array('\\*\\*', '\\*'), - array('.+?', '[^'.preg_quote(sfCache::SEPARATOR, '#').']+'), + ['\\*\\*', '\\*'], + ['.+?', '[^'.preg_quote(\sfCache::SEPARATOR, '#').']+'], preg_quote($pattern, '#') ); diff --git a/lib/cache/sfEAcceleratorCache.class.php b/lib/cache/sfEAcceleratorCache.class.php index c97092456..c9c3dad5f 100644 --- a/lib/cache/sfEAcceleratorCache.class.php +++ b/lib/cache/sfEAcceleratorCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfEAcceleratorCache extends sfCache +class sfEAcceleratorCache extends \sfCache { /** * Initializes this sfCache instance. @@ -24,28 +25,28 @@ class sfEAcceleratorCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache * * @param array $options * - * @throws sfInitializationException + * @throws \sfInitializationException */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); if (!function_exists('eaccelerator_put') || !ini_get('eaccelerator.enable')) { - throw new sfInitializationException('You must have EAccelerator installed and enabled to use sfEAcceleratorCache class (or perhaps you forgot to add --with-eaccelerator-shared-memory when installing).'); + throw new \sfInitializationException('You must have EAccelerator installed and enabled to use sfEAcceleratorCache class (or perhaps you forgot to add --with-eaccelerator-shared-memory when installing).'); } } /** - * @see sfCache + * @see \sfCache * - * @param string $key - * @param mixed|null $default + * @param string $key + * @param \mixed|null $default * - * @return string|null + * @return \string|null */ public function get($key, $default = null) { @@ -55,7 +56,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache * * @param string $key * @@ -67,11 +68,11 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param string $key - * @param string $data - * @param int|null $lifetime + * @param string $key + * @param string $data + * @param \int|null $lifetime * * @return bool */ @@ -81,7 +82,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -89,7 +90,7 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { @@ -107,20 +108,20 @@ public function removePattern($pattern) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { - if (sfCache::OLD === $mode) { + if (\sfCache::OLD === $mode) { return eaccelerator_gc(); } $infos = eaccelerator_list_keys(); if (is_array($infos)) { foreach ($infos as $info) { - if (false !== strpos($info['name'], $this->getOption('prefix'))) { + if (str_contains($info['name'], $this->getOption('prefix'))) { // eaccelerator bug (http://eaccelerator.net/ticket/287) - $key = 0 === strpos($info['name'], ':') ? substr($info['name'], 1) : $info['name']; + $key = str_starts_with($info['name'], ':') ? substr($info['name'], 1) : $info['name']; if (!eaccelerator_rm($key)) { return false; } @@ -132,7 +133,7 @@ public function clean($mode = sfCache::ALL) } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -144,7 +145,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { diff --git a/lib/cache/sfFileCache.class.php b/lib/cache/sfFileCache.class.php index 11d2d3c84..5f02b51d0 100644 --- a/lib/cache/sfFileCache.class.php +++ b/lib/cache/sfFileCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfFileCache extends sfCache +class sfFileCache extends \sfCache { public const READ_DATA = 1; public const READ_TIMEOUT = 2; @@ -32,23 +33,23 @@ class sfFileCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); if (!$this->getOption('cache_dir')) { - throw new sfInitializationException('You must pass a "cache_dir" option to initialize a sfFileCache object.'); + throw new \sfInitializationException('You must pass a "cache_dir" option to initialize a sfFileCache object.'); } $this->setcache_dir($this->getOption('cache_dir')); } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -67,7 +68,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -77,21 +78,21 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { if ($this->getOption('automatic_cleaning_factor') > 0 && 1 == mt_rand(1, $this->getOption('automatic_cleaning_factor'))) { - $this->clean(sfCache::OLD); + $this->clean(\sfCache::OLD); } return $this->write($this->getFilePath($key), $data, time() + $this->getLifetime($lifetime)); } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -99,27 +100,27 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { - if (false !== strpos($pattern, '**')) { - $pattern = str_replace(sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION; + if (str_contains($pattern, '**')) { + $pattern = str_replace(\sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION; $regexp = self::patternToRegexp($pattern); - $paths = array(); - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->getOption('cache_dir'))) as $path) { + $paths = []; + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getOption('cache_dir'))) as $path) { if (preg_match($regexp, str_replace($this->getOption('cache_dir').DIRECTORY_SEPARATOR, '', $path))) { $paths[] = $path; } } } else { - $paths = glob($this->getOption('cache_dir').DIRECTORY_SEPARATOR.str_replace(sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION); + $paths = glob($this->getOption('cache_dir').DIRECTORY_SEPARATOR.str_replace(\sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION); } foreach ($paths as $path) { if (is_dir($path)) { - sfToolkit::clearDirectory($path); + \sfToolkit::clearDirectory($path); } else { @unlink($path); } @@ -127,17 +128,17 @@ public function removePattern($pattern) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { if (!is_dir($this->getOption('cache_dir'))) { return true; } $result = true; - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->getOption('cache_dir'))) as $file) { - if (sfCache::ALL == $mode || !$this->isValid($file)) { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getOption('cache_dir'))) as $file) { + if (\sfCache::ALL == $mode || !$this->isValid($file)) { $result = @unlink($file) && $result; } } @@ -146,7 +147,7 @@ public function clean($mode = sfCache::ALL) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -162,7 +163,7 @@ public function getTimeout($key) } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -197,7 +198,7 @@ protected function isValid($path) */ protected function getFilePath($key) { - return $this->getOption('cache_dir').DIRECTORY_SEPARATOR.str_replace(sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $key).self::EXTENSION; + return $this->getOption('cache_dir').DIRECTORY_SEPARATOR.str_replace(\sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $key).self::EXTENSION; } /** @@ -211,12 +212,12 @@ protected function getFilePath($key) * * @return array the (meta)data of the cache file. E.g. $data[sfFileCache::READ_DATA] * - * @throws sfCacheException + * @throws \sfCacheException */ protected function read($path, $type = self::READ_DATA) { if (!$fp = @fopen($path, 'rb')) { - throw new sfCacheException(sprintf('Unable to read cache file "%s".', $path)); + throw new \sfCacheException(sprintf('Unable to read cache file "%s".', $path)); } @flock($fp, LOCK_SH); @@ -255,7 +256,7 @@ protected function read($path, $type = self::READ_DATA) * * @return bool true if ok, otherwise false * - * @throws sfCacheException + * @throws \sfCacheException */ protected function write($path, $data, $timeout) { @@ -270,7 +271,7 @@ protected function write($path, $data, $timeout) $tmpFile = tempnam($cacheDir, basename($path)); if (!$fp = @fopen($tmpFile, 'wb')) { - throw new sfCacheException(sprintf('Unable to write cache file "%s".', $tmpFile)); + throw new \sfCacheException(sprintf('Unable to write cache file "%s".', $tmpFile)); } @fwrite($fp, str_pad($timeout, 12, 0, STR_PAD_LEFT)); diff --git a/lib/cache/sfFunctionCache.class.php b/lib/cache/sfFunctionCache.class.php index 08da5f124..3295aaff1 100644 --- a/lib/cache/sfFunctionCache.class.php +++ b/lib/cache/sfFunctionCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -22,9 +23,9 @@ class sfFunctionCache /** * Constructor. * - * @param sfCache $cache An sfCache object instance + * @param \sfCache $cache An sfCache object instance */ - public function __construct(sfCache $cache) + public function __construct(\sfCache $cache) { $this->cache = $cache; } @@ -44,10 +45,10 @@ public function __construct(sfCache $cache) * * @return mixed The result of the function/method * - * @throws Exception - * @throws sfException + * @throws \Exception + * @throws \sfException */ - public function call($callable, $arguments = array()) + public function call($callable, $arguments = []) { // Generate a cache id $key = $this->computeCacheKey($callable, $arguments); @@ -56,10 +57,10 @@ public function call($callable, $arguments = array()) if (null !== $serialized) { $data = unserialize($serialized); } else { - $data = array(); + $data = []; if (!is_callable($callable)) { - throw new sfException('The first argument to call() must be a valid callable.'); + throw new \sfException('The first argument to call() must be a valid callable.'); } ob_start(); @@ -67,7 +68,7 @@ public function call($callable, $arguments = array()) try { $data['result'] = call_user_func_array($callable, $arguments); - } catch (Exception $e) { + } catch (\Exception $e) { ob_end_clean(); throw $e; @@ -86,7 +87,7 @@ public function call($callable, $arguments = array()) /** * Returns the cache instance. * - * @return sfCache The sfCache instance + * @return \sfCache The sfCache instance */ public function getCache() { @@ -101,7 +102,7 @@ public function getCache() * * @return string The associated cache key */ - public function computeCacheKey($callable, $arguments = array()) + public function computeCacheKey($callable, $arguments = []) { return md5(serialize($callable).serialize($arguments)); } diff --git a/lib/cache/sfMemcacheCache.class.php b/lib/cache/sfMemcacheCache.class.php index 7d69a6336..725cbc9ef 100644 --- a/lib/cache/sfMemcacheCache.class.php +++ b/lib/cache/sfMemcacheCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,9 +16,9 @@ * * @version SVN: $Id$ */ -class sfMemcacheCache extends sfCache +class sfMemcacheCache extends \sfCache { - /** @var Memcache */ + /** @var \Memcache */ protected $memcache; /** @@ -35,41 +36,41 @@ class sfMemcacheCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); if (!class_exists('Memcache')) { - throw new sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.'); + throw new \sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.'); } if ($this->getOption('memcache')) { $this->memcache = $this->getOption('memcache'); } else { - $this->memcache = new Memcache(); + $this->memcache = new \Memcache(); if ($this->getOption('servers')) { foreach ($this->getOption('servers') as $server) { $port = isset($server['port']) ? $server['port'] : 11211; if (!$this->memcache->addServer($server['host'], $port, isset($server['persistent']) ? $server['persistent'] : true)) { - throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $server['host'], $port)); + throw new \sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $server['host'], $port)); } } } else { $method = $this->getOption('persistent', true) ? 'pconnect' : 'connect'; if (!$this->memcache->{$method}($this->getOption('host', 'localhost'), $this->getOption('port', 11211), $this->getOption('timeout', 1))) { - throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $this->getOption('host', 'localhost'), $this->getOption('port', 11211))); + throw new \sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $this->getOption('host', 'localhost'), $this->getOption('port', 11211))); } } } } /** - * @see sfCache + * @see \sfCache * - * @return Memcache + * @return \Memcache */ public function getBackend() { @@ -77,9 +78,9 @@ public function getBackend() } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -89,7 +90,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -102,9 +103,9 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { @@ -126,7 +127,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -140,17 +141,17 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { - if (sfCache::ALL === $mode) { + if (\sfCache::ALL === $mode) { return $this->memcache->flush(); } } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -162,7 +163,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -174,14 +175,14 @@ public function getTimeout($key) } /** - * @see sfCache + * @see \sfCache * - * @throws sfCacheException + * @throws \sfCacheException */ public function removePattern($pattern) { if (!$this->getOption('storeCacheInfo', false)) { - throw new sfCacheException('To use the "removePattern" method, you must set the "storeCacheInfo" option to "true".'); + throw new \sfCacheException('To use the "removePattern" method, you must set the "storeCacheInfo" option to "true".'); } $regexp = self::patternToRegexp($this->getOption('prefix').$pattern); @@ -193,11 +194,11 @@ public function removePattern($pattern) } /** - * @see sfCache + * @see \sfCache */ public function getMany($keys) { - $values = array(); + $values = []; $prefix = $this->getOption('prefix'); $prefixed_keys = array_map(function ($k) use ($prefix) { return $prefix.$k; }, $keys); @@ -228,7 +229,7 @@ protected function getMetadata($key) */ protected function setMetadata($key, $lifetime) { - $this->memcache->set($this->getOption('prefix').'_metadata'.self::SEPARATOR.$key, array('lastModified' => time(), 'timeout' => time() + $lifetime), false, time() + $lifetime); + $this->memcache->set($this->getOption('prefix').'_metadata'.self::SEPARATOR.$key, ['lastModified' => time(), 'timeout' => time() + $lifetime], false, time() + $lifetime); } /** @@ -241,7 +242,7 @@ protected function setCacheInfo($key, $delete = false) { $keys = $this->memcache->get($this->getOption('prefix').'_metadata'); if (!is_array($keys)) { - $keys = array(); + $keys = []; } if ($delete) { @@ -266,7 +267,7 @@ protected function getCacheInfo() { $keys = $this->memcache->get($this->getOption('prefix').'_metadata'); if (!is_array($keys)) { - return array(); + return []; } return $keys; diff --git a/lib/cache/sfNoCache.class.php b/lib/cache/sfNoCache.class.php index 10d62b188..20a8ca3ad 100644 --- a/lib/cache/sfNoCache.class.php +++ b/lib/cache/sfNoCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,12 +16,12 @@ * * @version SVN: $Id$ */ -class sfNoCache extends sfCache +class sfNoCache extends \sfCache { /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -28,7 +29,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -36,9 +37,9 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { @@ -46,7 +47,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -54,7 +55,7 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { @@ -62,7 +63,7 @@ public function removePattern($pattern) } /** - * @see sfCache + * @see \sfCache */ public function clean($mode = self::ALL) { @@ -70,7 +71,7 @@ public function clean($mode = self::ALL) } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -78,7 +79,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { diff --git a/lib/cache/sfSQLiteCache.class.php b/lib/cache/sfSQLiteCache.class.php index 5200cb60d..fa790233b 100644 --- a/lib/cache/sfSQLiteCache.class.php +++ b/lib/cache/sfSQLiteCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfSQLiteCache extends sfCache +class sfSQLiteCache extends \sfCache { protected $dbh; protected $sqlLiteVersion; @@ -30,25 +31,25 @@ class sfSQLiteCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { if (!extension_loaded('SQLite') && !extension_loaded('pdo_SQLite')) { - throw new sfConfigurationException('sfSQLiteCache class needs "sqlite" or "pdo_sqlite" extension to be loaded.'); + throw new \sfConfigurationException('sfSQLiteCache class needs "sqlite" or "pdo_sqlite" extension to be loaded.'); } parent::initialize($options); if (!$this->getOption('database')) { - throw new sfInitializationException('You must pass a "database" option to initialize a sfSQLiteCache object.'); + throw new \sfInitializationException('You must pass a "database" option to initialize a sfSQLiteCache object.'); } $this->setDatabase($this->getOption('database')); } /** - * @see sfCache + * @see \sfCache * * @inheritdo * @@ -60,9 +61,9 @@ public function getBackend() } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -76,7 +77,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -88,14 +89,14 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { if ($this->getOption('automatic_cleaning_factor') > 0 && 1 == mt_rand(1, $this->getOption('automatic_cleaning_factor'))) { - $this->clean(sfCache::OLD); + $this->clean(\sfCache::OLD); } if ($this->isSqLite3()) { @@ -106,7 +107,7 @@ public function set($key, $data, $lifetime = null) } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -118,7 +119,7 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { @@ -130,12 +131,12 @@ public function removePattern($pattern) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { if ($this->isSqLite3()) { - $res = $this->dbh->exec('DELETE FROM cache'.(sfCache::OLD == $mode ? sprintf(" WHERE timeout < '%s'", time()) : '')); + $res = $this->dbh->exec('DELETE FROM cache'.(\sfCache::OLD == $mode ? sprintf(" WHERE timeout < '%s'", time()) : '')); if ($res) { return (bool) $this->dbh->changes(); @@ -144,11 +145,11 @@ public function clean($mode = sfCache::ALL) return false; } - return (bool) $this->dbh->query('DELETE FROM cache'.(sfCache::OLD == $mode ? sprintf(" WHERE timeout < '%s'", time()) : ''))->numRows(); + return (bool) $this->dbh->query('DELETE FROM cache'.(\sfCache::OLD == $mode ? sprintf(" WHERE timeout < '%s'", time()) : ''))->numRows(); } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -164,7 +165,7 @@ public function getTimeout($key) } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -193,13 +194,13 @@ public function removePatternRegexpCallback($regexp, $key) } /** - * @see sfCache + * @see \sfCache */ public function getMany($keys) { if ($this->isSqLite3()) { - $data = array(); - if ($results = $this->dbh->query(sprintf("SELECT key, data FROM cache WHERE key IN ('%s') AND timeout > %d", implode('\', \'', array_map(array($this->dbh, 'escapeString'), $keys)), time()))) { + $data = []; + if ($results = $this->dbh->query(sprintf("SELECT key, data FROM cache WHERE key IN ('%s') AND timeout > %d", implode('\', \'', array_map([$this->dbh, 'escapeString'], $keys)), time()))) { while ($row = $results->fetchArray()) { $data[$row['key']] = $row['data']; } @@ -210,7 +211,7 @@ public function getMany($keys) $rows = $this->dbh->arrayQuery(sprintf("SELECT key, data FROM cache WHERE key IN ('%s') AND timeout > %d", implode('\', \'', array_map('sqlite_escape_string', $keys)), time())); - $data = array(); + $data = []; foreach ($rows as $row) { $data[$row['key']] = $row['data']; } @@ -223,7 +224,7 @@ public function getMany($keys) * * @param string $database The database name where to store the cache * - * @throws sfCacheException + * @throws \sfCacheException */ protected function setDatabase($database) { @@ -247,17 +248,17 @@ protected function setDatabase($database) } if ($this->isSqLite3()) { - $this->dbh = new SQLite3($this->database); + $this->dbh = new \SQLite3($this->database); if ('not an error' !== $errmsg = $this->dbh->lastErrorMsg()) { - throw new sfCacheException(sprintf('Unable to connect to SQLite database: %s.', $errmsg)); + throw new \sfCacheException(sprintf('Unable to connect to SQLite database: %s.', $errmsg)); } } else { - if (!$this->dbh = new SQLiteDatabase($this->database, 0644, $errmsg)) { - throw new sfCacheException(sprintf('Unable to connect to SQLite database: %s.', $errmsg)); + if (!$this->dbh = new \SQLiteDatabase($this->database, 0644, $errmsg)) { + throw new \sfCacheException(sprintf('Unable to connect to SQLite database: %s.', $errmsg)); } } - $this->dbh->createFunction('regexp', array($this, 'removePatternRegexpCallback'), 2); + $this->dbh->createFunction('regexp', [$this, 'removePatternRegexpCallback'], 2); if ($new) { $this->createSchema(); @@ -267,11 +268,11 @@ protected function setDatabase($database) /** * Creates the database schema. * - * @throws sfCacheException + * @throws \sfCacheException */ protected function createSchema() { - $statements = array( + $statements = [ 'CREATE TABLE [cache] ( [key] VARCHAR(255), [data] LONGVARCHAR, @@ -279,13 +280,13 @@ protected function createSchema() [last_modified] TIMESTAMP )', 'CREATE UNIQUE INDEX [cache_unique] ON [cache] ([key])', - ); + ]; foreach ($statements as $statement) { if (false === $this->dbh->query($statement)) { $message = $this->isSqLite3() ? $this->dbh->lastErrorMsg() : sqlite_error_string($this->dbh->lastError()); - throw new sfCacheException($message); + throw new \sfCacheException($message); } } } diff --git a/lib/cache/sfXCacheCache.class.php b/lib/cache/sfXCacheCache.class.php index 8c5c53e5e..c87b241be 100644 --- a/lib/cache/sfXCacheCache.class.php +++ b/lib/cache/sfXCacheCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfXCacheCache extends sfCache +class sfXCacheCache extends \sfCache { /** * Initializes this sfCache instance. @@ -24,25 +25,25 @@ class sfXCacheCache extends sfCache * * * see sfCache for options available for all drivers * - * @see sfCache + * @see \sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); if (!function_exists('xcache_set')) { - throw new sfInitializationException('You must have XCache installed and enabled to use sfXCacheCache class.'); + throw new \sfInitializationException('You must have XCache installed and enabled to use sfXCacheCache class.'); } if (!ini_get('xcache.var_size')) { - throw new sfInitializationException('You must set the "xcache.var_size" variable to a value greater than 0 to use sfXCacheCache class.'); + throw new \sfInitializationException('You must set the "xcache.var_size" variable to a value greater than 0 to use sfXCacheCache class.'); } } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $default + * @param \mixed|null $default */ public function get($key, $default = null) { @@ -56,7 +57,7 @@ public function get($key, $default = null) } /** - * @see sfCache + * @see \sfCache */ public function has($key) { @@ -64,25 +65,25 @@ public function has($key) } /** - * @see sfCache + * @see \sfCache * - * @param mixed|null $lifetime + * @param \mixed|null $lifetime */ public function set($key, $data, $lifetime = null) { $lifetime = $this->getLifetime($lifetime); - $set = array( + $set = [ 'timeout' => time() + $lifetime, 'data' => $data, 'ctime' => time(), - ); + ]; return xcache_set($this->getOption('prefix').$key, $set, $lifetime); } /** - * @see sfCache + * @see \sfCache */ public function remove($key) { @@ -90,11 +91,11 @@ public function remove($key) } /** - * @see sfCache + * @see \sfCache */ - public function clean($mode = sfCache::ALL) + public function clean($mode = \sfCache::ALL) { - if (sfCache::ALL !== $mode) { + if (\sfCache::ALL !== $mode) { return true; } @@ -110,7 +111,7 @@ public function clean($mode = sfCache::ALL) } /** - * @see sfCache + * @see \sfCache */ public function getLastModified($key) { @@ -124,7 +125,7 @@ public function getLastModified($key) } /** - * @see sfCache + * @see \sfCache */ public function getTimeout($key) { @@ -140,7 +141,7 @@ public function getTimeout($key) /** * @param string $key * - * @return mixed|null + * @return \mixed|null */ public function getBaseValue($key) { @@ -148,7 +149,7 @@ public function getBaseValue($key) } /** - * @see sfCache + * @see \sfCache */ public function removePattern($pattern) { @@ -173,7 +174,7 @@ public function removePattern($pattern) /** * @param string $key * - * @return array|null + * @return \array|null */ public function getCacheInfo($key) { @@ -197,7 +198,7 @@ public function getCacheInfo($key) protected function checkAuth() { if (ini_get('xcache.admin.enable_auth')) { - throw new sfConfigurationException('To use all features of the "sfXCacheCache" class, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'); + throw new \sfConfigurationException('To use all features of the "sfXCacheCache" class, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'); } } } diff --git a/lib/command/cli.php b/lib/command/cli.php index 8b423443c..645f603a7 100644 --- a/lib/command/cli.php +++ b/lib/command/cli.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,18 +17,18 @@ // Fall back to classic Symfony loading if (!file_exists($autoload)) { require_once __DIR__.'/../autoload/sfCoreAutoload.class.php'; - sfCoreAutoload::register(); + \sfCoreAutoload::register(); } else { require_once $autoload; } try { - $dispatcher = new sfEventDispatcher(); - $logger = new sfCommandLogger($dispatcher); + $dispatcher = new \sfEventDispatcher(); + $logger = new \sfCommandLogger($dispatcher); - $application = new sfSymfonyCommandApplication($dispatcher, null, array('symfony_lib_dir' => realpath(__DIR__.'/..'))); + $application = new \sfSymfonyCommandApplication($dispatcher, null, ['symfony_lib_dir' => realpath(__DIR__.'/..')]); $statusCode = $application->run(); -} catch (Exception $e) { +} catch (\Exception $e) { if (!isset($application)) { throw $e; } diff --git a/lib/command/sfAnsiColorFormatter.class.php b/lib/command/sfAnsiColorFormatter.class.php index bae2f2406..e7a3586bc 100644 --- a/lib/command/sfAnsiColorFormatter.class.php +++ b/lib/command/sfAnsiColorFormatter.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,17 +16,17 @@ * * @version SVN: $Id$ */ -class sfAnsiColorFormatter extends sfFormatter +class sfAnsiColorFormatter extends \sfFormatter { - protected $styles = array( - 'ERROR' => array('bg' => 'red', 'fg' => 'white', 'bold' => true), - 'INFO' => array('fg' => 'green', 'bold' => true), - 'COMMENT' => array('fg' => 'yellow'), - 'QUESTION' => array('bg' => 'cyan', 'fg' => 'black', 'bold' => false), - ); - protected $options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8); - protected $foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37); - protected $background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47); + protected $styles = [ + 'ERROR' => ['bg' => 'red', 'fg' => 'white', 'bold' => true], + 'INFO' => ['fg' => 'green', 'bold' => true], + 'COMMENT' => ['fg' => 'yellow'], + 'QUESTION' => ['bg' => 'cyan', 'fg' => 'black', 'bold' => false], + ]; + protected $options = ['bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8]; + protected $foreground = ['black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37]; + protected $background = ['black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47]; /** * Sets a new style. @@ -33,7 +34,7 @@ class sfAnsiColorFormatter extends sfFormatter * @param string $name The style name * @param array $options An array of options */ - public function setStyle($name, $options = array()) + public function setStyle($name, $options = []) { $this->styles[$name] = $options; } @@ -46,7 +47,7 @@ public function setStyle($name, $options = array()) * * @return string The styled text */ - public function format($text = '', $parameters = array()) + public function format($text = '', $parameters = []) { if (!is_array($parameters) && 'NONE' == $parameters) { return $text; @@ -56,7 +57,7 @@ public function format($text = '', $parameters = array()) $parameters = $this->styles[$parameters]; } - $codes = array(); + $codes = []; if (isset($parameters['fg'])) { $codes[] = $this->foreground[$parameters['fg']]; } diff --git a/lib/command/sfCommandApplication.class.php b/lib/command/sfCommandApplication.class.php index c232f2ae5..f0e497f1b 100644 --- a/lib/command/sfCommandApplication.class.php +++ b/lib/command/sfCommandApplication.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +18,7 @@ */ abstract class sfCommandApplication { - /** @var sfCommandManager */ + /** @var \sfCommandManager */ protected $commandManager; /** @var bool */ @@ -39,18 +40,18 @@ abstract class sfCommandApplication protected $version = 'UNKNOWN'; /** @var array */ - protected $tasks = array(); + protected $tasks = []; - /** @var sfTask */ + /** @var \sfTask */ protected $currentTask; - /** @var sfEventDispatcher */ + /** @var \sfEventDispatcher */ protected $dispatcher; /** @var array */ - protected $options = array(); + protected $options = []; - /** @var sfFormatter */ + /** @var \sfFormatter */ protected $formatter; protected $commandOptions; @@ -58,11 +59,11 @@ abstract class sfCommandApplication /** * Constructor. * - * @param sfEventDispatcher $dispatcher A sfEventDispatcher instance - * @param sfFormatter $formatter A sfFormatter instance - * @param array $options An array of options + * @param \sfEventDispatcher $dispatcher A sfEventDispatcher instance + * @param \sfFormatter $formatter A sfFormatter instance + * @param array $options An array of options */ - public function __construct(sfEventDispatcher $dispatcher, sfFormatter $formatter = null, $options = array()) + public function __construct(\sfEventDispatcher $dispatcher, \sfFormatter $formatter = null, $options = []) { $this->dispatcher = $dispatcher; $this->formatter = null === $formatter ? $this->guessBestFormatter(STDOUT) : $formatter; @@ -70,18 +71,18 @@ public function __construct(sfEventDispatcher $dispatcher, sfFormatter $formatte $this->fixCgi(); - $argumentSet = new sfCommandArgumentSet(array( - new sfCommandArgument('task', sfCommandArgument::REQUIRED, 'The task to execute'), - )); - $optionSet = new sfCommandOptionSet(array( - new sfCommandOption('--help', '-H', sfCommandOption::PARAMETER_NONE, 'Display this help message.'), - new sfCommandOption('--quiet', '-q', sfCommandOption::PARAMETER_NONE, 'Do not log messages to standard output.'), - new sfCommandOption('--trace', '-t', sfCommandOption::PARAMETER_NONE, 'Turn on invoke/execute tracing, enable full backtrace.'), - new sfCommandOption('--version', '-V', sfCommandOption::PARAMETER_NONE, 'Display the program version.'), - new sfCommandOption('--color', '', sfCommandOption::PARAMETER_NONE, 'Forces ANSI color output.'), - new sfCommandOption('--no-debug', '', sfCommandOption::PARAMETER_NONE, 'Disable debug'), - )); - $this->commandManager = new sfCommandManager($argumentSet, $optionSet); + $argumentSet = new \sfCommandArgumentSet([ + new \sfCommandArgument('task', \sfCommandArgument::REQUIRED, 'The task to execute'), + ]); + $optionSet = new \sfCommandOptionSet([ + new \sfCommandOption('--help', '-H', \sfCommandOption::PARAMETER_NONE, 'Display this help message.'), + new \sfCommandOption('--quiet', '-q', \sfCommandOption::PARAMETER_NONE, 'Do not log messages to standard output.'), + new \sfCommandOption('--trace', '-t', \sfCommandOption::PARAMETER_NONE, 'Turn on invoke/execute tracing, enable full backtrace.'), + new \sfCommandOption('--version', '-V', \sfCommandOption::PARAMETER_NONE, 'Display the program version.'), + new \sfCommandOption('--color', '', \sfCommandOption::PARAMETER_NONE, 'Forces ANSI color output.'), + new \sfCommandOption('--no-debug', '', \sfCommandOption::PARAMETER_NONE, 'Disable debug'), + ]); + $this->commandManager = new \sfCommandManager($argumentSet, $optionSet); $this->configure(); @@ -108,7 +109,7 @@ public function getOption($name) /** * Returns the formatter instance. * - * @return sfFormatter The formatter instance + * @return \sfFormatter The formatter instance */ public function getFormatter() { @@ -118,9 +119,9 @@ public function getFormatter() /** * Sets the formatter instance. * - * @param sfFormatter $formatter The formatter instance + * @param \sfFormatter $formatter The formatter instance */ - public function setFormatter(sfFormatter $formatter) + public function setFormatter(\sfFormatter $formatter) { $this->formatter = $formatter; @@ -131,7 +132,7 @@ public function setFormatter(sfFormatter $formatter) public function clearTasks() { - $this->tasks = array(); + $this->tasks = []; } /** @@ -155,21 +156,21 @@ public function registerTasks($tasks = null) /** * Registers a task object. * - * @param sfTask $task An sfTask object + * @param \sfTask $task An sfTask object * - * @throws sfCommandException + * @throws \sfCommandException */ - public function registerTask(sfTask $task) + public function registerTask(\sfTask $task) { if (isset($this->tasks[$task->getFullName()])) { - throw new sfCommandException(sprintf('The task named "%s" in "%s" task is already registered by the "%s" task.', $task->getFullName(), get_class($task), get_class($this->tasks[$task->getFullName()]))); + throw new \sfCommandException(sprintf('The task named "%s" in "%s" task is already registered by the "%s" task.', $task->getFullName(), get_class($task), get_class($this->tasks[$task->getFullName()]))); } $this->tasks[$task->getFullName()] = $task; foreach ($task->getAliases() as $alias) { if (isset($this->tasks[$alias])) { - throw new sfCommandException(sprintf('A task named "%s" is already registered.', $alias)); + throw new \sfCommandException(sprintf('A task named "%s" is already registered.', $alias)); } $this->tasks[$alias] = $task; @@ -183,9 +184,9 @@ public function registerTask(sfTask $task) */ public function autodiscoverTasks() { - $tasks = array(); + $tasks = []; foreach (get_declared_classes() as $class) { - $r = new ReflectionClass($class); + $r = new \ReflectionClass($class); if ($r->isSubclassOf('sfTask') && !$r->isAbstract()) { $tasks[] = new $class($this->dispatcher, $this->formatter); @@ -210,14 +211,14 @@ public function getTasks() * * @param string $name The task name or alias * - * @return sfTask An sfTask object + * @return \sfTask An sfTask object * - * @throws sfCommandException + * @throws \sfCommandException */ public function getTask($name) { if (!isset($this->tasks[$name])) { - throw new sfCommandException(sprintf('The task "%s" does not exist.', $name)); + throw new \sfCommandException(sprintf('The task "%s" does not exist.', $name)); } return $this->tasks[$name]; @@ -329,11 +330,11 @@ public function isDebug() */ public function help() { - $messages = array( + $messages = [ $this->formatter->format('Usage:', 'COMMENT'), sprintf(" %s [options] task_name [arguments]\n", $this->getName()), $this->formatter->format('Options:', 'COMMENT'), - ); + ]; foreach ($this->commandManager->getOptionSet()->getOptions() as $option) { $messages[] = sprintf( @@ -344,25 +345,25 @@ public function help() ); } - $this->dispatcher->notify(new sfEvent($this, 'command.log', $messages)); + $this->dispatcher->notify(new \sfEvent($this, 'command.log', $messages)); } /** * Renders an exception. * - * @param Exception $e An exception object + * @param \Exception $e An exception object */ public function renderException($e) { $title = sprintf(' [%s] ', get_class($e)); $len = $this->strlen($title); - $lines = array(); + $lines = []; foreach (explode("\n", $e->getMessage()) as $line) { $lines[] = sprintf(' %s ', $line); $len = max($this->strlen($line) + 4, $len); } - $messages = array(str_repeat(' ', $len)); + $messages = [str_repeat(' ', $len)]; if ($this->trace) { $messages[] = $title.str_repeat(' ', $len - $this->strlen($title)); @@ -380,7 +381,7 @@ public function renderException($e) } fwrite(STDERR, "\n"); - if (null !== $this->currentTask && $e instanceof sfCommandArgumentsException) { + if (null !== $this->currentTask && $e instanceof \sfCommandArgumentsException) { fwrite(STDERR, $this->formatter->format(sprintf($this->currentTask->getSynopsis(), $this->getName()), 'INFO', STDERR)."\n"); fwrite(STDERR, "\n"); } @@ -390,12 +391,12 @@ public function renderException($e) // exception related properties $trace = $e->getTrace(); - array_unshift($trace, array( + array_unshift($trace, [ 'function' => '', 'file' => null != $e->getFile() ? $e->getFile() : 'n/a', 'line' => null != $e->getLine() ? $e->getLine() : 'n/a', - 'args' => array(), - )); + 'args' => [], + ]); for ($i = 0, $count = count($trace); $i < $count; ++$i) { $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; @@ -410,7 +411,7 @@ public function renderException($e) fwrite(STDERR, "\n"); } - $this->dispatcher->notify(new sfEvent($e, 'application.throw_exception')); + $this->dispatcher->notify(new \sfEvent($e, 'application.throw_exception')); } /** @@ -418,9 +419,9 @@ public function renderException($e) * * @param string $name The task name or a task shortcut * - * @return sfTask A sfTask object + * @return \sfTask A sfTask object * - * @throws sfCommandException + * @throws \sfCommandException */ public function getTaskToExecute($name) { @@ -429,7 +430,7 @@ public function getTaskToExecute($name) $namespace = substr($name, 0, $pos); $name = substr($name, $pos + 1); - $namespaces = array(); + $namespaces = []; foreach ($this->tasks as $task) { if ($task->getNamespace() && !in_array($task->getNamespace(), $namespaces)) { $namespaces[] = $task->getNamespace(); @@ -438,10 +439,10 @@ public function getTaskToExecute($name) $abbrev = $this->getAbbreviations($namespaces); if (!isset($abbrev[$namespace])) { - throw new sfCommandException(sprintf('There are no tasks defined in the "%s" namespace.', $namespace)); + throw new \sfCommandException(sprintf('There are no tasks defined in the "%s" namespace.', $namespace)); } if (count($abbrev[$namespace]) > 1) { - throw new sfCommandException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, implode(', ', $abbrev[$namespace]))); + throw new \sfCommandException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, implode(', ', $abbrev[$namespace]))); } $namespace = $abbrev[$namespace][0]; @@ -450,7 +451,7 @@ public function getTaskToExecute($name) } // name - $tasks = array(); + $tasks = []; foreach ($this->tasks as $taskName => $task) { if ($taskName == $task->getFullName() && $task->getNamespace() == $namespace) { $tasks[] = $task->getName(); @@ -463,7 +464,7 @@ public function getTaskToExecute($name) } // aliases - $aliases = array(); + $aliases = []; foreach ($this->tasks as $taskName => $task) { if ($taskName == $task->getFullName()) { foreach ($task->getAliases() as $alias) { @@ -475,10 +476,10 @@ public function getTaskToExecute($name) $abbrev = $this->getAbbreviations($aliases); $fullName = $namespace ? $namespace.':'.$name : $name; if (!isset($abbrev[$fullName])) { - throw new sfCommandException(sprintf('Task "%s" is not defined.', $fullName)); + throw new \sfCommandException(sprintf('Task "%s" is not defined.', $fullName)); } if (count($abbrev[$fullName]) > 1) { - throw new sfCommandException(sprintf('Task "%s" is ambiguous (%s).', $fullName, implode(', ', $abbrev[$fullName]))); + throw new \sfCommandException(sprintf('Task "%s" is ambiguous (%s).', $fullName, implode(', ', $abbrev[$fullName]))); } return $this->getTask($abbrev[$fullName][0]); @@ -497,7 +498,7 @@ protected function handleOptions($options = null) // the order of option processing matters if ($this->commandManager->getOptionSet()->hasOption('color') && false !== $this->commandManager->getOptionValue('color')) { - $this->setFormatter(new sfAnsiColorFormatter()); + $this->setFormatter(new \sfAnsiColorFormatter()); } if ($this->commandManager->getOptionSet()->hasOption('quiet') && false !== $this->commandManager->getOptionValue('quiet')) { @@ -559,7 +560,7 @@ protected function fixCgi() ini_set('html_errors', false); ini_set('magic_quotes_runtime', false); - if (false === strpos(PHP_SAPI, 'cgi')) { + if (!str_contains(PHP_SAPI, 'cgi')) { return; } @@ -594,8 +595,8 @@ protected function fixCgi() */ protected function getAbbreviations($names) { - $abbrevs = array(); - $table = array(); + $abbrevs = []; + $table = []; foreach ($names as $name) { for ($len = strlen($name) - 1; $len > 0; --$len) { @@ -609,7 +610,7 @@ protected function getAbbreviations($names) $seen = $table[$abbrev]; if (1 == $seen) { // We're the first word so far to have this abbreviation. - $abbrevs[$abbrev] = array($name); + $abbrevs[$abbrev] = [$name]; } elseif (2 == $seen) { // We're the second word to have this abbreviation, so we can't use it. // unset($abbrevs[$abbrev]); @@ -623,7 +624,7 @@ protected function getAbbreviations($names) // Non-abbreviations always get entered, even if they aren't unique foreach ($names as $name) { - $abbrevs[$name] = array($name); + $abbrevs[$name] = [$name]; } return $abbrevs; @@ -655,10 +656,10 @@ protected function isStreamSupportsColors($stream) * * @param mixed $stream A stream * - * @return sfFormatter A formatter instance + * @return \sfFormatter A formatter instance */ protected function guessBestFormatter($stream) { - return $this->isStreamSupportsColors($stream) ? new sfAnsiColorFormatter() : new sfFormatter(); + return $this->isStreamSupportsColors($stream) ? new \sfAnsiColorFormatter() : new \sfFormatter(); } } diff --git a/lib/command/sfCommandArgument.class.php b/lib/command/sfCommandArgument.class.php index 380590e80..2e5775233 100644 --- a/lib/command/sfCommandArgument.class.php +++ b/lib/command/sfCommandArgument.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -35,14 +36,14 @@ class sfCommandArgument * @param string $help A help text * @param mixed $default The default value (for self::OPTIONAL mode only) * - * @throws sfCommandException + * @throws \sfCommandException */ public function __construct($name, $mode = null, $help = '', $default = null) { if (null === $mode) { $mode = self::OPTIONAL; } elseif (is_string($mode) || $mode > 7) { - throw new sfCommandException(sprintf('Argument mode "%s" is not valid.', $mode)); + throw new \sfCommandException(sprintf('Argument mode "%s" is not valid.', $mode)); } $this->name = $name; @@ -87,19 +88,19 @@ public function isArray() * * @param mixed $default The default value * - * @throws sfCommandException + * @throws \sfCommandException */ public function setDefault($default = null) { if (self::REQUIRED === $this->mode && null !== $default) { - throw new sfCommandException('Cannot set a default value except for sfCommandParameter::OPTIONAL mode.'); + throw new \sfCommandException('Cannot set a default value except for sfCommandParameter::OPTIONAL mode.'); } if ($this->isArray()) { if (null === $default) { - $default = array(); + $default = []; } elseif (!is_array($default)) { - throw new sfCommandException('A default value for an array argument must be an array.'); + throw new \sfCommandException('A default value for an array argument must be an array.'); } } diff --git a/lib/command/sfCommandArgumentSet.class.php b/lib/command/sfCommandArgumentSet.class.php index b641a8603..8325e0269 100644 --- a/lib/command/sfCommandArgumentSet.class.php +++ b/lib/command/sfCommandArgumentSet.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +18,7 @@ */ class sfCommandArgumentSet { - protected $arguments = array(); + protected $arguments = []; protected $requiredCount = 0; protected $hasAnArrayArgument = false; protected $hasOptional = false; @@ -27,7 +28,7 @@ class sfCommandArgumentSet * * @param array $arguments An array of sfCommandArgument objects */ - public function __construct($arguments = array()) + public function __construct($arguments = []) { $this->setArguments($arguments); } @@ -37,9 +38,9 @@ public function __construct($arguments = array()) * * @param array $arguments An array of sfCommandArgument objects */ - public function setArguments($arguments = array()) + public function setArguments($arguments = []) { - $this->arguments = array(); + $this->arguments = []; $this->requiredCount = 0; $this->hasOptional = false; $this->addArguments($arguments); @@ -50,7 +51,7 @@ public function setArguments($arguments = array()) * * @param array $arguments An array of sfCommandArgument objects */ - public function addArguments($arguments = array()) + public function addArguments($arguments = []) { if (null !== $arguments) { foreach ($arguments as $argument) { @@ -62,22 +63,22 @@ public function addArguments($arguments = array()) /** * Add a sfCommandArgument objects. * - * @param sfCommandArgument $argument A sfCommandArgument object + * @param \sfCommandArgument $argument A sfCommandArgument object * - * @throws sfCommandException + * @throws \sfCommandException */ - public function addArgument(sfCommandArgument $argument) + public function addArgument(\sfCommandArgument $argument) { if (isset($this->arguments[$argument->getName()])) { - throw new sfCommandException(sprintf('An argument with name "%s" already exist.', $argument->getName())); + throw new \sfCommandException(sprintf('An argument with name "%s" already exist.', $argument->getName())); } if ($this->hasAnArrayArgument) { - throw new sfCommandException('Cannot add an argument after an array argument.'); + throw new \sfCommandException('Cannot add an argument after an array argument.'); } if ($argument->isRequired() && $this->hasOptional) { - throw new sfCommandException('Cannot add a required argument after an optional one.'); + throw new \sfCommandException('Cannot add a required argument after an optional one.'); } if ($argument->isArray()) { @@ -98,14 +99,14 @@ public function addArgument(sfCommandArgument $argument) * * @param string $name The argument name * - * @return sfCommandArgument A sfCommandArgument object + * @return \sfCommandArgument A sfCommandArgument object * - * @throws sfCommandException + * @throws \sfCommandException */ public function getArgument($name) { if (!$this->hasArgument($name)) { - throw new sfCommandException(sprintf('The "%s" argument does not exist.', $name)); + throw new \sfCommandException(sprintf('The "%s" argument does not exist.', $name)); } return $this->arguments[$name]; @@ -160,7 +161,7 @@ public function getArgumentRequiredCount() */ public function getDefaults() { - $values = array(); + $values = []; foreach ($this->arguments as $argument) { $values[$argument->getName()] = $argument->getDefault(); } diff --git a/lib/command/sfCommandArgumentsException.class.php b/lib/command/sfCommandArgumentsException.class.php index 0dff151aa..478d2b104 100644 --- a/lib/command/sfCommandArgumentsException.class.php +++ b/lib/command/sfCommandArgumentsException.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,6 +16,6 @@ * * @version SVN: $Id$ */ -class sfCommandArgumentsException extends sfCommandException +class sfCommandArgumentsException extends \sfCommandException { } diff --git a/lib/command/sfCommandException.class.php b/lib/command/sfCommandException.class.php index 5b7627482..1c61d72b3 100644 --- a/lib/command/sfCommandException.class.php +++ b/lib/command/sfCommandException.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,6 +16,6 @@ * * @version SVN: $Id$ */ -class sfCommandException extends sfException +class sfCommandException extends \sfException { } diff --git a/lib/command/sfCommandLogger.class.php b/lib/command/sfCommandLogger.class.php index b81347180..d52afe40d 100644 --- a/lib/command/sfCommandLogger.class.php +++ b/lib/command/sfCommandLogger.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,17 +14,17 @@ * * @version SVN: $Id$ */ -class sfCommandLogger extends sfConsoleLogger +class sfCommandLogger extends \sfConsoleLogger { /** * Initializes this logger. * - * @param sfEventDispatcher $dispatcher A sfEventDispatcher instance - * @param array $options an array of options + * @param \sfEventDispatcher $dispatcher A sfEventDispatcher instance + * @param array $options an array of options */ - public function initialize(sfEventDispatcher $dispatcher, $options = array()) + public function initialize(\sfEventDispatcher $dispatcher, $options = []) { - $dispatcher->connect('command.log', array($this, 'listenToLogEvent')); + $dispatcher->connect('command.log', [$this, 'listenToLogEvent']); return parent::initialize($dispatcher, $options); } @@ -31,9 +32,9 @@ public function initialize(sfEventDispatcher $dispatcher, $options = array()) /** * Listens to command.log events. * - * @param sfEvent $event An sfEvent instance + * @param \sfEvent $event An sfEvent instance */ - public function listenToLogEvent(sfEvent $event) + public function listenToLogEvent(\sfEvent $event) { $priority = isset($event['priority']) ? $event['priority'] : self::INFO; diff --git a/lib/command/sfCommandManager.class.php b/lib/command/sfCommandManager.class.php index 7d148ada3..95eb4a54c 100644 --- a/lib/command/sfCommandManager.class.php +++ b/lib/command/sfCommandManager.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -21,38 +22,38 @@ class sfCommandManager protected $arguments = ''; /** @var string[] */ - protected $errors = array(); + protected $errors = []; - /** @var sfCommandOptionSet */ + /** @var \sfCommandOptionSet */ protected $optionSet; - /** @var sfCommandArgumentSet */ - protected $argumentSet = array(); + /** @var \sfCommandArgumentSet */ + protected $argumentSet = []; /** @var array */ - protected $optionValues = array(); + protected $optionValues = []; /** @var array */ - protected $argumentValues = array(); + protected $argumentValues = []; /** @var array */ - protected $parsedArgumentValues = array(); + protected $parsedArgumentValues = []; /** * Constructor. * - * @param sfCommandArgumentSet $argumentSet A sfCommandArgumentSet object - * @param sfCommandOptionSet $optionSet A setOptionSet object + * @param \sfCommandArgumentSet $argumentSet A sfCommandArgumentSet object + * @param \sfCommandOptionSet $optionSet A setOptionSet object */ - public function __construct(sfCommandArgumentSet $argumentSet = null, sfCommandOptionSet $optionSet = null) + public function __construct(\sfCommandArgumentSet $argumentSet = null, \sfCommandOptionSet $optionSet = null) { if (null === $argumentSet) { - $argumentSet = new sfCommandArgumentSet(); + $argumentSet = new \sfCommandArgumentSet(); } $this->setArgumentSet($argumentSet); if (null === $optionSet) { - $optionSet = new sfCommandOptionSet(); + $optionSet = new \sfCommandOptionSet(); } $this->setOptionSet($optionSet); } @@ -60,9 +61,9 @@ public function __construct(sfCommandArgumentSet $argumentSet = null, sfCommandO /** * Sets the argument set. * - * @param sfCommandArgumentSet $argumentSet A sfCommandArgumentSet object + * @param \sfCommandArgumentSet $argumentSet A sfCommandArgumentSet object */ - public function setArgumentSet(sfCommandArgumentSet $argumentSet) + public function setArgumentSet(\sfCommandArgumentSet $argumentSet) { $this->argumentSet = $argumentSet; } @@ -70,7 +71,7 @@ public function setArgumentSet(sfCommandArgumentSet $argumentSet) /** * Gets the argument set. * - * @return sfCommandArgumentSet A sfCommandArgumentSet object + * @return \sfCommandArgumentSet A sfCommandArgumentSet object */ public function getArgumentSet() { @@ -80,9 +81,9 @@ public function getArgumentSet() /** * Sets the option set. * - * @param sfCommandOptionSet $optionSet A sfCommandOptionSet object + * @param \sfCommandOptionSet $optionSet A sfCommandOptionSet object */ - public function setOptionSet(sfCommandOptionSet $optionSet) + public function setOptionSet(\sfCommandOptionSet $optionSet) { $this->optionSet = $optionSet; } @@ -90,7 +91,7 @@ public function setOptionSet(sfCommandOptionSet $optionSet) /** * Gets the option set. * - * @return sfCommandOptionSet A sfCommandOptionSet object + * @return \sfCommandOptionSet A sfCommandOptionSet object */ public function getOptionSet() { @@ -123,10 +124,10 @@ public function process($arguments = null) $this->arguments = $arguments; $this->optionValues = $this->optionSet->getDefaults(); $this->argumentValues = $this->argumentSet->getDefaults(); - $this->parsedArgumentValues = array(); - $this->errors = array(); + $this->parsedArgumentValues = []; + $this->errors = []; - while (!in_array($argument = array_shift($this->arguments), array('', null))) { + while (!in_array($argument = array_shift($this->arguments), ['', null])) { if ('--' == $argument) { // stop options parsing $this->parsedArgumentValues = array_merge($this->parsedArgumentValues, $this->arguments); @@ -203,12 +204,12 @@ public function getArgumentValues() * * @return mixed The argument value * - * @throws sfCommandException + * @throws \sfCommandException */ public function getArgumentValue($name) { if (!$this->argumentSet->hasArgument($name)) { - throw new sfCommandException(sprintf('The "%s" argument does not exist.', $name)); + throw new \sfCommandException(sprintf('The "%s" argument does not exist.', $name)); } return $this->argumentValues[$name]; @@ -231,18 +232,18 @@ public function getOptionValues() * * @return mixed The option value * - * @throws sfCommandException + * @throws \sfCommandException */ public function getOptionValue($name) { if (!$this->optionSet->hasOption($name)) { - throw new sfCommandException(sprintf('The "%s" option does not exist.', $name)); + throw new \sfCommandException(sprintf('The "%s" option does not exist.', $name)); } return $this->optionValues[$name]; } - public function setOption(sfCommandOption $option, $value) + public function setOption(\sfCommandOption $option, $value) { if ($option->isArray()) { $this->optionValues[$option->getName()][] = $value; @@ -318,7 +319,7 @@ protected function parseShortOption($argument) */ protected function parseLongOption($argument) { - if (false !== strpos($argument, '=')) { + if (str_contains($argument, '=')) { list($name, $value) = explode('=', $argument, 2); if (!$this->optionSet->hasOption($name)) { diff --git a/lib/command/sfCommandOption.class.php b/lib/command/sfCommandOption.class.php index 43e1f91d3..d2994bb4d 100644 --- a/lib/command/sfCommandOption.class.php +++ b/lib/command/sfCommandOption.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -38,7 +39,7 @@ class sfCommandOption * @param string $help A help text * @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE) * - * @throws sfCommandException + * @throws \sfCommandException */ public function __construct($name, $shortcut = null, $mode = null, $help = '', $default = null) { @@ -59,7 +60,7 @@ public function __construct($name, $shortcut = null, $mode = null, $help = '', $ if (null === $mode) { $mode = self::PARAMETER_NONE; } elseif (is_string($mode) || $mode > 15) { - throw new sfCommandException(sprintf('Option mode "%s" is not valid.', $mode)); + throw new \sfCommandException(sprintf('Option mode "%s" is not valid.', $mode)); } $this->name = $name; @@ -135,19 +136,19 @@ public function isArray() * * @param mixed $default The default value * - * @throws sfCommandException + * @throws \sfCommandException */ public function setDefault($default = null) { if (self::PARAMETER_NONE === (self::PARAMETER_NONE & $this->mode) && null !== $default) { - throw new sfCommandException('Cannot set a default value when using sfCommandOption::PARAMETER_NONE mode.'); + throw new \sfCommandException('Cannot set a default value when using sfCommandOption::PARAMETER_NONE mode.'); } if ($this->isArray()) { if (null === $default) { - $default = array(); + $default = []; } elseif (!is_array($default)) { - throw new sfCommandException('A default value for an array option must be an array.'); + throw new \sfCommandException('A default value for an array option must be an array.'); } } diff --git a/lib/command/sfCommandOptionSet.class.php b/lib/command/sfCommandOptionSet.class.php index 49792f5db..88bef7f1f 100644 --- a/lib/command/sfCommandOptionSet.class.php +++ b/lib/command/sfCommandOptionSet.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,15 +18,15 @@ */ class sfCommandOptionSet { - protected $options = array(); - protected $shortcuts = array(); + protected $options = []; + protected $shortcuts = []; /** * Constructor. * * @param array $options An array of sfCommandOption objects */ - public function __construct($options = array()) + public function __construct($options = []) { $this->setOptions($options); } @@ -35,10 +36,10 @@ public function __construct($options = array()) * * @param array $options An array of sfCommandOption objects */ - public function setOptions($options = array()) + public function setOptions($options = []) { - $this->options = array(); - $this->shortcuts = array(); + $this->options = []; + $this->shortcuts = []; $this->addOptions($options); } @@ -47,7 +48,7 @@ public function setOptions($options = array()) * * @param array $options An array of sfCommandOption objects */ - public function addOptions($options = array()) + public function addOptions($options = []) { foreach ($options as $option) { $this->addOption($option); @@ -57,17 +58,17 @@ public function addOptions($options = array()) /** * Add a sfCommandOption objects. * - * @param sfCommandOption $option A sfCommandOption object + * @param \sfCommandOption $option A sfCommandOption object * - * @throws sfCommandException + * @throws \sfCommandException */ - public function addOption(sfCommandOption $option) + public function addOption(\sfCommandOption $option) { if (isset($this->options[$option->getName()])) { - throw new sfCommandException(sprintf('An option named "%s" already exist.', $option->getName())); + throw new \sfCommandException(sprintf('An option named "%s" already exist.', $option->getName())); } if (isset($this->shortcuts[$option->getShortcut()])) { - throw new sfCommandException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut())); + throw new \sfCommandException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut())); } $this->options[$option->getName()] = $option; @@ -81,14 +82,14 @@ public function addOption(sfCommandOption $option) * * @param string $name The option name * - * @return sfCommandOption A sfCommandOption object + * @return \sfCommandOption A sfCommandOption object * - * @throws sfCommandException + * @throws \sfCommandException */ public function getOption($name) { if (!$this->hasOption($name)) { - throw new sfCommandException(sprintf('The "--%s" option does not exist.', $name)); + throw new \sfCommandException(sprintf('The "--%s" option does not exist.', $name)); } return $this->options[$name]; @@ -133,7 +134,7 @@ public function hasShortcut($name) * * @param string $shortcut * - * @return sfCommandOption A sfCommandOption object + * @return \sfCommandOption A sfCommandOption object */ public function getOptionForShortcut($shortcut) { @@ -147,7 +148,7 @@ public function getOptionForShortcut($shortcut) */ public function getDefaults() { - $values = array(); + $values = []; foreach ($this->options as $option) { $values[$option->getName()] = $option->getDefault(); } @@ -162,12 +163,12 @@ public function getDefaults() * * @return string The option name * - * @throws sfCommandException + * @throws \sfCommandException */ protected function shortcutToName($shortcut) { if (!isset($this->shortcuts[$shortcut])) { - throw new sfCommandException(sprintf('The "-%s" option does not exist.', $shortcut)); + throw new \sfCommandException(sprintf('The "-%s" option does not exist.', $shortcut)); } return $this->shortcuts[$shortcut]; diff --git a/lib/command/sfFormatter.class.php b/lib/command/sfFormatter.class.php index c5b776ff0..1b2456705 100644 --- a/lib/command/sfFormatter.class.php +++ b/lib/command/sfFormatter.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -39,7 +40,7 @@ public function __construct($maxLineSize = null) * @param string $name The style name * @param array $options An array of options */ - public function setStyle($name, $options = array()) + public function setStyle($name, $options = []) { } @@ -51,7 +52,7 @@ public function setStyle($name, $options = array()) * * @return string The formatted text */ - public function format($text = '', $parameters = array()) + public function format($text = '', $parameters = []) { return $text; } diff --git a/lib/command/sfSymfonyCommandApplication.class.php b/lib/command/sfSymfonyCommandApplication.class.php index 11caf20f8..282f23e32 100644 --- a/lib/command/sfSymfonyCommandApplication.class.php +++ b/lib/command/sfSymfonyCommandApplication.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,9 +16,9 @@ * * @version SVN: $Id$ */ -class sfSymfonyCommandApplication extends sfCommandApplication +class sfSymfonyCommandApplication extends \sfCommandApplication { - protected $taskFiles = array(); + protected $taskFiles = []; /** * Configures the current symfony command application. @@ -25,15 +26,15 @@ class sfSymfonyCommandApplication extends sfCommandApplication public function configure() { if (!isset($this->options['symfony_lib_dir'])) { - throw new sfInitializationException('You must pass a "symfony_lib_dir" option.'); + throw new \sfInitializationException('You must pass a "symfony_lib_dir" option.'); } $configurationFile = getcwd().'/config/ProjectConfiguration.class.php'; if (is_readable($configurationFile)) { require_once $configurationFile; - $configuration = new ProjectConfiguration(getcwd(), $this->dispatcher); + $configuration = new \ProjectConfiguration(getcwd(), $this->dispatcher); } else { - $configuration = new sfProjectConfiguration(getcwd(), $this->dispatcher); + $configuration = new \sfProjectConfiguration(getcwd(), $this->dispatcher); } // application @@ -62,7 +63,7 @@ public function run($options = null) $this->currentTask = $this->getTaskToExecute($arguments['task']); - if ($this->currentTask instanceof sfCommandApplicationTask) { + if ($this->currentTask instanceof \sfCommandApplicationTask) { $this->currentTask->setCommandApplication($this); } @@ -78,12 +79,12 @@ public function run($options = null) * * Looks for tasks in the symfony core, the current project and all project plugins. * - * @param sfProjectConfiguration $configuration The project configuration + * @param \sfProjectConfiguration $configuration The project configuration */ - public function loadTasks(sfProjectConfiguration $configuration) + public function loadTasks(\sfProjectConfiguration $configuration) { // Symfony core tasks - $dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); + $dirs = [\sfConfig::get('sf_symfony_lib_dir').'/task']; // Plugin tasks foreach ($configuration->getPluginPaths() as $path) { @@ -93,15 +94,15 @@ public function loadTasks(sfProjectConfiguration $configuration) } // project tasks - $dirs[] = sfConfig::get('sf_lib_dir').'/task'; + $dirs[] = \sfConfig::get('sf_lib_dir').'/task'; - $finder = sfFinder::type('file')->name('*Task.class.php'); + $finder = \sfFinder::type('file')->name('*Task.class.php'); foreach ($finder->in($dirs) as $file) { $this->taskFiles[basename($file, '.class.php')] = $file; } // register local autoloader for tasks - spl_autoload_register(array($this, 'autoloadTask')); + spl_autoload_register([$this, 'autoloadTask']); // require tasks foreach ($this->taskFiles as $task => $file) { @@ -110,7 +111,7 @@ class_exists($task, true); } // unregister local autoloader - spl_autoload_unregister(array($this, 'autoloadTask')); + spl_autoload_unregister([$this, 'autoloadTask']); } /** @@ -132,10 +133,10 @@ public function autoloadTask($class) } /** - * @see sfCommandApplication + * @see \sfCommandApplication */ public function getLongVersion() { - return sprintf('%s version %s (%s)', $this->getName(), $this->formatter->format($this->getVersion(), 'INFO'), sfConfig::get('sf_symfony_lib_dir'))."\n"; + return sprintf('%s version %s (%s)', $this->getName(), $this->formatter->format($this->getVersion(), 'INFO'), \sfConfig::get('sf_symfony_lib_dir'))."\n"; } } diff --git a/lib/config/sfApplicationConfiguration.class.php b/lib/config/sfApplicationConfiguration.class.php index d38b03b74..9f621142d 100644 --- a/lib/config/sfApplicationConfiguration.class.php +++ b/lib/config/sfApplicationConfiguration.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,27 +16,27 @@ * * @version SVN: $Id$ */ -abstract class sfApplicationConfiguration extends ProjectConfiguration +abstract class sfApplicationConfiguration extends \ProjectConfiguration { protected static $coreLoaded = false; - protected static $loadedHelpers = array(); + protected static $loadedHelpers = []; protected $configCache; protected $application; protected $environment; protected $debug = false; - protected $config = array(); + protected $config = []; protected $cache; /** * Constructor. * - * @param string $environment The environment name - * @param bool $debug true to enable debug mode - * @param string $rootDir The project root directory - * @param sfEventDispatcher $dispatcher An event dispatcher + * @param string $environment The environment name + * @param bool $debug true to enable debug mode + * @param string $rootDir The project root directory + * @param \sfEventDispatcher $dispatcher An event dispatcher */ - public function __construct($environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null) + public function __construct($environment, $debug, $rootDir = null, \sfEventDispatcher $dispatcher = null) { $this->environment = $environment; $this->debug = (bool) $debug; @@ -47,18 +48,18 @@ public function __construct($environment, $debug, $rootDir = null, sfEventDispat $this->initConfiguration(); - if (sfConfig::get('sf_check_lock')) { + if (\sfConfig::get('sf_check_lock')) { $this->checkLock(); } - if (is_file($file = sfConfig::get('sf_app_cache_dir').'/config/configuration.php')) { + if (is_file($file = \sfConfig::get('sf_app_cache_dir').'/config/configuration.php')) { $this->cache = require $file; } $this->initialize(); // store current sfConfig values - $this->config = sfConfig::getAll(); + $this->config = \sfConfig::getAll(); } /** @@ -81,8 +82,8 @@ public function initialize() public function activate() { - sfConfig::clear(); - sfConfig::add($this->config); + \sfConfig::clear(); + \sfConfig::add($this->config); } /** @@ -93,20 +94,20 @@ public function initConfiguration() $configCache = $this->getConfigCache(); // in debug mode, start global timer - if ($this->isDebug() && !sfConfig::get('sf_cli') && !sfWebDebugPanelTimer::isStarted()) { - sfWebDebugPanelTimer::startTime(); + if ($this->isDebug() && !\sfConfig::get('sf_cli') && !\sfWebDebugPanelTimer::isStarted()) { + \sfWebDebugPanelTimer::startTime(); } // required core classes for the framework - if (!$this->isDebug() && !sfConfig::get('sf_test') && !sfConfig::get('sf_cli') && !self::$coreLoaded) { + if (!$this->isDebug() && !\sfConfig::get('sf_test') && !\sfConfig::get('sf_cli') && !self::$coreLoaded) { $configCache->import('config/core_compile.yml', false); } // autoloader(s) - $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); - sfAutoload::getInstance()->register(); + $this->dispatcher->connect('autoload.filter_config', [$this, 'filterAutoloadConfig']); + \sfAutoload::getInstance()->register(); if ($this->isDebug()) { - sfAutoloadAgain::getInstance()->register(); + \sfAutoloadAgain::getInstance()->register(); } // load base settings @@ -115,29 +116,29 @@ public function initConfiguration() include $file; } - if (!sfConfig::get('sf_cli') && false !== sfConfig::get('sf_csrf_secret')) { - sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret')); + if (!\sfConfig::get('sf_cli') && false !== \sfConfig::get('sf_csrf_secret')) { + \sfForm::enableCSRFProtection(\sfConfig::get('sf_csrf_secret')); } - sfWidget::setCharset(sfConfig::get('sf_charset')); - sfValidatorBase::setCharset(sfConfig::get('sf_charset')); + \sfWidget::setCharset(\sfConfig::get('sf_charset')); + \sfValidatorBase::setCharset(\sfConfig::get('sf_charset')); // force setting default timezone if not set - if ($default_timezone = sfConfig::get('sf_default_timezone')) { + if ($default_timezone = \sfConfig::get('sf_default_timezone')) { date_default_timezone_set($default_timezone); - } elseif (sfConfig::get('sf_force_default_timezone', true)) { + } elseif (\sfConfig::get('sf_force_default_timezone', true)) { date_default_timezone_set(@date_default_timezone_get()); } // error settings ini_set('display_errors', $this->isDebug() ? 'on' : 'off'); - error_reporting(sfConfig::get('sf_error_reporting')); + error_reporting(\sfConfig::get('sf_error_reporting')); // initialize plugin configuration objects $this->initializePlugins(); // compress output - if (!self::$coreLoaded && sfConfig::get('sf_compressed')) { + if (!self::$coreLoaded && \sfConfig::get('sf_compressed')) { ob_start('ob_gzhandler'); } @@ -149,7 +150,7 @@ public function initConfiguration() * * @return array */ - public function filterAutoloadConfig(sfEvent $event, array $config) + public function filterAutoloadConfig(\sfEvent $event, array $config) { foreach ($this->pluginConfigurations as $name => $configuration) { $config = $configuration->filterAutoloadConfig($event, $config); @@ -161,12 +162,12 @@ public function filterAutoloadConfig(sfEvent $event, array $config) /** * Returns a configuration cache object for the current configuration. * - * @return sfConfigCache A sfConfigCache instance + * @return \sfConfigCache A sfConfigCache instance */ public function getConfigCache() { if (null === $this->configCache) { - $this->configCache = new sfConfigCache($this); + $this->configCache = new \sfConfigCache($this); } return $this->configCache; @@ -178,16 +179,16 @@ public function getConfigCache() public function checkLock() { if ( - $this->hasLockFile(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'-cli.lck', 5) - || $this->hasLockFile(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'.lck') + $this->hasLockFile(\sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'-cli.lck', 5) + || $this->hasLockFile(\sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'.lck') ) { // application is not available - we'll find the most specific unavailable page... - $files = array( - sfConfig::get('sf_app_config_dir').'/unavailable.php', - sfConfig::get('sf_config_dir').'/unavailable.php', - sfConfig::get('sf_web_dir').'/errors/unavailable.php', + $files = [ + \sfConfig::get('sf_app_config_dir').'/unavailable.php', + \sfConfig::get('sf_config_dir').'/unavailable.php', + \sfConfig::get('sf_web_dir').'/errors/unavailable.php', $this->getSymfonyLibDir().'/exception/data/unavailable.php', - ); + ]; foreach ($files as $file) { if (is_readable($file)) { @@ -213,14 +214,14 @@ public function setRootDir($rootDir) { parent::setRootDir($rootDir); - sfConfig::add(array( + \sfConfig::add([ 'sf_app' => $this->getApplication(), 'sf_environment' => $this->getEnvironment(), 'sf_debug' => $this->isDebug(), 'sf_cli' => PHP_SAPI === 'cli', - )); + ]); - $this->setAppDir(sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$this->getApplication()); + $this->setAppDir(\sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$this->getApplication()); } /** @@ -230,7 +231,7 @@ public function setRootDir($rootDir) */ public function setAppDir($appDir) { - sfConfig::add(array( + \sfConfig::add([ 'sf_app_dir' => $appDir, // SF_APP_DIR directory structure @@ -239,17 +240,17 @@ public function setAppDir($appDir) 'sf_app_module_dir' => $appDir.DIRECTORY_SEPARATOR.'modules', 'sf_app_template_dir' => $appDir.DIRECTORY_SEPARATOR.'templates', 'sf_app_i18n_dir' => $appDir.DIRECTORY_SEPARATOR.'i18n', - )); + ]); } /** - * @see sfProjectConfiguration + * @see \sfProjectConfiguration */ public function setCacheDir($cacheDir) { parent::setCacheDir($cacheDir); - sfConfig::add(array( + \sfConfig::add([ 'sf_app_base_cache_dir' => $cacheDir.DIRECTORY_SEPARATOR.$this->getApplication(), 'sf_app_cache_dir' => $appCacheDir = $cacheDir.DIRECTORY_SEPARATOR.$this->getApplication().DIRECTORY_SEPARATOR.$this->getEnvironment(), @@ -259,7 +260,7 @@ public function setCacheDir($cacheDir) 'sf_config_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'config', 'sf_test_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'test', 'sf_module_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'modules', - )); + ]); } /** @@ -272,9 +273,9 @@ public function setCacheDir($cacheDir) public function getControllerDirs($moduleName) { if (!isset($this->cache['getControllerDirs'][$moduleName])) { - $dirs = array(); + $dirs = []; - $dirs[sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/actions'] = false; // application + $dirs[\sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/actions'] = false; // application foreach ($this->getPluginPaths() as $path) { if (is_dir($dir = $path.'/modules/'.$moduleName.'/actions')) { @@ -301,12 +302,12 @@ public function getControllerDirs($moduleName) */ public function getLibDirs($moduleName) { - $dirs = array(); + $dirs = []; - $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib'; // application + $dirs[] = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib'; // application $dirs = array_merge($dirs, $this->getPluginSubPaths('/modules/'.$moduleName.'/lib')); // plugins $dirs[] = $this->getSymfonyLibDir().'/controller/'.$moduleName.'/lib'; // core modules - $dirs[] = sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($moduleName.'/lib'); // generated templates in cache + $dirs[] = \sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($moduleName.'/lib'); // generated templates in cache return $dirs; } @@ -320,12 +321,12 @@ public function getLibDirs($moduleName) */ public function getTemplateDirs($moduleName) { - $dirs = array(); + $dirs = []; - $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/templates'; // application + $dirs[] = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/templates'; // application $dirs = array_merge($dirs, $this->getPluginSubPaths('/modules/'.$moduleName.'/templates')); // plugins $dirs[] = $this->getSymfonyLibDir().'/controller/'.$moduleName.'/templates'; // core modules - $dirs[] = sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($moduleName.'/templates'); // generated templates in cache + $dirs[] = \sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($moduleName.'/templates'); // generated templates in cache return $dirs; } @@ -339,22 +340,22 @@ public function getTemplateDirs($moduleName) */ public function getHelperDirs($moduleName = '') { - $dirs = array(); + $dirs = []; if ($moduleName) { - $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib/helper'; // module + $dirs[] = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib/helper'; // module $dirs = array_merge($dirs, $this->getPluginSubPaths('/modules/'.$moduleName.'/lib/helper')); } return array_merge( $dirs, - array( - sfConfig::get('sf_app_lib_dir').'/helper', // application - sfConfig::get('sf_lib_dir').'/helper', // project - ), + [ + \sfConfig::get('sf_app_lib_dir').'/helper', // application + \sfConfig::get('sf_lib_dir').'/helper', // project + ], $this->getPluginSubPaths('/lib/helper'), // plugins - array($this->getSymfonyLibDir().'/helper') // symfony + [$this->getSymfonyLibDir().'/helper'] // symfony ); } @@ -398,7 +399,7 @@ public function getTemplatePath($moduleName, $templateFile) } /** - * @see sfProjectConfiguration + * @see \sfProjectConfiguration */ public function getPluginPaths() { @@ -416,7 +417,7 @@ public function getPluginPaths() */ public function getDecoratorDirs() { - return array(sfConfig::get('sf_app_template_dir')); + return [\sfConfig::get('sf_app_template_dir')]; } /** @@ -442,10 +443,10 @@ public function getDecoratorDir($template) */ public function getI18NGlobalDirs() { - $dirs = array(); + $dirs = []; // application - if (is_dir($dir = sfConfig::get('sf_app_i18n_dir'))) { + if (is_dir($dir = \sfConfig::get('sf_app_i18n_dir'))) { $dirs[] = $dir; } @@ -462,15 +463,15 @@ public function getI18NGlobalDirs() */ public function getI18NDirs($moduleName) { - $dirs = array(); + $dirs = []; // module - if (is_dir($dir = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/i18n')) { + if (is_dir($dir = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/i18n')) { $dirs[] = $dir; } // application - if (is_dir($dir = sfConfig::get('sf_app_i18n_dir'))) { + if (is_dir($dir = \sfConfig::get('sf_app_i18n_dir'))) { $dirs[] = $dir; } @@ -492,9 +493,9 @@ public function getConfigPaths($configPath) { $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath); - $files = array( + $files = [ $this->getSymfonyLibDir().'/config/'.$globalConfigPath, // symfony - ); + ]; foreach ($this->getPluginPaths() as $path) { if (is_file($file = $path.'/'.$globalConfigPath)) { @@ -502,12 +503,12 @@ public function getConfigPaths($configPath) } } - $files = array_merge($files, array( + $files = array_merge($files, [ $this->getRootDir().'/'.$globalConfigPath, // project $this->getRootDir().'/'.$configPath, // project - sfConfig::get('sf_app_dir').'/'.$globalConfigPath, // application - sfConfig::get('sf_app_cache_dir').'/'.$configPath, // generated modules - )); + \sfConfig::get('sf_app_dir').'/'.$globalConfigPath, // application + \sfConfig::get('sf_app_cache_dir').'/'.$configPath, // generated modules + ]); foreach ($this->getPluginPaths() as $path) { if (is_file($file = $path.'/'.$configPath)) { @@ -515,9 +516,9 @@ public function getConfigPaths($configPath) } } - $files[] = sfConfig::get('sf_app_dir').'/'.$configPath; // module + $files[] = \sfConfig::get('sf_app_dir').'/'.$configPath; // module - $configs = array(); + $configs = []; foreach (array_unique($files) as $file) { if (is_readable($file)) { $configs[] = $file; @@ -562,7 +563,7 @@ public function loadHelpers($helpers, $moduleName = '') } if (!$included) { - throw new InvalidArgumentException(sprintf('Unable to load "%sHelper.php" helper in: %s.', $helperName, implode(', ', array_map(array('sfDebug', 'shortenFilePath'), $dirs)))); + throw new \InvalidArgumentException(sprintf('Unable to load "%sHelper.php" helper in: %s.', $helperName, implode(', ', array_map(['sfDebug', 'shortenFilePath'], $dirs)))); } } diff --git a/lib/config/sfAutoloadConfigHandler.class.php b/lib/config/sfAutoloadConfigHandler.class.php index 09faea48e..4aec4d0d2 100755 --- a/lib/config/sfAutoloadConfigHandler.class.php +++ b/lib/config/sfAutoloadConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,7 @@ * * @version SVN: $Id$ */ -class sfAutoloadConfigHandler extends sfYamlConfigHandler +class sfAutoloadConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -24,15 +24,15 @@ class sfAutoloadConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { // set our required categories list and initialize our handler - $this->initialize(array('required_categories' => array('autoload'))); + $this->initialize(['required_categories' => ['autoload']]); - $data = array(); + $data = []; foreach ($this->parse($configFiles) as $name => $mapping) { $data[] = sprintf("\n // %s", $name); @@ -53,7 +53,7 @@ public function execute($configFiles) public function evaluate($configFiles) { - $mappings = array(); + $mappings = []; foreach ($this->parse($configFiles) as $mapping) { foreach ($mapping as $class => $file) { $mappings[$class] = $file; @@ -65,7 +65,7 @@ public function evaluate($configFiles) public static function parseFile($path, $file, $prefix) { - $mapping = array(); + $mapping = []; preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface|trait)\s+(\w+)~mi', file_get_contents($file), $classes); foreach ($classes[1] as $class) { $localPrefix = ''; @@ -84,14 +84,14 @@ public static function parseFile($path, $file, $prefix) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { - $configuration = sfProjectConfiguration::getActive(); + $configuration = \sfProjectConfiguration::getActive(); $pluginPaths = $configuration->getPluginPaths(); - $pluginConfigFiles = array(); + $pluginConfigFiles = []; // move plugin files to front foreach ($configFiles as $i => $configFile) { @@ -113,7 +113,7 @@ public static function getConfiguration(array $configFiles) } } - $event = $configuration->getEventDispatcher()->filter(new sfEvent(__CLASS__, 'autoload.filter_config'), $config); + $event = $configuration->getEventDispatcher()->filter(new \sfEvent(__CLASS__, 'autoload.filter_config'), $config); $config = $event->getReturnValue(); return $config; @@ -124,9 +124,9 @@ protected function parse(array $configFiles) // parse the yaml $config = static::getConfiguration($configFiles); - $mappings = array(); + $mappings = []; foreach ($config['autoload'] as $name => $entry) { - $mapping = array(); + $mapping = []; // file mapping or directory mapping? if (isset($entry['files'])) { @@ -140,8 +140,8 @@ protected function parse(array $configFiles) $path = $entry['path']; // we automatically add our php classes - require_once sfConfig::get('sf_symfony_lib_dir').'/util/sfFinder.class.php'; - $finder = sfFinder::type('file')->name('*'.$ext)->follow_link(); + require_once \sfConfig::get('sf_symfony_lib_dir').'/util/sfFinder.class.php'; + $finder = \sfFinder::type('file')->name('*'.$ext)->follow_link(); // recursive mapping? $recursive = isset($entry['recursive']) ? $entry['recursive'] : false; diff --git a/lib/config/sfCacheConfigHandler.class.php b/lib/config/sfCacheConfigHandler.class.php index bc4095df0..1f687b096 100644 --- a/lib/config/sfCacheConfigHandler.class.php +++ b/lib/config/sfCacheConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,9 +16,9 @@ * * @version SVN: $Id$ */ -class sfCacheConfigHandler extends sfYamlConfigHandler +class sfCacheConfigHandler extends \sfYamlConfigHandler { - protected $cacheConfig = array(); + protected $cacheConfig = []; /** * Executes this configuration handler. @@ -26,9 +27,9 @@ class sfCacheConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted - * @throws sfInitializationException If a cache.yml key check fails + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted + * @throws \sfInitializationException If a cache.yml key check fails */ public function execute($configFiles) { @@ -36,7 +37,7 @@ public function execute($configFiles) $this->yamlConfig = static::getConfiguration($configFiles); // iterate through all action names - $data = array(); + $data = []; $first = true; foreach ($this->yamlConfig as $actionName => $values) { if ('all' == $actionName) { @@ -64,7 +65,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -80,7 +81,7 @@ public static function getConfiguration(array $configFiles) */ protected function addCache($actionName = '') { - $data = array(); + $data = []; // enabled? $enabled = $this->getConfigValue('enabled', $actionName); @@ -98,9 +99,9 @@ protected function addCache($actionName = '') $contextual = $this->getConfigValue('contextual', $actionName) ? 'true' : 'false'; // vary - $vary = $this->getConfigValue('vary', $actionName, array()); + $vary = $this->getConfigValue('vary', $actionName, []); if (!is_array($vary)) { - $vary = array($vary); + $vary = [$vary]; } // add cache information to cache manager diff --git a/lib/config/sfCompileConfigHandler.class.php b/lib/config/sfCompileConfigHandler.class.php index 70f29f2be..c217ac5f0 100644 --- a/lib/config/sfCompileConfigHandler.class.php +++ b/lib/config/sfCompileConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -18,7 +18,7 @@ * * @version SVN: $Id$ */ -class sfCompileConfigHandler extends sfYamlConfigHandler +class sfCompileConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -27,8 +27,8 @@ class sfCompileConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -42,24 +42,24 @@ public function execute($configFiles) foreach ($config as $file) { if (!is_readable($file)) { // file doesn't exist - throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file)); } $contents = file_get_contents($file); // strip comments (not in debug mode) - if (!sfConfig::get('sf_debug')) { - $contents = sfToolkit::stripComments($contents); + if (!\sfConfig::get('sf_debug')) { + $contents = \sfToolkit::stripComments($contents); } // strip php tags - $contents = sfToolkit::pregtr($contents, array('/^\s*<\?(php\s*)?/m' => '', '/^\s*\?>/m' => '')); + $contents = \sfToolkit::pregtr($contents, ['/^\s*<\?(php\s*)?/m' => '', '/^\s*\?>/m' => '']); // replace windows and mac format with unix format $contents = str_replace("\r", "\n", $contents); // replace multiple new lines with a single newline - $contents = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $contents); + $contents = preg_replace(['/\s+$/Sm', '/\n+/S'], "\n", $contents); // append file data $data .= "\n".$contents; @@ -77,11 +77,11 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { - $config = array(); + $config = []; foreach ($configFiles as $configFile) { $config = array_merge($config, static::parseYaml($configFile)); } diff --git a/lib/config/sfConfig.class.php b/lib/config/sfConfig.class.php index 7be4530bd..193996e0c 100644 --- a/lib/config/sfConfig.class.php +++ b/lib/config/sfConfig.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +18,7 @@ */ class sfConfig { - protected static $config = array(); + protected static $config = []; /** * Retrieves a config parameter. @@ -65,7 +66,7 @@ public static function set($name, $value) * * @param array $parameters An associative array of config parameters and their associated values */ - public static function add($parameters = array()) + public static function add($parameters = []) { self::$config = array_merge(self::$config, $parameters); } @@ -85,6 +86,6 @@ public static function getAll() */ public static function clear() { - self::$config = array(); + self::$config = []; } } diff --git a/lib/config/sfConfigCache.class.php b/lib/config/sfConfigCache.class.php index bf33328a4..f99972e94 100644 --- a/lib/config/sfConfigCache.class.php +++ b/lib/config/sfConfigCache.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -22,15 +22,15 @@ class sfConfigCache { protected $configuration; - protected $handlers = array(); - protected $userHandlers = array(); + protected $handlers = []; + protected $userHandlers = []; /** * Constructor. * - * @param sfApplicationConfiguration $configuration A sfApplicationConfiguration instance + * @param \sfApplicationConfiguration $configuration A sfApplicationConfiguration instance */ - public function __construct(sfApplicationConfiguration $configuration) + public function __construct(\sfApplicationConfiguration $configuration) { $this->configuration = $configuration; } @@ -49,27 +49,27 @@ public function __construct(sfApplicationConfiguration $configuration) * * @return string An absolute filesystem path to the cache filename associated with this specified configuration file * - * @throws sfConfigurationException If a requested configuration file does not exist + * @throws \sfConfigurationException If a requested configuration file does not exist * * @see sfConfiguration::getConfigPaths() */ public function checkConfig($configPath, $optional = false) { - if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { - $timer = sfTimerManager::getTimer('Configuration'); + if (\sfConfig::get('sf_debug') && \sfConfig::get('sf_logging_enabled')) { + $timer = \sfTimerManager::getTimer('Configuration'); } // the cache filename we'll be using $cache = $this->getCacheName($configPath); - if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && is_readable($cache)) { + if (!\sfConfig::get('sf_debug') && !\sfConfig::get('sf_test') && is_readable($cache)) { return $cache; } - if (!sfToolkit::isPathAbsolute($configPath)) { + if (!\sfToolkit::isPathAbsolute($configPath)) { $files = $this->configuration->getConfigPaths($configPath); } else { - $files = is_readable($configPath) ? array($configPath) : array(); + $files = is_readable($configPath) ? [$configPath] : []; } if (!isset($files[0])) { @@ -78,7 +78,7 @@ public function checkConfig($configPath, $optional = false) } // configuration does not exist - throw new sfConfigurationException(sprintf('Configuration "%s" does not exist or is unreadable.', $configPath)); + throw new \sfConfigurationException(sprintf('Configuration "%s" does not exist or is unreadable.', $configPath)); } // find the more recent configuration file last modification time @@ -94,7 +94,7 @@ public function checkConfig($configPath, $optional = false) $this->callHandler($configPath, $files, $cache); } - if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { + if (\sfConfig::get('sf_debug') && \sfConfig::get('sf_logging_enabled')) { // @var $timer sfTimer $timer->addTime(); } @@ -107,7 +107,7 @@ public function checkConfig($configPath, $optional = false) */ public function clear() { - sfToolkit::clearDirectory(sfConfig::get('sf_config_cache_dir')); + \sfToolkit::clearDirectory(\sfConfig::get('sf_config_cache_dir')); } /** @@ -125,10 +125,10 @@ public function getCacheName($config) } // replace unfriendly filename characters with an underscore - $config = str_replace(array('\\', '/', ' '), '_', $config); + $config = str_replace(['\\', '/', ' '], '_', $config); $config .= '.php'; - return sfConfig::get('sf_config_cache_dir').'/'.$config; + return \sfConfig::get('sf_config_cache_dir').'/'.$config; } /** @@ -160,10 +160,10 @@ public function import($config, $once = true, $optional = false) * Registers a configuration handler. * * @param string $handler The handler to use when parsing a configuration file - * @param class $class A configuration handler class + * @param \class $class A configuration handler class * @param string $params An array of options for the handler class initialization */ - public function registerConfigHandler($handler, $class, $params = array()) + public function registerConfigHandler($handler, $class, $params = []) { $this->userHandlers[$handler] = new $class($params); } @@ -175,7 +175,7 @@ public function registerConfigHandler($handler, $class, $params = array()) * @param array $configs An array of absolute filesystem paths to configuration files * @param string $cache An absolute filesystem path to the cache file that will be written * - * @throws sfConfigurationException If a requested configuration file does not have an associated configuration handler + * @throws \sfConfigurationException If a requested configuration file does not have an associated configuration handler */ protected function callHandler($handler, $configs, $cache) { @@ -206,8 +206,8 @@ protected function callHandler($handler, $configs, $cache) // let's see if we have any wildcard handlers registered that match this basename foreach (array_keys($this->handlers) as $key) { // replace wildcard chars in the configuration - $pattern = strtr($key, array('.' => '\.', '*' => '(.*?)')); - $matches = array(); + $pattern = strtr($key, ['.' => '\.', '*' => '(.*?)']); + $matches = []; // create pattern from config if (preg_match('#'.$pattern.'$#', $handler, $matches)) { @@ -222,7 +222,7 @@ protected function callHandler($handler, $configs, $cache) if (!$handlerInstance) { // we do not have a registered handler for this file - throw new sfConfigurationException(sprintf('Configuration file "%s" does not have a registered handler.', implode(', ', $configs))); + throw new \sfConfigurationException(sprintf('Configuration file "%s" does not have a registered handler.', implode(', ', $configs))); } // call the handler and retrieve the cache data @@ -236,7 +236,7 @@ protected function callHandler($handler, $configs, $cache) * * @param string $name The config handler name * - * @return sfConfigHandler A sfConfigHandler instance + * @return \sfConfigHandler A sfConfigHandler instance */ protected function getHandler($name) { @@ -251,12 +251,12 @@ protected function getHandler($name) /** * Loads all configuration application and module level handlers. * - * @throws sfConfigurationException If a configuration related error occurs + * @throws \sfConfigurationException If a configuration related error occurs */ protected function loadConfigHandlers() { // manually create our config_handlers.yml handler - $this->handlers['config_handlers.yml'] = new sfRootConfigHandler(); + $this->handlers['config_handlers.yml'] = new \sfRootConfigHandler(); // application configuration handlers @@ -265,12 +265,12 @@ protected function loadConfigHandlers() // module level configuration handlers // checks modules directory exists - if (!is_readable($sf_app_module_dir = sfConfig::get('sf_app_module_dir'))) { + if (!is_readable($sf_app_module_dir = \sfConfig::get('sf_app_module_dir'))) { return; } // ignore names - $ignore = array('.', '..', 'CVS', '.svn'); + $ignore = ['.', '..', 'CVS', '.svn']; // create a file pointer to the module dir $fp = opendir($sf_app_module_dir); @@ -285,7 +285,7 @@ protected function loadConfigHandlers() if (is_readable($configPath)) { // initialize the root configuration handler with this module name - $params = array('module_level' => true, 'module_name' => $directory); + $params = ['module_level' => true, 'module_name' => $directory]; $this->handlers['config_handlers.yml']->initialize($params); @@ -308,7 +308,7 @@ protected function loadConfigHandlers() * @param string $cache An absolute filesystem path to the cache file that will be written * @param string $data Data to be written to the cache file * - * @throws sfCacheException If the cache file cannot be written + * @throws \sfCacheException If the cache file cannot be written */ protected function writeCacheFile($config, $cache, $data) { @@ -321,7 +321,7 @@ protected function writeCacheFile($config, $cache, $data) $tmpFile = tempnam($cacheDir, basename($cache)); if (!$fp = @fopen($tmpFile, 'wb')) { - throw new sfCacheException(sprintf('Failed to write cache file "%s" generated from configuration file "%s".', $tmpFile, $config)); + throw new \sfCacheException(sprintf('Failed to write cache file "%s" generated from configuration file "%s".', $tmpFile, $config)); } @fwrite($fp, $data); @@ -349,6 +349,6 @@ protected function mergeUserConfigHandlers() // user defined configuration handlers $this->handlers = array_merge($this->handlers, $this->userHandlers); - $this->userHandlers = array(); + $this->userHandlers = []; } } diff --git a/lib/config/sfConfigHandler.class.php b/lib/config/sfConfigHandler.class.php index 8904862af..7e1ebbbfb 100644 --- a/lib/config/sfConfigHandler.class.php +++ b/lib/config/sfConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -21,7 +21,7 @@ */ abstract class sfConfigHandler { - /** @var sfParameterHolder */ + /** @var \sfParameterHolder */ protected $parameterHolder; /** @@ -29,7 +29,7 @@ abstract class sfConfigHandler * * @see initialize() * - * @param array|null $parameters + * @param \array|null $parameters */ public function __construct($parameters = null) { @@ -41,11 +41,11 @@ public function __construct($parameters = null) * * @param array $parameters An associative array of initialization parameters * - * @throws sfInitializationException If an error occurs while initializing this ConfigHandler + * @throws \sfInitializationException If an error occurs while initializing this ConfigHandler */ public function initialize($parameters = null) { - $this->parameterHolder = new sfParameterHolder(); + $this->parameterHolder = new \sfParameterHolder(); $this->parameterHolder->add($parameters); } @@ -56,8 +56,8 @@ public function initialize($parameters = null) * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ abstract public function execute($configFiles); @@ -73,9 +73,9 @@ abstract public function execute($configFiles); public static function replaceConstants($value) { if (is_array($value)) { - array_walk_recursive($value, function (&$value) { $value = sfToolkit::replaceConstants($value); }); + array_walk_recursive($value, function (&$value) { $value = \sfToolkit::replaceConstants($value); }); } else { - $value = sfToolkit::replaceConstants($value); + $value = \sfToolkit::replaceConstants($value); } return $value; @@ -91,11 +91,11 @@ public static function replaceConstants($value) public static function replacePath($path) { if (is_array($path)) { - array_walk_recursive($path, function (&$path) { $path = sfConfigHandler::replacePath($path); }); + array_walk_recursive($path, function (&$path) { $path = \sfConfigHandler::replacePath($path); }); } else { - if (!sfToolkit::isPathAbsolute($path)) { + if (!\sfToolkit::isPathAbsolute($path)) { // not an absolute path so we'll prepend to it - $path = sfConfig::get('sf_app_dir').'/'.$path; + $path = \sfConfig::get('sf_app_dir').'/'.$path; } } @@ -105,7 +105,7 @@ public static function replacePath($path) /** * Gets the parameter holder for this configuration handler. * - * @return sfParameterHolder A sfParameterHolder instance + * @return \sfParameterHolder A sfParameterHolder instance */ public function getParameterHolder() { @@ -117,10 +117,10 @@ public function getParameterHolder() * * @param array $configFiles An array of ordered configuration files * - * @throws LogicException no matter what + * @throws \LogicException no matter what */ public static function getConfiguration(array $configFiles) { - throw new LogicException('You must call the ::getConfiguration() method on a concrete config handler class'); + throw new \LogicException('You must call the ::getConfiguration() method on a concrete config handler class'); } } diff --git a/lib/config/sfDatabaseConfigHandler.class.php b/lib/config/sfDatabaseConfigHandler.class.php index 8113693f7..8a47add0d 100644 --- a/lib/config/sfDatabaseConfigHandler.class.php +++ b/lib/config/sfDatabaseConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,7 +19,7 @@ * * @version SVN: $Id$ */ -class sfDatabaseConfigHandler extends sfYamlConfigHandler +class sfDatabaseConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -28,8 +28,8 @@ class sfDatabaseConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -62,7 +62,7 @@ public function evaluate($configFiles) require_once $include; } - $databases = array(); + $databases = []; foreach ($data as $name => $database) { $databases[$name] = new $database[0]($database[1]); } @@ -71,7 +71,7 @@ public function evaluate($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -92,16 +92,16 @@ protected function parse($configFiles) $config = static::getConfiguration($configFiles); // init our data and includes arrays - $data = array(); - $databases = array(); - $includes = array(); + $data = []; + $databases = []; + $includes = []; // get a list of database connections foreach ($config as $name => $dbConfig) { // is this category already registered? if (in_array($name, $databases)) { // this category is already registered - throw new sfParseException(sprintf('Configuration file "%s" specifies previously registered category "%s".', $configFiles[0], $name)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies previously registered category "%s".', $configFiles[0], $name)); } // add this database @@ -110,14 +110,14 @@ protected function parse($configFiles) // let's do our fancy work if (!isset($dbConfig['class'])) { // missing class key - throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $name)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $name)); } if (isset($dbConfig['file'])) { // we have a file to include if (!is_readable($dbConfig['file'])) { // database file doesn't exist - throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $dbConfig['class'], $dbConfig['file'])); + throw new \sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $dbConfig['class'], $dbConfig['file'])); } // append our data @@ -125,16 +125,16 @@ protected function parse($configFiles) } // parse parameters - $parameters = array(); + $parameters = []; if (isset($dbConfig['param'])) { $parameters = $dbConfig['param']; } $parameters['name'] = $name; // append new data - $data[$name] = array($dbConfig['class'], $parameters); + $data[$name] = [$dbConfig['class'], $parameters]; } - return array($includes, $data); + return [$includes, $data]; } } diff --git a/lib/config/sfDefineEnvironmentConfigHandler.class.php b/lib/config/sfDefineEnvironmentConfigHandler.class.php index 979817859..7abb60009 100644 --- a/lib/config/sfDefineEnvironmentConfigHandler.class.php +++ b/lib/config/sfDefineEnvironmentConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +14,7 @@ * * @version SVN: $Id$ */ -class sfDefineEnvironmentConfigHandler extends sfYamlConfigHandler +class sfDefineEnvironmentConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -22,8 +23,8 @@ class sfDefineEnvironmentConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -41,7 +42,7 @@ public function execute($configFiles) // parse the yaml $config = static::getConfiguration($configFiles); - $values = array(); + $values = []; foreach ($config as $category => $keys) { $values = array_merge($values, $this->getValues($prefix, $category, $keys)); } @@ -64,7 +65,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -85,10 +86,10 @@ protected function getValues($prefix, $category, $keys) if (!is_array($keys)) { list($key, $value) = $this->fixCategoryValue($prefix.strtolower($category), '', $keys); - return array($key => $value); + return [$key => $value]; } - $values = array(); + $values = []; $category = $this->fixCategoryName($category, $prefix); @@ -112,7 +113,7 @@ protected function getValues($prefix, $category, $keys) */ protected function fixCategoryValue($category, $key, $value) { - return array($category.$key, $value); + return [$category.$key, $value]; } /** diff --git a/lib/config/sfFactoryConfigHandler.class.php b/lib/config/sfFactoryConfigHandler.class.php index e190d73de..ea73bcbf0 100644 --- a/lib/config/sfFactoryConfigHandler.class.php +++ b/lib/config/sfFactoryConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -18,7 +18,7 @@ * * @version SVN: $Id$ */ -class sfFactoryConfigHandler extends sfYamlConfigHandler +class sfFactoryConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -27,8 +27,8 @@ class sfFactoryConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -36,11 +36,11 @@ public function execute($configFiles) $config = static::getConfiguration($configFiles); // init our data and includes arrays - $includes = array(); - $instances = array(); + $includes = []; + $instances = []; // available list of factories - $factories = array('view_cache_manager', 'logger', 'i18n', 'controller', 'request', 'response', 'routing', 'storage', 'user', 'view_cache', 'mailer', 'service_container'); + $factories = ['view_cache_manager', 'logger', 'i18n', 'controller', 'request', 'response', 'routing', 'storage', 'user', 'view_cache', 'mailer', 'service_container']; // let's do our fancy work foreach ($factories as $factory) { @@ -49,7 +49,7 @@ public function execute($configFiles) if (!isset($keys['class'])) { // missing class key - throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $factory)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $factory)); } $class = $keys['class']; @@ -58,7 +58,7 @@ public function execute($configFiles) // we have a file to include if (!is_readable($keys['file'])) { // factory file doesn't exist - throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); + throw new \sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); } // append our data @@ -66,10 +66,10 @@ public function execute($configFiles) } // parse parameters - $parameters = array(); + $parameters = []; if (isset($keys['param'])) { if (!is_array($keys['param'])) { - throw new InvalidArgumentException(sprintf('The "param" key for the "%s" factory must be an array (in %s).', $class, $configFiles[0])); + throw new \InvalidArgumentException(sprintf('The "param" key for the "%s" factory must be an array (in %s).', $class, $configFiles[0])); } $parameters = $keys['param']; @@ -83,7 +83,7 @@ public function execute($configFiles) break; case 'request': - $parameters['no_script_name'] = sfConfig::get('sf_no_script_name'); + $parameters['no_script_name'] = \sfConfig::get('sf_no_script_name'); $instances[] = sprintf(" \$class = sfConfig::get('sf_factory_request', '%s');\n \$this->factories['request'] = new \$class(\$this->dispatcher, array(), array(), sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", $class, var_export($parameters, true)); break; @@ -96,7 +96,7 @@ public function execute($configFiles) break; case 'storage': - $defaultParameters = array(); + $defaultParameters = []; $defaultParameters[] = sprintf("'auto_shutdown' => false, 'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); if (is_subclass_of($class, 'sfDatabaseSessionStorage')) { $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); @@ -190,7 +190,7 @@ public function execute($configFiles) if (!isset($keys['class'])) { // missing class key - throw new sfParseException(sprintf('Configuration file "%s" specifies logger "%s" with missing class key.', $configFiles[0], $name)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies logger "%s" with missing class key.', $configFiles[0], $name)); } $condition = true; @@ -259,7 +259,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfFilterConfigHandler.class.php b/lib/config/sfFilterConfigHandler.class.php index 076c2af9e..870459e48 100644 --- a/lib/config/sfFilterConfigHandler.class.php +++ b/lib/config/sfFilterConfigHandler.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * * @version SVN: $Id$ */ -class sfFilterConfigHandler extends sfYamlConfigHandler +class sfFilterConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -26,8 +26,8 @@ class sfFilterConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -35,8 +35,8 @@ public function execute($configFiles) $config = static::getConfiguration($configFiles); // init our data and includes arrays - $data = array(); - $includes = array(); + $data = []; + $includes = []; $execution = false; $rendering = false; @@ -49,7 +49,7 @@ public function execute($configFiles) if (!isset($keys['class'])) { // missing class key - throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $category)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $category)); } $class = $keys['class']; @@ -57,7 +57,7 @@ public function execute($configFiles) if (isset($keys['file'])) { if (!is_readable($keys['file'])) { // filter file doesn't exist - throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); + throw new \sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); } // append our data @@ -95,11 +95,11 @@ public function execute($configFiles) } if (!$rendering) { - throw new sfParseException(sprintf('Configuration file "%s" must register a filter of type "rendering".', $configFiles[0])); + throw new \sfParseException(sprintf('Configuration file "%s" must register a filter of type "rendering".', $configFiles[0])); } if (!$execution) { - throw new sfParseException(sprintf('Configuration file "%s" must register a filter of type "execution".', $configFiles[0])); + throw new \sfParseException(sprintf('Configuration file "%s" must register a filter of type "execution".', $configFiles[0])); } // compile data @@ -116,7 +116,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -125,16 +125,16 @@ public static function getConfiguration(array $configFiles) // we get the order of the new file and merge with the previous configurations $previous = $config; - $config = array(); + $config = []; foreach (static::parseYaml($configFile) as $key => $value) { $value = (array) $value; - $config[$key] = isset($previous[$key]) ? sfToolkit::arrayDeepMerge($previous[$key], $value) : $value; + $config[$key] = isset($previous[$key]) ? \sfToolkit::arrayDeepMerge($previous[$key], $value) : $value; } // check that every key in previous array is still present (to avoid problem when upgrading) foreach (array_keys($previous) as $key) { if (!isset($config[$key])) { - throw new sfConfigurationException(sprintf('The filter name "%s" is defined in "%s" but not present in "%s" file. To disable a filter, add a "enabled" key with a false value.', $key, $configFiles[$i], $configFile)); + throw new \sfConfigurationException(sprintf('The filter name "%s" is defined in "%s" but not present in "%s" file. To disable a filter, add a "enabled" key with a false value.', $key, $configFiles[$i], $configFile)); } } } diff --git a/lib/config/sfGeneratorConfigHandler.class.php b/lib/config/sfGeneratorConfigHandler.class.php index adcf8700c..676a56bfb 100644 --- a/lib/config/sfGeneratorConfigHandler.class.php +++ b/lib/config/sfGeneratorConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfGeneratorConfigHandler extends sfYamlConfigHandler +class sfGeneratorConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -24,9 +25,9 @@ class sfGeneratorConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted - * @throws sfInitializationException If a generator.yml key check fails + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted + * @throws \sfInitializationException If a generator.yml key check fails */ public function execute($configFiles) { @@ -37,26 +38,26 @@ public function execute($configFiles) } if (!isset($config['generator'])) { - throw new sfParseException(sprintf('Configuration file "%s" must specify a generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); + throw new \sfParseException(sprintf('Configuration file "%s" must specify a generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); } $config = $config['generator']; if (!isset($config['class'])) { - throw new sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); + throw new \sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); } - foreach (array('fields', 'list', 'edit') as $section) { + foreach (['fields', 'list', 'edit'] as $section) { if (isset($config[$section])) { - throw new sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0], $section)); + throw new \sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0], $section)); } } // generate class and add a reference to it - $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration()); + $generatorManager = new \sfGeneratorManager(\sfContext::getInstance()->getConfiguration()); // generator parameters - $generatorParam = (isset($config['param']) ? $config['param'] : array()); + $generatorParam = (isset($config['param']) ? $config['param'] : []); // hack to find the module name (look for the last /modules/ in path) preg_match('#.*/modules/([^/]+)/#', str_replace('\\', '/', $configFiles[0]), $match); @@ -71,13 +72,13 @@ public function execute($configFiles) return $retval; } - public static function getContent(sfGeneratorManager $generatorManager, $class, $parameters) + public static function getContent(\sfGeneratorManager $generatorManager, $class, $parameters) { return $generatorManager->generate($class, $parameters); } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfPluginConfiguration.class.php b/lib/config/sfPluginConfiguration.class.php index babc1c5f1..d5f63a20a 100644 --- a/lib/config/sfPluginConfiguration.class.php +++ b/lib/config/sfPluginConfiguration.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -25,11 +26,11 @@ abstract class sfPluginConfiguration /** * Constructor. * - * @param sfProjectConfiguration $configuration The project configuration - * @param string $rootDir The plugin root directory - * @param string $name The plugin name + * @param \sfProjectConfiguration $configuration The project configuration + * @param string $rootDir The plugin root directory + * @param string $name The plugin name */ - public function __construct(sfProjectConfiguration $configuration, $rootDir = null, $name = null) + public function __construct(\sfProjectConfiguration $configuration, $rootDir = null, $name = null) { $this->configuration = $configuration; $this->dispatcher = $configuration->getEventDispatcher(); @@ -39,7 +40,7 @@ public function __construct(sfProjectConfiguration $configuration, $rootDir = nu $this->setup(); $this->configure(); - if (!$this->configuration instanceof sfApplicationConfiguration) { + if (!$this->configuration instanceof \sfApplicationConfiguration) { $this->initializeAutoload(); $this->initialize(); } @@ -68,7 +69,7 @@ public function configure() * * This method is called after the plugin's classes have been added to sfAutoload. * - * @return bool|null If false sfApplicationConfiguration will look for a config.php (maintains BC with symfony < 1.2) + * @return \bool|null If false sfApplicationConfiguration will look for a config.php (maintains BC with symfony < 1.2) */ public function initialize() { @@ -101,16 +102,16 @@ public function getName() * configuration. Otherwise, autoload is handled in * {@link sfApplicationConfiguration} using {@link sfAutoload}. * - * @see sfSimpleAutoload + * @see \sfSimpleAutoload */ public function initializeAutoload() { - $autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir').'/project_autoload.cache'); + $autoload = \sfSimpleAutoload::getInstance(\sfConfig::get('sf_cache_dir').'/project_autoload.cache'); if (is_readable($file = $this->rootDir.'/config/autoload.yml')) { - $this->configuration->getEventDispatcher()->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); - $autoload->loadConfiguration(array($file)); - $this->configuration->getEventDispatcher()->disconnect('autoload.filter_config', array($this, 'filterAutoloadConfig')); + $this->configuration->getEventDispatcher()->connect('autoload.filter_config', [$this, 'filterAutoloadConfig']); + $autoload->loadConfiguration([$file]); + $this->configuration->getEventDispatcher()->disconnect('autoload.filter_config', [$this, 'filterAutoloadConfig']); } else { $autoload->addDirectory($this->rootDir.'/lib'); } @@ -123,26 +124,26 @@ public function initializeAutoload() * * @return array */ - public function filterAutoloadConfig(sfEvent $event, array $config) + public function filterAutoloadConfig(\sfEvent $event, array $config) { // use array_merge so config is added to the front of the autoload array if (!isset($config['autoload'][$this->name.'_lib'])) { - $config['autoload'] = array_merge(array( - $this->name.'_lib' => array( + $config['autoload'] = array_merge([ + $this->name.'_lib' => [ 'path' => $this->rootDir.'/lib', 'recursive' => true, - ), - ), $config['autoload']); + ], + ], $config['autoload']); } if (!isset($config['autoload'][$this->name.'_module_libs'])) { - $config['autoload'] = array_merge(array( - $this->name.'_module_libs' => array( + $config['autoload'] = array_merge([ + $this->name.'_module_libs' => [ 'path' => $this->rootDir.'/modules/*/lib', 'recursive' => true, 'prefix' => 1, - ), - ), $config['autoload']); + ], + ], $config['autoload']); } return $config; @@ -153,7 +154,7 @@ public function filterAutoloadConfig(sfEvent $event, array $config) */ public function connectTests() { - $this->dispatcher->connect('task.test.filter_test_files', array($this, 'filterTestFiles')); + $this->dispatcher->connect('task.test.filter_test_files', [$this, 'filterTestFiles']); } /** @@ -163,27 +164,27 @@ public function connectTests() * * @return array An array of files with the appropriate tests from the current plugin merged in */ - public function filterTestFiles(sfEvent $event, $files) + public function filterTestFiles(\sfEvent $event, $files) { $task = $event->getSubject(); - if ($task instanceof sfTestAllTask) { + if ($task instanceof \sfTestAllTask) { $directory = $this->rootDir.'/test'; - $names = array(); - } elseif ($task instanceof sfTestFunctionalTask) { + $names = []; + } elseif ($task instanceof \sfTestFunctionalTask) { $directory = $this->rootDir.'/test/functional'; $names = $event['arguments']['controller']; - } elseif ($task instanceof sfTestUnitTask) { + } elseif ($task instanceof \sfTestUnitTask) { $directory = $this->rootDir.'/test/unit'; $names = $event['arguments']['name']; } if (!count($names)) { - $names = array('*'); + $names = ['*']; } foreach ($names as $name) { - $finder = sfFinder::type('file')->follow_link()->name(basename($name).'Test.php'); + $finder = \sfFinder::type('file')->follow_link()->name(basename($name).'Test.php'); $files = array_merge($files, $finder->in($directory.'/'.dirname($name))); } @@ -197,7 +198,7 @@ public function filterTestFiles(sfEvent $event, $files) */ protected function guessRootDir() { - $r = new ReflectionClass(get_class($this)); + $r = new \ReflectionClass(get_class($this)); return realpath(dirname($r->getFileName()).'/..'); } diff --git a/lib/config/sfPluginConfigurationGeneric.class.php b/lib/config/sfPluginConfigurationGeneric.class.php index d7d9eff99..70fe0f77a 100644 --- a/lib/config/sfPluginConfigurationGeneric.class.php +++ b/lib/config/sfPluginConfigurationGeneric.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,10 +16,10 @@ * * @version SVN: $Id$ */ -class sfPluginConfigurationGeneric extends sfPluginConfiguration +class sfPluginConfigurationGeneric extends \sfPluginConfiguration { /** - * @see sfPluginConfiguration + * @see \sfPluginConfiguration */ public function initialize() { diff --git a/lib/config/sfProjectConfiguration.class.php b/lib/config/sfProjectConfiguration.class.php index 0f8c12fed..d8f21c897 100644 --- a/lib/config/sfProjectConfiguration.class.php +++ b/lib/config/sfProjectConfiguration.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -23,51 +24,51 @@ class sfProjectConfiguration /** @var string */ protected $symfonyLibDir; - /** @var sfEventDispatcher */ + /** @var \sfEventDispatcher */ protected $dispatcher; /** @var array */ - protected $plugins = array(); + protected $plugins = []; /** @var array */ - protected $pluginPaths = array(); + protected $pluginPaths = []; /** @var array */ - protected $overriddenPluginPaths = array(); + protected $overriddenPluginPaths = []; /** @var sfPluginConfiguration[] */ - protected $pluginConfigurations = array(); + protected $pluginConfigurations = []; /** @var bool */ protected $pluginsLoaded = false; - /** @var sfApplicationConfiguration */ + /** @var \sfApplicationConfiguration */ protected static $active; /** * Constructor. * - * @param string $rootDir The project root directory - * @param sfEventDispatcher $dispatcher The event dispatcher + * @param string $rootDir The project root directory + * @param \sfEventDispatcher $dispatcher The event dispatcher */ - public function __construct($rootDir = null, sfEventDispatcher $dispatcher = null) + public function __construct($rootDir = null, \sfEventDispatcher $dispatcher = null) { - if (null === self::$active || $this instanceof sfApplicationConfiguration) { + if (null === self::$active || $this instanceof \sfApplicationConfiguration) { self::$active = $this; } $this->rootDir = null === $rootDir ? static::guessRootDir() : realpath($rootDir); $this->symfonyLibDir = realpath(__DIR__.'/..'); - $this->dispatcher = null === $dispatcher ? new sfEventDispatcher() : $dispatcher; + $this->dispatcher = null === $dispatcher ? new \sfEventDispatcher() : $dispatcher; ini_set('magic_quotes_runtime', 'off'); - sfConfig::set('sf_symfony_lib_dir', $this->symfonyLibDir); + \sfConfig::set('sf_symfony_lib_dir', $this->symfonyLibDir); $this->setRootDir($this->rootDir); // provide forms the dispatcher - sfFormSymfony::setEventDispatcher($this->dispatcher); + \sfFormSymfony::setEventDispatcher($this->dispatcher); $this->setup(); @@ -83,13 +84,13 @@ public function __construct($rootDir = null, sfEventDispatcher $dispatcher = nul * * @return mixed The returned value of the called method * - * @throws sfException + * @throws \sfException */ public function __call($method, $arguments) { - $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'configuration.method_not_found', array('method' => $method, 'arguments' => $arguments))); + $event = $this->dispatcher->notifyUntil(new \sfEvent($this, 'configuration.method_not_found', ['method' => $method, 'arguments' => $arguments])); if (!$event->isProcessed()) { - throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); + throw new \sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); } return $event->getReturnValue(); @@ -119,7 +120,7 @@ public function loadPlugins() require_once $file; $configuration = new $class($this, $path, $plugin); } else { - $configuration = new sfPluginConfigurationGeneric($this, $path, $plugin); + $configuration = new \sfPluginConfigurationGeneric($this, $path, $plugin); } $this->pluginConfigurations[$plugin] = $configuration; @@ -146,7 +147,7 @@ public function setRootDir($rootDir) { $this->rootDir = $rootDir; - sfConfig::add(array( + \sfConfig::add([ 'sf_root_dir' => $rootDir, // global directory structure @@ -157,7 +158,7 @@ public function setRootDir($rootDir) 'sf_config_dir' => $rootDir.DIRECTORY_SEPARATOR.'config', 'sf_test_dir' => $rootDir.DIRECTORY_SEPARATOR.'test', 'sf_plugins_dir' => $rootDir.DIRECTORY_SEPARATOR.'plugins', - )); + ]); $this->setWebDir($rootDir.DIRECTORY_SEPARATOR.'web'); $this->setCacheDir($rootDir.DIRECTORY_SEPARATOR.'cache'); @@ -180,7 +181,7 @@ public function getRootDir() */ public function setCacheDir($cacheDir) { - sfConfig::set('sf_cache_dir', $cacheDir); + \sfConfig::set('sf_cache_dir', $cacheDir); } /** @@ -190,7 +191,7 @@ public function setCacheDir($cacheDir) */ public function setLogDir($logDir) { - sfConfig::set('sf_log_dir', $logDir); + \sfConfig::set('sf_log_dir', $logDir); } /** @@ -200,11 +201,11 @@ public function setLogDir($logDir) */ public function setWebDir($webDir) { - sfConfig::add(array( + \sfConfig::add([ 'sf_web_dir' => $webDir, 'sf_upload_dir_name' => $uploadDirName = 'uploads', 'sf_upload_dir' => $webDir.DIRECTORY_SEPARATOR.$uploadDirName, - )); + ]); } /** @@ -217,7 +218,7 @@ public function getModelDirs() { return array_merge( $this->getPluginSubPaths('/lib/model'), // plugins - array(sfConfig::get('sf_lib_dir').'/model') // project + [\sfConfig::get('sf_lib_dir').'/model'] // project ); } @@ -232,9 +233,9 @@ public function getModelDirs() public function getGeneratorTemplateDirs($class, $theme) { return array_merge( - array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/template'), // project + [\sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/template'], // project $this->getPluginSubPaths('/data/generator/'.$class.'/'.$theme.'/template'), // plugins - array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/default/template'), // project (default theme) + [\sfConfig::get('sf_data_dir').'/generator/'.$class.'/default/template'], // project (default theme) $this->getPluginSubPaths('/data/generator/'.$class.'/default/template') // plugins (default theme) ); } @@ -250,9 +251,9 @@ public function getGeneratorTemplateDirs($class, $theme) public function getGeneratorSkeletonDirs($class, $theme) { return array_merge( - array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/skeleton'), // project + [\sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/skeleton'], // project $this->getPluginSubPaths('/data/generator/'.$class.'/'.$theme.'/skeleton'), // plugins - array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/default/skeleton'), // project (default theme) + [\sfConfig::get('sf_data_dir').'/generator/'.$class.'/default/skeleton'], // project (default theme) $this->getPluginSubPaths('/data/generator/'.$class.'/default/skeleton') // plugins (default theme) ); } @@ -266,7 +267,7 @@ public function getGeneratorSkeletonDirs($class, $theme) * * @return string A template path * - * @throws sfException + * @throws \sfException */ public function getGeneratorTemplate($class, $theme, $path) { @@ -277,7 +278,7 @@ public function getGeneratorTemplate($class, $theme, $path) } } - throw new sfException(sprintf('Unable to load "%s" generator template in: %s.', $path, implode(', ', $dirs))); + throw new \sfException(sprintf('Unable to load "%s" generator template in: %s.', $path, implode(', ', $dirs))); } /** @@ -291,9 +292,9 @@ public function getConfigPaths($configPath) { $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath); - $files = array( + $files = [ $this->getSymfonyLibDir().'/config/'.$globalConfigPath, // symfony - ); + ]; foreach ($this->getPluginPaths() as $path) { if (is_file($file = $path.'/'.$globalConfigPath)) { @@ -301,10 +302,10 @@ public function getConfigPaths($configPath) } } - $files = array_merge($files, array( + $files = array_merge($files, [ $this->getRootDir().'/'.$globalConfigPath, // project $this->getRootDir().'/'.$configPath, // project - )); + ]); foreach ($this->getPluginPaths() as $path) { if (is_file($file = $path.'/'.$configPath)) { @@ -312,7 +313,7 @@ public function getConfigPaths($configPath) } } - $configs = array(); + $configs = []; foreach (array_unique($files) as $file) { if (is_readable($file)) { $configs[] = $file; @@ -327,17 +328,17 @@ public function getConfigPaths($configPath) * * @param array $plugins An array of plugin names * - * @throws LogicException If plugins have already been loaded + * @throws \LogicException If plugins have already been loaded */ public function setPlugins(array $plugins) { if ($this->pluginsLoaded) { - throw new LogicException('Plugins have already been loaded.'); + throw new \LogicException('Plugins have already been loaded.'); } $this->plugins = $plugins; - $this->pluginPaths = array(); + $this->pluginPaths = []; } /** @@ -351,7 +352,7 @@ public function enablePlugins($plugins) if (func_num_args() > 1) { $plugins = func_get_args(); } else { - $plugins = array($plugins); + $plugins = [$plugins]; } } @@ -363,27 +364,27 @@ public function enablePlugins($plugins) * * @param array|string $plugins A plugin name or a plugin list * - * @throws LogicException If plugins have already been loaded + * @throws \LogicException If plugins have already been loaded */ public function disablePlugins($plugins) { if ($this->pluginsLoaded) { - throw new LogicException('Plugins have already been loaded.'); + throw new \LogicException('Plugins have already been loaded.'); } if (!is_array($plugins)) { - $plugins = array($plugins); + $plugins = [$plugins]; } foreach ($plugins as $plugin) { if (false !== $pos = array_search($plugin, $this->plugins)) { unset($this->plugins[$pos]); } else { - throw new InvalidArgumentException(sprintf('The plugin "%s" does not exist.', $plugin)); + throw new \InvalidArgumentException(sprintf('The plugin "%s" does not exist.', $plugin)); } } - $this->pluginPaths = array(); + $this->pluginPaths = []; } /** @@ -391,12 +392,12 @@ public function disablePlugins($plugins) * * @param array|string $plugins A plugin name or a plugin list * - * @throws LogicException If plugins have already been loaded + * @throws \LogicException If plugins have already been loaded */ - public function enableAllPluginsExcept($plugins = array()) + public function enableAllPluginsExcept($plugins = []) { if ($this->pluginsLoaded) { - throw new LogicException('Plugins have already been loaded.'); + throw new \LogicException('Plugins have already been loaded.'); } $this->plugins = array_keys($this->getAllPluginPaths()); @@ -429,7 +430,7 @@ public function getPluginSubPaths($subPath = '') return $this->pluginPaths[$subPath]; } - $this->pluginPaths[$subPath] = array(); + $this->pluginPaths[$subPath] = []; $pluginPaths = $this->getPluginPaths(); foreach ($pluginPaths as $pluginPath) { if (is_dir($pluginPath.$subPath)) { @@ -445,19 +446,19 @@ public function getPluginSubPaths($subPath = '') * * @return array the plugin root paths * - * @throws InvalidArgumentException If an enabled plugin does not exist + * @throws \InvalidArgumentException If an enabled plugin does not exist */ public function getPluginPaths() { if (!isset($this->pluginPaths[''])) { $pluginPaths = $this->getAllPluginPaths(); - $this->pluginPaths[''] = array(); + $this->pluginPaths[''] = []; foreach ($this->getPlugins() as $plugin) { if (isset($pluginPaths[$plugin])) { $this->pluginPaths[''][] = $pluginPaths[$plugin]; } else { - throw new InvalidArgumentException(sprintf('The plugin "%s" does not exist.', $plugin)); + throw new \InvalidArgumentException(sprintf('The plugin "%s" does not exist.', $plugin)); } } } @@ -472,15 +473,15 @@ public function getPluginPaths() */ public function getAllPluginPaths() { - $pluginPaths = array(); + $pluginPaths = []; // search for *Plugin directories representing plugins // follow links and do not recurse. No need to exclude VC because they do not end with *Plugin - $finder = sfFinder::type('dir')->maxdepth(0)->ignore_version_control(false)->follow_link()->name('*Plugin'); - $dirs = array( + $finder = \sfFinder::type('dir')->maxdepth(0)->ignore_version_control(false)->follow_link()->name('*Plugin'); + $dirs = [ $this->getSymfonyLibDir().'/plugins', - sfConfig::get('sf_plugins_dir'), - ); + \sfConfig::get('sf_plugins_dir'), + ]; foreach ($finder->in($dirs) as $path) { $pluginPaths[basename($path)] = $path; @@ -513,12 +514,12 @@ public function setPluginPath($plugin, $path) * * @param string $name * - * @return sfPluginConfiguration + * @return \sfPluginConfiguration */ public function getPluginConfiguration($name) { if (!isset($this->pluginConfigurations[$name])) { - throw new InvalidArgumentException(sprintf('There is no configuration object for the "%s" object.', $name)); + throw new \InvalidArgumentException(sprintf('There is no configuration object for the "%s" object.', $name)); } return $this->pluginConfigurations[$name]; @@ -527,7 +528,7 @@ public function getPluginConfiguration($name) /** * Returns the event dispatcher. * - * @return sfEventDispatcher A sfEventDispatcher instance + * @return \sfEventDispatcher A sfEventDispatcher instance */ public function getEventDispatcher() { @@ -547,12 +548,12 @@ public function getSymfonyLibDir() /** * Returns the active configuration. * - * @return sfApplicationConfiguration The current sfProjectConfiguration instance + * @return \sfApplicationConfiguration The current sfProjectConfiguration instance */ public static function getActive() { if (!static::hasActive()) { - throw new RuntimeException('There is no active configuration.'); + throw new \RuntimeException('There is no active configuration.'); } return self::$active; @@ -575,7 +576,7 @@ public static function hasActive() */ public static function guessRootDir() { - $r = new ReflectionClass('ProjectConfiguration'); + $r = new \ReflectionClass('ProjectConfiguration'); return realpath(dirname($r->getFileName()).'/..'); } @@ -583,15 +584,15 @@ public static function guessRootDir() /** * Returns a sfApplicationConfiguration configuration for a given application. * - * @param string $application An application name - * @param string $environment The environment name - * @param bool $debug true to enable debug mode - * @param string $rootDir The project root directory - * @param sfEventDispatcher $dispatcher An event dispatcher + * @param string $application An application name + * @param string $environment The environment name + * @param bool $debug true to enable debug mode + * @param string $rootDir The project root directory + * @param \sfEventDispatcher $dispatcher An event dispatcher * - * @return sfApplicationConfiguration A sfApplicationConfiguration instance + * @return \sfApplicationConfiguration A sfApplicationConfiguration instance */ - public static function getApplicationConfiguration($application, $environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null) + public static function getApplicationConfiguration($application, $environment, $debug, $rootDir = null, \sfEventDispatcher $dispatcher = null) { $class = $application.'Configuration'; @@ -600,7 +601,7 @@ public static function getApplicationConfiguration($application, $environment, $ } if (!is_file($file = $rootDir.'/apps/'.$application.'/config/'.$class.'.class.php')) { - throw new InvalidArgumentException(sprintf('The application "%s" does not exist.', $application)); + throw new \InvalidArgumentException(sprintf('The application "%s" does not exist.', $application)); } require_once $file; diff --git a/lib/config/sfRootConfigHandler.class.php b/lib/config/sfRootConfigHandler.class.php index e4837cae6..d8d120dd0 100644 --- a/lib/config/sfRootConfigHandler.class.php +++ b/lib/config/sfRootConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +17,7 @@ * * @version SVN: $Id$ */ -class sfRootConfigHandler extends sfYamlConfigHandler +class sfRootConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -25,8 +26,8 @@ class sfRootConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { @@ -42,8 +43,8 @@ public function execute($configFiles) } // init our data and includes arrays - $data = array(); - $includes = array(); + $data = []; + $includes = []; // let's do our fancy work foreach ($config as $category => $keys) { @@ -55,7 +56,7 @@ public function execute($configFiles) if (!isset($keys['class'])) { // missing class key - throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $category)); + throw new \sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $category)); } $class = $keys['class']; @@ -63,7 +64,7 @@ public function execute($configFiles) if (isset($keys['file'])) { if (!is_readable($keys['file'])) { // handler file doesn't exist - throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); + throw new \sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); } // append our data @@ -91,7 +92,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfRoutingConfigHandler.class.php b/lib/config/sfRoutingConfigHandler.class.php index ac82d5cc9..c5b30a1c8 100644 --- a/lib/config/sfRoutingConfigHandler.class.php +++ b/lib/config/sfRoutingConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +14,7 @@ * * @version SVN: $Id$ */ -class sfRoutingConfigHandler extends sfYamlConfigHandler +class sfRoutingConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -22,23 +23,23 @@ class sfRoutingConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { $options = $this->getOptions(); unset($options['cache']); - $data = array(); + $data = []; foreach ($this->parse($configFiles) as $name => $routeConfig) { - $r = new ReflectionClass($routeConfig[0]); + $r = new \ReflectionClass($routeConfig[0]); - /** @var sfRoute $route */ + /** @var \sfRoute $route */ $route = $r->newInstanceArgs($routeConfig[1]); - $routes = $route instanceof sfRouteCollection ? $route : array($name => $route); - foreach (sfPatternRouting::flattenRoutes($routes) as $name => $route) { + $routes = $route instanceof \sfRouteCollection ? $route : [$name => $route]; + foreach (\sfPatternRouting::flattenRoutes($routes) as $name => $route) { $route->setDefaultOptions($options); $data[] = sprintf('$this->routes[\'%s\'] = %s;', $name, var_export(serialize($route), true)); } @@ -57,9 +58,9 @@ public function evaluate($configFiles) { $routeDefinitions = $this->parse($configFiles); - $routes = array(); + $routes = []; foreach ($routeDefinitions as $name => $route) { - $r = new ReflectionClass($route[0]); + $r = new \ReflectionClass($route[0]); $routes[$name] = $r->newInstanceArgs($route[1]); } @@ -67,7 +68,7 @@ public function evaluate($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -76,7 +77,7 @@ public static function getConfiguration(array $configFiles) protected function getOptions() { - $config = sfFactoryConfigHandler::getConfiguration(sfContext::getInstance()->getConfiguration()->getConfigPaths('config/factories.yml')); + $config = \sfFactoryConfigHandler::getConfiguration(\sfContext::getInstance()->getConfiguration()->getConfigPaths('config/factories.yml')); return $config['routing']['param']; } @@ -87,24 +88,24 @@ protected function parse($configFiles) $config = static::getConfiguration($configFiles); // collect routes - $routes = array(); + $routes = []; foreach ($config as $name => $params) { if ( (isset($params['type']) && 'collection' == $params['type']) - || (isset($params['class']) && false !== strpos($params['class'], 'Collection')) + || (isset($params['class']) && str_contains($params['class'], 'Collection')) ) { - $options = isset($params['options']) ? $params['options'] : array(); + $options = isset($params['options']) ? $params['options'] : []; $options['name'] = $name; - $options['requirements'] = isset($params['requirements']) ? $params['requirements'] : array(); + $options['requirements'] = isset($params['requirements']) ? $params['requirements'] : []; - $routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRouteCollection', array($options)); + $routes[$name] = [isset($params['class']) ? $params['class'] : 'sfRouteCollection', [$options]]; } else { - $routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRoute', array( + $routes[$name] = [isset($params['class']) ? $params['class'] : 'sfRoute', [ $params['url'] ?: '/', - isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : array()), - isset($params['requirements']) ? $params['requirements'] : array(), - isset($params['options']) ? $params['options'] : array(), - )); + isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : []), + isset($params['requirements']) ? $params['requirements'] : [], + isset($params['options']) ? $params['options'] : [], + ]]; } } diff --git a/lib/config/sfSecurityConfigHandler.class.php b/lib/config/sfSecurityConfigHandler.class.php index dd0b8aa64..fba190960 100644 --- a/lib/config/sfSecurityConfigHandler.class.php +++ b/lib/config/sfSecurityConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfSecurityConfigHandler extends sfYamlConfigHandler +class sfSecurityConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -24,9 +25,9 @@ class sfSecurityConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted - * @throws sfInitializationException If a view.yml key check fails + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted + * @throws \sfInitializationException If a view.yml key check fails */ public function execute($configFiles) { @@ -46,7 +47,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfServiceConfigHandler.class.php b/lib/config/sfServiceConfigHandler.class.php index 2bc86f8d0..27d6215b6 100644 --- a/lib/config/sfServiceConfigHandler.class.php +++ b/lib/config/sfServiceConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfServiceConfigHandler extends sfYamlConfigHandler +class sfServiceConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -26,18 +27,18 @@ class sfServiceConfigHandler extends sfYamlConfigHandler */ public function execute($configFiles) { - $class = sfConfig::get('sf_app').'_'.sfConfig::get('sf_environment').'ServiceContainer'; + $class = \sfConfig::get('sf_app').'_'.\sfConfig::get('sf_environment').'ServiceContainer'; - $serviceContainerBuilder = new sfServiceContainerBuilder(); + $serviceContainerBuilder = new \sfServiceContainerBuilder(); - $loader = new sfServiceContainerLoaderArray($serviceContainerBuilder); + $loader = new \sfServiceContainerLoaderArray($serviceContainerBuilder); $loader->load(static::getConfiguration($configFiles)); - $dumper = new sfServiceContainerDumperPhp($serviceContainerBuilder); - $code = $dumper->dump(array( + $dumper = new \sfServiceContainerDumperPhp($serviceContainerBuilder); + $code = $dumper->dump([ 'class' => $class, 'base_class' => $this->parameterHolder->get('base_class'), - )); + ]); // compile data $retval = sprintf( @@ -58,7 +59,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfSimpleYamlConfigHandler.class.php b/lib/config/sfSimpleYamlConfigHandler.class.php index 827f77e24..836b34d4f 100644 --- a/lib/config/sfSimpleYamlConfigHandler.class.php +++ b/lib/config/sfSimpleYamlConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfSimpleYamlConfigHandler extends sfYamlConfigHandler +class sfSimpleYamlConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -38,7 +39,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { diff --git a/lib/config/sfViewConfigHandler.class.php b/lib/config/sfViewConfigHandler.class.php index 56230c775..d881775da 100644 --- a/lib/config/sfViewConfigHandler.class.php +++ b/lib/config/sfViewConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfViewConfigHandler extends sfYamlConfigHandler +class sfViewConfigHandler extends \sfYamlConfigHandler { /** * Executes this configuration handler. @@ -24,9 +25,9 @@ class sfViewConfigHandler extends sfYamlConfigHandler * * @return string Data to be written to a cache file * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted - * @throws sfInitializationException If a view.yml key check fails + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted + * @throws \sfInitializationException If a view.yml key check fails */ public function execute($configFiles) { @@ -34,7 +35,7 @@ public function execute($configFiles) $this->yamlConfig = static::getConfiguration($configFiles); // init our data array - $data = array(); + $data = []; $data[] = "\$response = \$this->context->getResponse();\n\n"; @@ -104,7 +105,7 @@ public function execute($configFiles) } /** - * @see sfConfigHandler + * @see \sfConfigHandler */ public static function getConfiguration(array $configFiles) { @@ -125,7 +126,7 @@ protected function addComponentSlots($viewName = '') $components = $this->mergeConfigValue('components', $viewName); foreach ($components as $name => $component) { if (!is_array($component) || count($component) < 1) { - $component = array(null, null); + $component = [null, null]; } $data .= " \$this->setComponentSlot('{$name}', '{$component[0]}', '{$component[1]}');\n"; @@ -215,14 +216,14 @@ protected function addLayout($viewName = '') */ protected function addHtmlHead($viewName = '') { - $data = array(); + $data = []; foreach ($this->mergeConfigValue('http_metas', $viewName) as $httpequiv => $content) { $data[] = sprintf(" \$response->addHttpMeta('%s', '%s', false);", $httpequiv, str_replace('\'', '\\\'', $content)); } foreach ($this->mergeConfigValue('metas', $viewName) as $name => $content) { - $data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&(?=\w+;)/', '&', htmlspecialchars((string) $content, ENT_QUOTES, sfConfig::get('sf_charset'))))); + $data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&(?=\w+;)/', '&', htmlspecialchars((string) $content, ENT_QUOTES, \sfConfig::get('sf_charset'))))); } return implode("\n", $data)."\n"; @@ -257,7 +258,7 @@ protected function addHtmlAsset($viewName = '') */ protected function addEscaping($viewName = '') { - $data = array(); + $data = []; $escaping = $this->getConfigValue('escaping', $viewName); @@ -271,16 +272,16 @@ protected function addEscaping($viewName = '') protected static function mergeConfig($config) { // merge javascripts and stylesheets - $config['all']['stylesheets'] = array_merge(isset($config['default']['stylesheets']) && is_array($config['default']['stylesheets']) ? $config['default']['stylesheets'] : array(), isset($config['all']['stylesheets']) && is_array($config['all']['stylesheets']) ? $config['all']['stylesheets'] : array()); + $config['all']['stylesheets'] = array_merge(isset($config['default']['stylesheets']) && is_array($config['default']['stylesheets']) ? $config['default']['stylesheets'] : [], isset($config['all']['stylesheets']) && is_array($config['all']['stylesheets']) ? $config['all']['stylesheets'] : []); unset($config['default']['stylesheets']); - $config['all']['javascripts'] = array_merge(isset($config['default']['javascripts']) && is_array($config['default']['javascripts']) ? $config['default']['javascripts'] : array(), isset($config['all']['javascripts']) && is_array($config['all']['javascripts']) ? $config['all']['javascripts'] : array()); + $config['all']['javascripts'] = array_merge(isset($config['default']['javascripts']) && is_array($config['default']['javascripts']) ? $config['default']['javascripts'] : [], isset($config['all']['javascripts']) && is_array($config['all']['javascripts']) ? $config['all']['javascripts'] : []); unset($config['default']['javascripts']); // merge default and all - $config['all'] = sfToolkit::arrayDeepMerge( - isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), - isset($config['all']) && is_array($config['all']) ? $config['all'] : array() + $config['all'] = \sfToolkit::arrayDeepMerge( + isset($config['default']) && is_array($config['default']) ? $config['default'] : [], + isset($config['all']) && is_array($config['all']) ? $config['all'] : [] ); unset($config['default']); @@ -298,7 +299,7 @@ protected static function mergeConfig($config) */ private function addAssets($type, $assets) { - $tmp = array(); + $tmp = []; foreach ((array) $assets as $asset) { $position = ''; if (is_array($asset)) { @@ -311,11 +312,11 @@ private function addAssets($type, $assets) } } else { $key = $asset; - $options = array(); + $options = []; } if ('-*' == $key) { - $tmp = array(); + $tmp = []; } elseif ('-' == $key[0]) { unset($tmp[substr($key, 1)]); } else { diff --git a/lib/config/sfYamlConfigHandler.class.php b/lib/config/sfYamlConfigHandler.class.php index c2993a80f..95ff9b4f2 100644 --- a/lib/config/sfYamlConfigHandler.class.php +++ b/lib/config/sfYamlConfigHandler.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +17,7 @@ * * @version SVN: $Id$ */ -abstract class sfYamlConfigHandler extends sfConfigHandler +abstract class sfYamlConfigHandler extends \sfConfigHandler { /** @var array */ protected $yamlConfig; @@ -30,17 +31,17 @@ abstract class sfYamlConfigHandler extends sfConfigHandler */ public static function parseYamls($configFiles) { - $config = array(); + $config = []; foreach ($configFiles as $configFile) { // the first level is an environment and its value must be an array - $values = array(); + $values = []; foreach (static::parseYaml($configFile) as $env => $value) { if (null !== $value) { $values[$env] = $value; } } - $config = sfToolkit::arrayDeepMerge($config, $values); + $config = \sfToolkit::arrayDeepMerge($config, $values); } return $config; @@ -53,32 +54,32 @@ public static function parseYamls($configFiles) * * @return array|string A parsed .yml configuration * - * @throws sfConfigurationException If a requested configuration file does not exist or is not readable - * @throws sfParseException If a requested configuration file is improperly formatted + * @throws \sfConfigurationException If a requested configuration file does not exist or is not readable + * @throws \sfParseException If a requested configuration file is improperly formatted */ public static function parseYaml($configFile) { if (!is_readable($configFile)) { // can't read the configuration - throw new sfConfigurationException(sprintf('Configuration file "%s" does not exist or is not readable.', $configFile)); + throw new \sfConfigurationException(sprintf('Configuration file "%s" does not exist or is not readable.', $configFile)); } // parse our config - $config = sfYaml::load($configFile, sfConfig::get('sf_charset', 'UTF-8')); + $config = \sfYaml::load($configFile, \sfConfig::get('sf_charset', 'UTF-8')); if (false === $config) { // configuration couldn't be parsed - throw new sfParseException(sprintf('Configuration file "%s" could not be parsed', $configFile)); + throw new \sfParseException(sprintf('Configuration file "%s" could not be parsed', $configFile)); } - return null === $config ? array() : $config; + return null === $config ? [] : $config; } public static function flattenConfiguration($config) { - $config['all'] = sfToolkit::arrayDeepMerge( - isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), - isset($config['all']) && is_array($config['all']) ? $config['all'] : array() + $config['all'] = \sfToolkit::arrayDeepMerge( + isset($config['default']) && is_array($config['default']) ? $config['default'] : [], + isset($config['all']) && is_array($config['all']) ? $config['all'] : [] ); unset($config['default']); @@ -95,10 +96,10 @@ public static function flattenConfiguration($config) */ public static function flattenConfigurationWithEnvironment($config) { - return sfToolkit::arrayDeepMerge( - isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), - isset($config['all']) && is_array($config['all']) ? $config['all'] : array(), - isset($config[sfConfig::get('sf_environment')]) && is_array($config[sfConfig::get('sf_environment')]) ? $config[sfConfig::get('sf_environment')] : array() + return \sfToolkit::arrayDeepMerge( + isset($config['default']) && is_array($config['default']) ? $config['default'] : [], + isset($config['all']) && is_array($config['all']) ? $config['all'] : [], + isset($config[\sfConfig::get('sf_environment')]) && is_array($config[\sfConfig::get('sf_environment')]) ? $config[\sfConfig::get('sf_environment')] : [] ); } @@ -112,7 +113,7 @@ public static function flattenConfigurationWithEnvironment($config) */ protected function mergeConfigValue($keyName, $category) { - $values = array(); + $values = []; if (isset($this->yamlConfig['all'][$keyName]) && is_array($this->yamlConfig['all'][$keyName])) { $values = $this->yamlConfig['all'][$keyName]; diff --git a/lib/controller/default/actions/actions.class.php b/lib/controller/default/actions/actions.class.php index 5dfa30554..7e5866ba0 100644 --- a/lib/controller/default/actions/actions.class.php +++ b/lib/controller/default/actions/actions.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class defaultActions extends sfActions +class defaultActions extends \sfActions { /** * Congratulations page for creating an application. diff --git a/lib/controller/default/templates/defaultLayout.php b/lib/controller/default/templates/defaultLayout.php index 1898f65a8..8aa94057f 100644 --- a/lib/controller/default/templates/defaultLayout.php +++ b/lib/controller/default/templates/defaultLayout.php @@ -18,7 +18,7 @@
- 'symfony PHP Framework', 'class' => 'sfTLogo', 'size' => '186x39')), 'http://www.symfony-project.org/'); ?> + 'symfony PHP Framework', 'class' => 'sfTLogo', 'size' => '186x39']), 'http://www.symfony-project.org/'); ?>
diff --git a/lib/controller/default/templates/disabledSuccess.php b/lib/controller/default/templates/disabledSuccess.php index 1f76fbff2..d52ff435b 100644 --- a/lib/controller/default/templates/disabledSuccess.php +++ b/lib/controller/default/templates/disabledSuccess.php @@ -1,7 +1,7 @@
- 'module disabled', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'module disabled', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

This Module is Unavailable

This module has been disabled.
diff --git a/lib/controller/default/templates/error404Success.php b/lib/controller/default/templates/error404Success.php index 919af7520..9a65929a1 100644 --- a/lib/controller/default/templates/error404Success.php +++ b/lib/controller/default/templates/error404Success.php @@ -1,7 +1,7 @@
- 'page not found', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'page not found', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

Oops! Page Not Found

The server returned a 404 response.
diff --git a/lib/controller/default/templates/indexSuccess.php b/lib/controller/default/templates/indexSuccess.php index b50638f39..9d887fb63 100644 --- a/lib/controller/default/templates/indexSuccess.php +++ b/lib/controller/default/templates/indexSuccess.php @@ -1,7 +1,7 @@
- 'ok', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'ok', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

Symfony Project Created

Congratulations! You have successfully created your symfony project.
diff --git a/lib/controller/default/templates/loginSuccess.php b/lib/controller/default/templates/loginSuccess.php index f1b5c7e0e..5efb66c0e 100644 --- a/lib/controller/default/templates/loginSuccess.php +++ b/lib/controller/default/templates/loginSuccess.php @@ -1,7 +1,7 @@
- 'login required', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'login required', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

Login Required

This page is not public.
@@ -14,7 +14,7 @@
What's Next
diff --git a/lib/controller/default/templates/moduleSuccess.php b/lib/controller/default/templates/moduleSuccess.php index b4dc0bdcd..0e0c92180 100644 --- a/lib/controller/default/templates/moduleSuccess.php +++ b/lib/controller/default/templates/moduleSuccess.php @@ -1,7 +1,7 @@
- 'module created', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'module created', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

Module "get('module'); ?>" created

Congratulations! You have successfully created a symfony module.
@@ -14,7 +14,7 @@
What's next
    -
  • Browse to the apps/getConfiguration()->getApplication(); ?>/modules/get('module'); ?>/ directory
  • +
  • Browse to the apps/getConfiguration()->getApplication(); ?>/modules/get('module'); ?>/ directory
  • In actions/actions.class.php, edit the executeIndex() method and remove the final forward
  • Customize the templates/indexSuccess.php template
  • diff --git a/lib/controller/default/templates/secureSuccess.php b/lib/controller/default/templates/secureSuccess.php index 3151ff665..912963b26 100644 --- a/lib/controller/default/templates/secureSuccess.php +++ b/lib/controller/default/templates/secureSuccess.php @@ -1,7 +1,7 @@
    - 'credentials required', 'class' => 'sfTMessageIcon', 'size' => '48x48')); ?> + 'credentials required', 'class' => 'sfTMessageIcon', 'size' => '48x48']); ?>

    Credentials Required

    This page is in a restricted area.
    diff --git a/lib/controller/sfController.class.php b/lib/controller/sfController.class.php index c654d3e38..eb8c097fb 100644 --- a/lib/controller/sfController.class.php +++ b/lib/controller/sfController.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,17 +19,17 @@ */ abstract class sfController { - /** @var sfContext */ + /** @var \sfContext */ protected $context; - /** @var sfEventDispatcher */ + /** @var \sfEventDispatcher */ protected $dispatcher; /** @var string[] */ - protected $controllerClasses = array(); + protected $controllerClasses = []; /** @var int */ - protected $renderMode = sfView::RENDER_CLIENT; + protected $renderMode = \sfView::RENDER_CLIENT; /** @var int */ protected $maxForwards = 5; @@ -39,7 +39,7 @@ abstract class sfController * * @see initialize() * - * @param sfContext $context A sfContext implementation instance + * @param \sfContext $context A sfContext implementation instance */ public function __construct($context) { @@ -54,13 +54,13 @@ public function __construct($context) * * @return mixed The returned value of the called method * - * @throws sfException + * @throws \sfException */ public function __call($method, $arguments) { - $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'controller.method_not_found', array('method' => $method, 'arguments' => $arguments))); + $event = $this->dispatcher->notifyUntil(new \sfEvent($this, 'controller.method_not_found', ['method' => $method, 'arguments' => $arguments])); if (!$event->isProcessed()) { - throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); + throw new \sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method)); } return $event->getReturnValue(); @@ -69,7 +69,7 @@ public function __call($method, $arguments) /** * Initializes this controller. * - * @param sfContext $context A sfContext implementation instance + * @param \sfContext $context A sfContext implementation instance */ public function initialize($context) { @@ -109,10 +109,10 @@ public function actionExists($moduleName, $actionName) * @param string $moduleName A module name * @param string $actionName An action name * - * @throws sfConfigurationException If an invalid configuration setting has been found - * @throws sfForwardException If an error occurs while forwarding the request - * @throws sfError404Exception If the action not exist - * @throws sfInitializationException If the action could not be initialized + * @throws \sfConfigurationException If an invalid configuration setting has been found + * @throws \sfForwardException If an error occurs while forwarding the request + * @throws \sfError404Exception If the action not exist + * @throws \sfInitializationException If the action could not be initialized */ public function forward($moduleName, $actionName) { @@ -122,7 +122,7 @@ public function forward($moduleName, $actionName) if ($this->getActionStack()->getSize() >= $this->maxForwards) { // let's kill this party before it turns into cpu cycle hell - throw new sfForwardException('Too many forwards have been detected for this request.'); + throw new \sfForwardException('Too many forwards have been detected for this request.'); } // check for a module generator config file @@ -130,11 +130,11 @@ public function forward($moduleName, $actionName) if (!$this->actionExists($moduleName, $actionName)) { // the requested action doesn't exist - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" does not exist', $moduleName, $actionName)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Action "%s/%s" does not exist', $moduleName, $actionName)])); } - throw new sfError404Exception(sprintf('Action "%s/%s" does not exist.', $moduleName, $actionName)); + throw new \sfError404Exception(sprintf('Action "%s/%s" does not exist.', $moduleName, $actionName)); } // create an instance of the action @@ -144,43 +144,43 @@ public function forward($moduleName, $actionName) $this->getActionStack()->addEntry($moduleName, $actionName, $actionInstance); // include module configuration - $viewClass = sfConfig::get('mod_'.strtolower($moduleName).'_view_class', false); + $viewClass = \sfConfig::get('mod_'.strtolower($moduleName).'_view_class', false); require $this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/config/module.yml'); if (false !== $viewClass) { - sfConfig::set('mod_'.strtolower($moduleName).'_view_class', $viewClass); + \sfConfig::set('mod_'.strtolower($moduleName).'_view_class', $viewClass); } // module enabled? - if (sfConfig::get('mod_'.strtolower($moduleName).'_enabled')) { + if (\sfConfig::get('mod_'.strtolower($moduleName).'_enabled')) { // check for a module config.php - $moduleConfig = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/config/config.php'; + $moduleConfig = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/config/config.php'; if (is_readable($moduleConfig)) { require_once $moduleConfig; } // create a new filter chain - $filterChain = new sfFilterChain(); + $filterChain = new \sfFilterChain(); $filterChain->loadConfiguration($actionInstance); - $this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName))); + $this->context->getEventDispatcher()->notify(new \sfEvent($this, 'controller.change_action', ['module' => $moduleName, 'action' => $actionName])); - if ($moduleName == sfConfig::get('sf_error_404_module') && $actionName == sfConfig::get('sf_error_404_action')) { + if ($moduleName == \sfConfig::get('sf_error_404_module') && $actionName == \sfConfig::get('sf_error_404_action')) { $this->context->getResponse()->setStatusCode(404); $this->context->getResponse()->setHttpHeader('Status', '404 Not Found'); - $this->dispatcher->notify(new sfEvent($this, 'controller.page_not_found', array('module' => $moduleName, 'action' => $actionName))); + $this->dispatcher->notify(new \sfEvent($this, 'controller.page_not_found', ['module' => $moduleName, 'action' => $actionName])); } // process the filter chain $filterChain->execute(); } else { - $moduleName = sfConfig::get('sf_module_disabled_module'); - $actionName = sfConfig::get('sf_module_disabled_action'); + $moduleName = \sfConfig::get('sf_module_disabled_module'); + $actionName = \sfConfig::get('sf_module_disabled_action'); if (!$this->actionExists($moduleName, $actionName)) { // cannot find mod disabled module/action - throw new sfConfigurationException(sprintf('Invalid configuration settings: [sf_module_disabled_module] "%s", [sf_module_disabled_action] "%s".', $moduleName, $actionName)); + throw new \sfConfigurationException(sprintf('Invalid configuration settings: [sf_module_disabled_module] "%s", [sf_module_disabled_action] "%s".', $moduleName, $actionName)); } $this->forward($moduleName, $actionName); @@ -193,7 +193,7 @@ public function forward($moduleName, $actionName) * @param string $moduleName A module name * @param string $actionName An action name * - * @return sfAction An sfAction implementation instance, if the action exists, otherwise null + * @return \sfAction An sfAction implementation instance, if the action exists, otherwise null */ public function getAction($moduleName, $actionName) { @@ -206,7 +206,7 @@ public function getAction($moduleName, $actionName) * @param string $moduleName A module name * @param string $componentName A component name * - * @return sfComponent A sfComponent implementation instance, if the component exists, otherwise null + * @return \sfComponent A sfComponent implementation instance, if the component exists, otherwise null */ public function getComponent($moduleName, $componentName) { @@ -216,7 +216,7 @@ public function getComponent($moduleName, $componentName) /** * Retrieves the action stack. * - * @return sfActionStack An sfActionStack instance, if the action stack is enabled, otherwise null + * @return \sfActionStack An sfActionStack instance, if the action stack is enabled, otherwise null */ public function getActionStack() { @@ -242,12 +242,12 @@ public function getRenderMode() * @param string $actionName An action name * @param string $viewName A view name * - * @return sfView A sfView implementation instance, if the view exists, otherwise null + * @return \sfView A sfView implementation instance, if the view exists, otherwise null */ public function getView($moduleName, $actionName, $viewName) { // user view exists? - $file = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/view/'.$actionName.$viewName.'View.class.php'; + $file = \sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/view/'.$actionName.$viewName.'View.class.php'; if (is_readable($file)) { require_once $file; @@ -262,7 +262,7 @@ public function getView($moduleName, $actionName, $viewName) } } else { // view class (as configured in module.yml or defined in action) - $class = sfConfig::get('mod_'.strtolower($moduleName).'_view_class', 'sfPHP').'View'; + $class = \sfConfig::get('mod_'.strtolower($moduleName).'_view_class', 'sfPHP').'View'; } return new $class($this->context, $moduleName, $actionName, $viewName); @@ -277,20 +277,20 @@ public function getView($moduleName, $actionName, $viewName) * * @return string The generated content * - * @throws Exception - * @throws sfException + * @throws \Exception + * @throws \sfException */ public function getPresentationFor($module, $action, $viewName = null) { - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Get presentation for action "%s/%s" (view class: "%s")', $module, $action, $viewName)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Get presentation for action "%s/%s" (view class: "%s")', $module, $action, $viewName)])); } // get original render mode $renderMode = $this->getRenderMode(); // set render mode to var - $this->setRenderMode(sfView::RENDER_VAR); + $this->setRenderMode(\sfView::RENDER_VAR); // grab the action stack $actionStack = $this->getActionStack(); @@ -300,20 +300,20 @@ public function getPresentationFor($module, $action, $viewName = null) // set viewName if needed if ($viewName) { - $currentViewName = sfConfig::get('mod_'.strtolower($module).'_view_class'); - sfConfig::set('mod_'.strtolower($module).'_view_class', $viewName); + $currentViewName = \sfConfig::get('mod_'.strtolower($module).'_view_class'); + \sfConfig::set('mod_'.strtolower($module).'_view_class', $viewName); } try { // forward to the action $this->forward($module, $action); - } catch (Exception $e) { + } catch (\Exception $e) { // put render mode back $this->setRenderMode($renderMode); // remove viewName if ($viewName) { - sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName); + \sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName); } throw $e; @@ -333,17 +333,17 @@ public function getPresentationFor($module, $action, $viewName = null) while ($nb-- > 0) { $actionEntry = $actionStack->popEntry(); - if ($actionEntry->getModuleName() == sfConfig::get('sf_login_module') && $actionEntry->getActionName() == sfConfig::get('sf_login_action')) { - throw new sfException('Your action is secured, but the user is not authenticated.'); + if ($actionEntry->getModuleName() == \sfConfig::get('sf_login_module') && $actionEntry->getActionName() == \sfConfig::get('sf_login_action')) { + throw new \sfException('Your action is secured, but the user is not authenticated.'); } - if ($actionEntry->getModuleName() == sfConfig::get('sf_secure_module') && $actionEntry->getActionName() == sfConfig::get('sf_secure_action')) { - throw new sfException('Your action is secured, but the user does not have access.'); + if ($actionEntry->getModuleName() == \sfConfig::get('sf_secure_module') && $actionEntry->getActionName() == \sfConfig::get('sf_secure_action')) { + throw new \sfException('Your action is secured, but the user does not have access.'); } } // remove viewName if ($viewName) { - sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName); + \sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName); } return $presentation; @@ -357,18 +357,18 @@ public function getPresentationFor($module, $action, $viewName = null) * - sfView::RENDER_VAR * - sfView::RENDER_NONE * - * @throws sfRenderException If an invalid render mode has been set + * @throws \sfRenderException If an invalid render mode has been set */ public function setRenderMode($mode) { - if (sfView::RENDER_CLIENT == $mode || sfView::RENDER_VAR == $mode || sfView::RENDER_NONE == $mode) { + if (\sfView::RENDER_CLIENT == $mode || \sfView::RENDER_VAR == $mode || \sfView::RENDER_NONE == $mode) { $this->renderMode = $mode; return; } // invalid rendering mode type - throw new sfRenderException(sprintf('Invalid rendering mode: %s.', $mode)); + throw new \sfRenderException(sprintf('Invalid rendering mode: %s.', $mode)); } /** @@ -392,16 +392,16 @@ public function inCLI() * * @return bool true if the controller exists, false otherwise * - * @throws sfConfigurationException thrown if the module is not enabled - * @throws sfControllerException thrown if the controller doesn't exist and the $throwExceptions parameter is set to true + * @throws \sfConfigurationException thrown if the module is not enabled + * @throws \sfControllerException thrown if the controller doesn't exist and the $throwExceptions parameter is set to true */ protected function controllerExists($moduleName, $controllerName, $extension, $throwExceptions) { $dirs = $this->context->getConfiguration()->getControllerDirs($moduleName); foreach ($dirs as $dir => $checkEnabled) { // plugin module enabled? - if ($checkEnabled && !in_array($moduleName, sfConfig::get('sf_enabled_modules')) && is_readable($dir)) { - throw new sfConfigurationException(sprintf('The module "%s" is not enabled.', $moduleName)); + if ($checkEnabled && !in_array($moduleName, \sfConfig::get('sf_enabled_modules')) && is_readable($dir)) { + throw new \sfConfigurationException(sprintf('The module "%s" is not enabled.', $moduleName)); } // check for a module generator config file @@ -427,7 +427,7 @@ protected function controllerExists($moduleName, $controllerName, $extension, $t if (!class_exists($moduleName.$classSuffix.'s', false)) { if ($throwExceptions) { - throw new sfControllerException(sprintf('There is no "%s" class in your action file "%s".', $moduleName.$classSuffix.'s', $module_file)); + throw new \sfControllerException(sprintf('There is no "%s" class in your action file "%s".', $moduleName.$classSuffix.'s', $module_file)); } return false; @@ -436,7 +436,7 @@ protected function controllerExists($moduleName, $controllerName, $extension, $t // action is defined in this class? if (!in_array('execute'.ucfirst($controllerName), get_class_methods($moduleName.$classSuffix.'s'))) { if ($throwExceptions) { - throw new sfControllerException(sprintf('There is no "%s" method in your action class "%s".', 'execute'.ucfirst($controllerName), $moduleName.$classSuffix.'s')); + throw new \sfControllerException(sprintf('There is no "%s" method in your action class "%s".', 'execute'.ucfirst($controllerName), $moduleName.$classSuffix.'s')); } return false; @@ -449,10 +449,10 @@ protected function controllerExists($moduleName, $controllerName, $extension, $t } // send an exception if debug - if ($throwExceptions && sfConfig::get('sf_debug')) { - $dirs = array_map(array('sfDebug', 'shortenFilePath'), array_keys($dirs)); + if ($throwExceptions && \sfConfig::get('sf_debug')) { + $dirs = array_map(['sfDebug', 'shortenFilePath'], array_keys($dirs)); - throw new sfControllerException(sprintf('Controller "%s/%s" does not exist in: %s.', $moduleName, $controllerName, implode(', ', $dirs))); + throw new \sfControllerException(sprintf('Controller "%s/%s" does not exist in: %s.', $moduleName, $controllerName, implode(', ', $dirs))); } return false; @@ -465,7 +465,7 @@ protected function controllerExists($moduleName, $controllerName, $extension, $t * @param string $controllerName A component name * @param string $extension Either 'action' or 'component' depending on the type of controller to look for * - * @return sfAction A controller implementation instance, if the controller exists, otherwise null + * @return \sfAction A controller implementation instance, if the controller exists, otherwise null * * @see getComponent(), getAction() */ diff --git a/lib/controller/sfFrontWebController.class.php b/lib/controller/sfFrontWebController.class.php index 5e2becdd5..667ca5de5 100644 --- a/lib/controller/sfFrontWebController.class.php +++ b/lib/controller/sfFrontWebController.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,7 +19,7 @@ * * @version SVN: $Id$ */ -class sfFrontWebController extends sfWebController +class sfFrontWebController extends \sfWebController { /** * Dispatches a request. @@ -30,24 +30,24 @@ public function dispatch() { try { // reinitialize filters (needed for unit and functional tests) - sfFilter::$filterCalled = array(); + \sfFilter::$filterCalled = []; // determine our module and action - /** @var sfWebRequest $request */ + /** @var \sfWebRequest $request */ $request = $this->context->getRequest(); $moduleName = $request->getParameter('module'); $actionName = $request->getParameter('action'); if (empty($moduleName) || empty($actionName)) { - throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName)); + throw new \sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName)); } // make the first request $this->forward($moduleName, $actionName); - } catch (sfException $e) { + } catch (\sfException $e) { $e->printStackTrace(); - } catch (Exception $e) { - sfException::createFromException($e)->printStackTrace(); + } catch (\Exception $e) { + \sfException::createFromException($e)->printStackTrace(); } } } diff --git a/lib/controller/sfWebController.class.php b/lib/controller/sfWebController.class.php index b4ca30b67..297a1179c 100644 --- a/lib/controller/sfWebController.class.php +++ b/lib/controller/sfWebController.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * * @version SVN: $Id$ */ -abstract class sfWebController extends sfController +abstract class sfWebController extends \sfController { /** * Generates an URL from an array of parameters. @@ -27,7 +27,7 @@ abstract class sfWebController extends sfController * * @return string A URL to a symfony resource */ - public function genUrl($parameters = array(), $absolute = false) + public function genUrl($parameters = [], $absolute = false) { $route = ''; $fragment = ''; @@ -39,7 +39,7 @@ public function genUrl($parameters = array(), $absolute = false) } // relative URL? - if (0 === strpos($parameters, '/')) { + if (str_starts_with($parameters, '/')) { return $parameters; } @@ -78,13 +78,13 @@ public function genUrl($parameters = array(), $absolute = false) * * @return array An array of parameters * - * @throws sfParseException + * @throws \sfParseException */ public function convertUrlStringToParameters($url) { $givenUrl = $url; - $params = array(); + $params = []; $queryString = ''; $route = ''; @@ -111,12 +111,12 @@ public function convertUrlStringToParameters($url) // routeName? if ($url && '@' == $url[0]) { $route = substr($url, 1); - } elseif (false !== strpos($url, '/')) { + } elseif (str_contains($url, '/')) { list($params['module'], $params['action']) = explode('/', $url); } elseif (!$queryString) { $route = $givenUrl; } else { - throw new InvalidArgumentException(sprintf('An internal URI must contain a module and an action (module/action) ("%s" given).', $givenUrl)); + throw new \InvalidArgumentException(sprintf('An internal URI must contain a module and an action (module/action) ("%s" given).', $givenUrl)); } // split the query string @@ -135,11 +135,11 @@ public function convertUrlStringToParameters($url) // check that all string is matched if (!$matched) { - throw new sfParseException(sprintf('Unable to parse query string "%s".', $queryString)); + throw new \sfParseException(sprintf('Unable to parse query string "%s".', $queryString)); } } - return array($route, $params); + return [$route, $params]; } /** @@ -150,24 +150,24 @@ public function convertUrlStringToParameters($url) * browsers that do not support HTTP headers * @param int $statusCode The status code * - * @throws InvalidArgumentException If the url argument is null or an empty string + * @throws \InvalidArgumentException If the url argument is null or an empty string */ public function redirect($url, $delay = 0, $statusCode = 302) { if (empty($url)) { - throw new InvalidArgumentException('Cannot redirect to an empty URL.'); + throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); } $url = $this->genUrl($url, true); // see #8083 $url = str_replace('&', '&', $url); - if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Redirect to "%s"', $url)))); + if (\sfConfig::get('sf_logging_enabled')) { + $this->dispatcher->notify(new \sfEvent($this, 'application.log', [sprintf('Redirect to "%s"', $url)])); } // redirect - /** @var sfWebResponse $response */ + /** @var \sfWebResponse $response */ $response = $this->context->getResponse(); $response->clearHttpHeaders(); $response->setStatusCode($statusCode); @@ -178,7 +178,7 @@ public function redirect($url, $delay = 0, $statusCode = 302) $response->setHttpHeader('Location', $url); } - $response->setContent(sprintf('', $delay, htmlspecialchars($url, ENT_QUOTES, sfConfig::get('sf_charset')))); + $response->setContent(sprintf('', $delay, htmlspecialchars($url, ENT_QUOTES, \sfConfig::get('sf_charset')))); $response->send(); } } diff --git a/lib/database/sfDatabase.class.php b/lib/database/sfDatabase.class.php index 3ff9862b8..bc4352543 100644 --- a/lib/database/sfDatabase.class.php +++ b/lib/database/sfDatabase.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -20,7 +20,7 @@ */ abstract class sfDatabase { - /** @var sfParameterHolder */ + /** @var \sfParameterHolder */ protected $parameterHolder; /** @var PDO|resource */ @@ -36,7 +36,7 @@ abstract class sfDatabase * * @param array $parameters An associative array of initialization parameters */ - public function __construct($parameters = array()) + public function __construct($parameters = []) { $this->initialize($parameters); } @@ -46,18 +46,18 @@ public function __construct($parameters = array()) * * @param array $parameters An associative array of initialization parameters * - * @throws sfInitializationException If an error occurs while initializing this sfDatabase object + * @throws \sfInitializationException If an error occurs while initializing this sfDatabase object */ - public function initialize($parameters = array()) + public function initialize($parameters = []) { - $this->parameterHolder = new sfParameterHolder(); + $this->parameterHolder = new \sfParameterHolder(); $this->parameterHolder->add($parameters); } /** * Connects to the database. * - * @throws sfDatabaseException If a connection could not be created + * @throws \sfDatabaseException If a connection could not be created */ abstract public function connect(); @@ -69,7 +69,7 @@ abstract public function connect(); * * @return mixed A database connection * - * @throws sfDatabaseException If a connection could not be retrieved + * @throws \sfDatabaseException If a connection could not be retrieved */ public function getConnection() { @@ -85,7 +85,7 @@ public function getConnection() * * @return mixed A database resource * - * @throws sfDatabaseException If a resource could not be retrieved + * @throws \sfDatabaseException If a resource could not be retrieved */ public function getResource() { @@ -99,7 +99,7 @@ public function getResource() /** * Gets the parameter holder for this object. * - * @return sfParameterHolder A sfParameterHolder instance + * @return \sfParameterHolder A sfParameterHolder instance */ public function getParameterHolder() { @@ -118,7 +118,7 @@ public function getParameterHolder() * * @return string The value associated with the key * - * @see sfParameterHolder + * @see \sfParameterHolder */ public function getParameter($name, $default = null) { @@ -136,7 +136,7 @@ public function getParameter($name, $default = null) * * @return bool true if the given key exists, false otherwise * - * @see sfParameterHolder + * @see \sfParameterHolder */ public function hasParameter($name) { @@ -153,7 +153,7 @@ public function hasParameter($name) * @param string $name The key name * @param string $value The value * - * @see sfParameterHolder + * @see \sfParameterHolder */ public function setParameter($name, $value) { @@ -163,7 +163,7 @@ public function setParameter($name, $value) /** * Executes the shutdown procedure. * - * @throws sfDatabaseException If an error occurs while shutting down this database + * @throws \sfDatabaseException If an error occurs while shutting down this database */ abstract public function shutdown(); } diff --git a/lib/database/sfDatabaseManager.class.php b/lib/database/sfDatabaseManager.class.php index ae0a6927e..ab09eb9f8 100644 --- a/lib/database/sfDatabaseManager.class.php +++ b/lib/database/sfDatabaseManager.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -21,9 +21,9 @@ */ class sfDatabaseManager { - /** @var sfProjectConfiguration */ + /** @var \sfProjectConfiguration */ protected $configuration; - protected $databases = array(); + protected $databases = []; /** * Class constructor. @@ -32,23 +32,23 @@ class sfDatabaseManager * * @param array $options */ - public function __construct(sfProjectConfiguration $configuration, $options = array()) + public function __construct(\sfProjectConfiguration $configuration, $options = []) { $this->initialize($configuration); if (!isset($options['auto_shutdown']) || $options['auto_shutdown']) { - register_shutdown_function(array($this, 'shutdown')); + register_shutdown_function([$this, 'shutdown']); } } /** * Initializes this sfDatabaseManager object. * - * @param sfProjectConfiguration $configuration A sfProjectConfiguration instance + * @param \sfProjectConfiguration $configuration A sfProjectConfiguration instance * - * @throws sfInitializationException If an error occurs while initializing this sfDatabaseManager object + * @throws \sfInitializationException If an error occurs while initializing this sfDatabaseManager object */ - public function initialize(sfProjectConfiguration $configuration) + public function initialize(\sfProjectConfiguration $configuration) { $this->configuration = $configuration; @@ -60,11 +60,11 @@ public function initialize(sfProjectConfiguration $configuration) */ public function loadConfiguration() { - if ($this->configuration instanceof sfApplicationConfiguration) { + if ($this->configuration instanceof \sfApplicationConfiguration) { $databases = include $this->configuration->getConfigCache()->checkConfig('config/databases.yml'); } else { - $configHandler = new sfDatabaseConfigHandler(); - $databases = $configHandler->evaluate(array($this->configuration->getRootDir().'/config/databases.yml')); + $configHandler = new \sfDatabaseConfigHandler(); + $databases = $configHandler->evaluate([$this->configuration->getRootDir().'/config/databases.yml']); } foreach ($databases as $name => $database) { @@ -75,10 +75,10 @@ public function loadConfiguration() /** * Sets a database connection. * - * @param string $name The database name - * @param sfDatabase $database A sfDatabase instance + * @param string $name The database name + * @param \sfDatabase $database A sfDatabase instance */ - public function setDatabase($name, sfDatabase $database) + public function setDatabase($name, \sfDatabase $database) { $this->databases[$name] = $database; } @@ -90,7 +90,7 @@ public function setDatabase($name, sfDatabase $database) * * @return mixed A Database instance * - * @throws sfDatabaseException If the requested database name does not exist + * @throws \sfDatabaseException If the requested database name does not exist */ public function getDatabase($name = 'default') { @@ -99,7 +99,7 @@ public function getDatabase($name = 'default') } // nonexistent database name - throw new sfDatabaseException(sprintf('Database "%s" does not exist.', $name)); + throw new \sfDatabaseException(sprintf('Database "%s" does not exist.', $name)); } /** @@ -115,7 +115,7 @@ public function getNames() /** * Executes the shutdown procedure. * - * @throws sfDatabaseException If an error occurs while shutting down this DatabaseManager + * @throws \sfDatabaseException If an error occurs while shutting down this DatabaseManager */ public function shutdown() { diff --git a/lib/database/sfMySQLDatabase.class.php b/lib/database/sfMySQLDatabase.class.php index 82e5d8248..10f317ff3 100644 --- a/lib/database/sfMySQLDatabase.class.php +++ b/lib/database/sfMySQLDatabase.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -25,12 +25,12 @@ * * @version SVN: $Id$ */ -class sfMySQLDatabase extends sfDatabase +class sfMySQLDatabase extends \sfDatabase { /** * Connects to the database. * - * @throws sfDatabaseException If a connection could not be created + * @throws \sfDatabaseException If a connection could not be created */ public function connect() { @@ -55,13 +55,13 @@ public function connect() // make sure the connection went through if (false === $this->connection) { // the connection's foobar'd - throw new sfDatabaseException('Failed to create a MySQLDatabase connection.'); + throw new \sfDatabaseException('Failed to create a MySQLDatabase connection.'); } // select our database if ($this->selectDatabase($database)) { // can't select the database - throw new sfDatabaseException(sprintf('Failed to select MySQLDatabase "%s".', $database)); + throw new \sfDatabaseException(sprintf('Failed to select MySQLDatabase "%s".', $database)); } // set encoding if specified @@ -77,7 +77,7 @@ public function connect() /** * Execute the shutdown procedure. * - * @throws sfDatabaseException If an error occurs while shutting down this database + * @throws \sfDatabaseException If an error occurs while shutting down this database */ public function shutdown() { diff --git a/lib/database/sfMySQLiDatabase.class.php b/lib/database/sfMySQLiDatabase.class.php index a7c485c39..54aa83577 100644 --- a/lib/database/sfMySQLiDatabase.class.php +++ b/lib/database/sfMySQLiDatabase.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,14 +12,14 @@ /** * sfMySQLiDatabase provides connectivity for the MySQL brand database. * - * @see sfMySQLDatabase + * @see \sfMySQLDatabase * * @property $connection mysqli */ -class sfMySQLiDatabase extends sfMySQLDatabase +class sfMySQLiDatabase extends \sfMySQLDatabase { /** - * @throws sfDatabaseException + * @throws \sfDatabaseException */ public function connect() { @@ -32,7 +32,7 @@ public function connect() /** * Execute the shutdown procedure. * - * @throws sfDatabaseException If an error occurs while shutting down this database + * @throws \sfDatabaseException If an error occurs while shutting down this database */ public function shutdown() { diff --git a/lib/database/sfPDODatabase.class.php b/lib/database/sfPDODatabase.class.php index d81999960..c9043d7dd 100644 --- a/lib/database/sfPDODatabase.class.php +++ b/lib/database/sfPDODatabase.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,7 +19,7 @@ * * @version SVN: $Id$ */ -class sfPDODatabase extends sfDatabase +class sfPDODatabase extends \sfDatabase { /** * Magic method for calling PDO directly via sfPDODatabase. @@ -29,19 +29,19 @@ class sfPDODatabase extends sfDatabase */ public function __call($method, $arguments) { - return call_user_func_array(array($this->getConnection(), $method), $arguments); + return call_user_func_array([$this->getConnection(), $method], $arguments); } /** * Connects to the database. * - * @throws sfDatabaseException If a connection could not be created + * @throws \sfDatabaseException If a connection could not be created */ public function connect() { if (!$dsn = $this->getParameter('dsn')) { // missing required dsn parameter - throw new sfDatabaseException('Database configuration is missing the "dsn" parameter.'); + throw new \sfDatabaseException('Database configuration is missing the "dsn" parameter.'); } try { @@ -50,36 +50,36 @@ public function connect() $password = $this->getParameter('password'); $persistent = $this->getParameter('persistent'); - $options = $persistent ? array(PDO::ATTR_PERSISTENT => true) : array(); + $options = $persistent ? [\PDO::ATTR_PERSISTENT => true] : []; $this->connection = new $pdo_class($dsn, $username, $password, $options); - } catch (PDOException $e) { - throw new sfDatabaseException($e->getMessage()); + } catch (\PDOException $e) { + throw new \sfDatabaseException($e->getMessage()); } // lets generate exceptions instead of silent failures - if (sfConfig::get('sf_debug')) { - $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + if (\sfConfig::get('sf_debug')) { + $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } else { - $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); + $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); } // compatability $compatability = $this->getParameter('compat'); if ($compatability) { - $this->connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); + $this->connection->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL); } // nulls $nulls = $this->getParameter('nulls'); if ($nulls) { - $this->connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); + $this->connection->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_EMPTY_STRING); } // auto commit $autocommit = $this->getParameter('autocommit'); if ($autocommit) { - $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true); + $this->connection->setAttribute(\PDO::ATTR_AUTOCOMMIT, true); } $this->resource = $this->connection; diff --git a/lib/database/sfPostgreSQLDatabase.class.php b/lib/database/sfPostgreSQLDatabase.class.php index d5ed1dcbc..53194468d 100644 --- a/lib/database/sfPostgreSQLDatabase.class.php +++ b/lib/database/sfPostgreSQLDatabase.class.php @@ -1,9 +1,9 @@ - * (c) 2004-2006 Sean Kerr + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -26,12 +26,12 @@ * * @version SVN: $Id$ */ -class sfPostgreSQLDatabase extends sfDatabase +class sfPostgreSQLDatabase extends \sfDatabase { /** * Connects to the database. * - * @throws sfDatabaseException If a connection could not be created + * @throws \sfDatabaseException If a connection could not be created */ public function connect() { @@ -57,7 +57,7 @@ public function connect() // make sure the connection went through if (false === $this->connection) { // the connection's foobar'd - throw new sfDatabaseException('Failed to create a PostgreSQLDatabase connection.'); + throw new \sfDatabaseException('Failed to create a PostgreSQLDatabase connection.'); } // since we're not an abstraction layer, we copy the connection @@ -68,7 +68,7 @@ public function connect() /** * Executes the shutdown procedure. * - * @throws sfDatabaseException If an error occurs while shutting down this database + * @throws \sfDatabaseException If an error occurs while shutting down this database */ public function shutdown() { diff --git a/lib/debug/sfDebug.class.php b/lib/debug/sfDebug.class.php index db1fe186a..dad90d6b7 100644 --- a/lib/debug/sfDebug.class.php +++ b/lib/debug/sfDebug.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -24,10 +25,10 @@ class sfDebug */ public static function symfonyInfoAsArray() { - return array( + return [ 'version' => SYMFONY_VERSION, - 'path' => sfConfig::get('sf_symfony_lib_dir'), - ); + 'path' => \sfConfig::get('sf_symfony_lib_dir'), + ]; } /** @@ -37,11 +38,11 @@ public static function symfonyInfoAsArray() */ public static function phpInfoAsArray() { - $values = array( + $values = [ 'php' => phpversion(), 'os' => php_uname(), 'extensions' => get_loaded_extensions(), - ); + ]; natcasesort($values['extensions']); @@ -62,13 +63,13 @@ public static function phpInfoAsArray() */ public static function globalsAsArray() { - $values = array(); - foreach (array('cookie', 'server', 'get', 'post', 'files', 'env', 'session') as $name) { + $values = []; + foreach (['cookie', 'server', 'get', 'post', 'files', 'env', 'session'] as $name) { if (!isset($GLOBALS['_'.strtoupper($name)])) { continue; } - $values[$name] = array(); + $values[$name] = []; foreach ($GLOBALS['_'.strtoupper($name)] as $key => $value) { $values[$name][$key] = $value; } @@ -87,7 +88,7 @@ public static function globalsAsArray() */ public static function settingsAsArray() { - $config = sfConfig::getAll(); + $config = \sfConfig::getAll(); ksort($config); @@ -97,73 +98,73 @@ public static function settingsAsArray() /** * Returns request parameter holders as an array. * - * @param sfRequest $request A sfRequest instance + * @param \sfRequest $request A sfRequest instance * * @return array The request parameter holders */ - public static function requestAsArray(sfRequest $request = null) + public static function requestAsArray(\sfRequest $request = null) { if (!$request) { - return array(); + return []; } - return array( + return [ 'options' => $request->getOptions(), 'parameterHolder' => self::flattenParameterHolder($request->getParameterHolder(), true), 'attributeHolder' => self::flattenParameterHolder($request->getAttributeHolder(), true), - ); + ]; } /** * Returns response parameters as an array. * - * @param sfWebResponse $response A sfResponse instance + * @param \sfWebResponse $response A sfResponse instance * * @return array The response parameters */ - public static function responseAsArray(sfResponse $response = null) + public static function responseAsArray(\sfResponse $response = null) { if (!$response) { - return array(); + return []; } - return array( - 'status' => array('code' => $response->getStatusCode(), 'text' => $response->getStatusText()), + return [ + 'status' => ['code' => $response->getStatusCode(), 'text' => $response->getStatusText()], 'options' => $response->getOptions(), - 'cookies' => method_exists($response, 'getCookies') ? $response->getCookies() : array(), - 'httpHeaders' => method_exists($response, 'getHttpHeaders') ? $response->getHttpHeaders() : array(), - 'javascripts' => method_exists($response, 'getJavascripts') ? $response->getJavascripts('ALL') : array(), - 'stylesheets' => method_exists($response, 'getStylesheets') ? $response->getStylesheets('ALL') : array(), - 'metas' => method_exists($response, 'getMetas') ? $response->getMetas() : array(), - 'httpMetas' => method_exists($response, 'getHttpMetas') ? $response->getHttpMetas() : array(), - ); + 'cookies' => method_exists($response, 'getCookies') ? $response->getCookies() : [], + 'httpHeaders' => method_exists($response, 'getHttpHeaders') ? $response->getHttpHeaders() : [], + 'javascripts' => method_exists($response, 'getJavascripts') ? $response->getJavascripts('ALL') : [], + 'stylesheets' => method_exists($response, 'getStylesheets') ? $response->getStylesheets('ALL') : [], + 'metas' => method_exists($response, 'getMetas') ? $response->getMetas() : [], + 'httpMetas' => method_exists($response, 'getHttpMetas') ? $response->getHttpMetas() : [], + ]; } /** * Returns user parameters as an array. * - * @param sfUser $user A sfUser instance + * @param \sfUser $user A sfUser instance * * @return array The user parameters */ - public static function userAsArray(sfUser $user = null) + public static function userAsArray(\sfUser $user = null) { if (!$user) { - return array(); + return []; } - $data = array( + $data = [ 'options' => $user->getOptions(), 'attributeHolder' => self::flattenParameterHolder($user->getAttributeHolder(), true), 'culture' => $user->getCulture(), - ); + ]; - if ($user instanceof sfBasicSecurityUser) { - $data = array_merge($data, array( + if ($user instanceof \sfBasicSecurityUser) { + $data = array_merge($data, [ 'authenticated' => $user->isAuthenticated(), 'credentials' => $user->getCredentials(), 'lastRequest' => $user->getLastRequestTime(), - )); + ]); } return $data; @@ -172,17 +173,17 @@ public static function userAsArray(sfUser $user = null) /** * Returns a parameter holder as an array. * - * @param sfParameterHolder $parameterHolder A sfParameterHolder instance - * @param bool $removeObjects when set to true, objects are removed. default is false for BC. + * @param \sfParameterHolder $parameterHolder A sfParameterHolder instance + * @param bool $removeObjects when set to true, objects are removed. default is false for BC. * * @return array The parameter holder as an array */ public static function flattenParameterHolder($parameterHolder, $removeObjects = false) { - $values = array(); - if ($parameterHolder instanceof sfNamespacedParameterHolder) { + $values = []; + if ($parameterHolder instanceof \sfNamespacedParameterHolder) { foreach ($parameterHolder->getNamespaces() as $ns) { - $values[$ns] = array(); + $values[$ns] = []; foreach ($parameterHolder->getAll($ns) as $key => $value) { $values[$ns][$key] = $value; } @@ -212,7 +213,7 @@ public static function flattenParameterHolder($parameterHolder, $removeObjects = */ public static function removeObjects($values) { - $nvalues = array(); + $nvalues = []; foreach ($values as $key => $value) { if (is_array($value)) { $nvalues[$key] = self::removeObjects($value); @@ -239,8 +240,8 @@ public static function shortenFilePath($file) return $file; } - foreach (array('sf_root_dir', 'sf_symfony_lib_dir') as $key) { - if (0 === strpos($file, $value = sfConfig::get($key))) { + foreach (['sf_root_dir', 'sf_symfony_lib_dir'] as $key) { + if (str_starts_with($file, $value = \sfConfig::get($key))) { $file = str_replace($value, strtoupper($key), $file); break; diff --git a/lib/debug/sfTimer.class.php b/lib/debug/sfTimer.class.php index 8b85e0e9a..5f5abcea2 100644 --- a/lib/debug/sfTimer.class.php +++ b/lib/debug/sfTimer.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/lib/debug/sfTimerManager.class.php b/lib/debug/sfTimerManager.class.php index 110939ca8..dce2fb681 100644 --- a/lib/debug/sfTimerManager.class.php +++ b/lib/debug/sfTimerManager.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -18,7 +19,7 @@ class sfTimerManager { /** @var sfTimer[] */ - public static $timers = array(); + public static $timers = []; /** * Gets a sfTimer instance. @@ -28,12 +29,12 @@ class sfTimerManager * @param string $name The name of the timer * @param bool $reset * - * @return sfTimer The timer instance + * @return \sfTimer The timer instance */ public static function getTimer($name, $reset = true) { if (!isset(self::$timers[$name])) { - self::$timers[$name] = new sfTimer($name); + self::$timers[$name] = new \sfTimer($name); } if ($reset) { @@ -58,6 +59,6 @@ public static function getTimers() */ public static function clearTimers() { - self::$timers = array(); + self::$timers = []; } } diff --git a/lib/debug/sfWebDebug.class.php b/lib/debug/sfWebDebug.class.php index c7dd17415..51c63fc33 100644 --- a/lib/debug/sfWebDebug.class.php +++ b/lib/debug/sfWebDebug.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -19,8 +20,8 @@ class sfWebDebug { protected $dispatcher; protected $logger; - protected $options = array(); - protected $panels = array(); + protected $options = []; + protected $panels = []; /** * Constructor. @@ -30,11 +31,11 @@ class sfWebDebug * * image_root_path: The image root path * * request_parameters: The current request parameters * - * @param sfEventDispatcher $dispatcher The event dispatcher - * @param sfVarLogger $logger The logger - * @param array $options An array of options + * @param \sfEventDispatcher $dispatcher The event dispatcher + * @param \sfVarLogger $logger The logger + * @param array $options An array of options */ - public function __construct(sfEventDispatcher $dispatcher, sfVarLogger $logger, array $options = array()) + public function __construct(\sfEventDispatcher $dispatcher, \sfVarLogger $logger, array $options = []) { $this->dispatcher = $dispatcher; $this->logger = $logger; @@ -45,12 +46,12 @@ public function __construct(sfEventDispatcher $dispatcher, sfVarLogger $logger, } if (!isset($this->options['request_parameters'])) { - $this->options['request_parameters'] = array(); + $this->options['request_parameters'] = []; } $this->configure(); - $this->dispatcher->notify(new sfEvent($this, 'debug.web.load_panels')); + $this->dispatcher->notify(new \sfEvent($this, 'debug.web.load_panels')); } /** @@ -58,27 +59,27 @@ public function __construct(sfEventDispatcher $dispatcher, sfVarLogger $logger, */ public function configure() { - $this->setPanel('symfony_version', new sfWebDebugPanelSymfonyVersion($this)); - if (sfConfig::get('sf_debug') && sfConfig::get('sf_cache')) { - $this->setPanel('cache', new sfWebDebugPanelCache($this)); + $this->setPanel('symfony_version', new \sfWebDebugPanelSymfonyVersion($this)); + if (\sfConfig::get('sf_debug') && \sfConfig::get('sf_cache')) { + $this->setPanel('cache', new \sfWebDebugPanelCache($this)); } - if (sfConfig::get('sf_logging_enabled')) { - $this->setPanel('config', new sfWebDebugPanelConfig($this)); - $this->setPanel('view', new sfWebDebugPanelView($this)); + if (\sfConfig::get('sf_logging_enabled')) { + $this->setPanel('config', new \sfWebDebugPanelConfig($this)); + $this->setPanel('view', new \sfWebDebugPanelView($this)); } - $this->setPanel('logs', new sfWebDebugPanelLogs($this)); - $this->setPanel('memory', new sfWebDebugPanelMemory($this)); - if (sfConfig::get('sf_debug')) { - $this->setPanel('time', new sfWebDebugPanelTimer($this)); + $this->setPanel('logs', new \sfWebDebugPanelLogs($this)); + $this->setPanel('memory', new \sfWebDebugPanelMemory($this)); + if (\sfConfig::get('sf_debug')) { + $this->setPanel('time', new \sfWebDebugPanelTimer($this)); } - $this->setPanel('mailer', new sfWebDebugPanelMailer($this)); + $this->setPanel('mailer', new \sfWebDebugPanelMailer($this)); } /** * Gets the logger. * - * @return sfVarLogger The logger instance + * @return \sfVarLogger The logger instance */ public function getLogger() { @@ -88,7 +89,7 @@ public function getLogger() /** * Gets the event dispatcher. * - * @return sfEventDispatcher The event dispatcher + * @return \sfEventDispatcher The event dispatcher */ public function getEventDispatcher() { @@ -108,10 +109,10 @@ public function getPanels() /** * Sets a panel by name. * - * @param string $name The panel name - * @param sfWebDebugPanel $panel The panel + * @param string $name The panel name + * @param \sfWebDebugPanel $panel The panel */ - public function setPanel($name, sfWebDebugPanel $panel) + public function setPanel($name, \sfWebDebugPanel $panel) { $this->panels[$name] = $panel; } @@ -129,8 +130,8 @@ public function removePanel($name) /** * Gets an option value by name. * - * @param string $name The option name - * @param mixed|null $default + * @param string $name The option name + * @param \mixed|null $default * * @return mixed The option value */ @@ -159,7 +160,7 @@ public function injectToolbar($content) } if (false !== $pos = $posFunction($content, '')) { - $styles = ''; + $styles = ''; $content = $substrFunction($content, 0, $pos).$styles.$substrFunction($content, $pos); } @@ -182,8 +183,8 @@ public function asHtml() { $current = isset($this->options['request_parameters']['sfWebDebugPanel']) ? $this->options['request_parameters']['sfWebDebugPanel'] : null; - $titles = array(); - $panels = array(); + $titles = []; + $panels = []; foreach ($this->panels as $name => $panel) { if ($title = $panel->getTitle()) { if (($content = $panel->getPanelContent()) || $panel->getTitleUrl()) { @@ -236,10 +237,10 @@ public function asHtml() */ public function getPriority($value) { - if ($value >= sfLogger::INFO) { + if ($value >= \sfLogger::INFO) { return 'info'; } - if ($value >= sfLogger::WARNING) { + if ($value >= \sfLogger::WARNING) { return 'warning'; } diff --git a/lib/debug/sfWebDebugPanel.class.php b/lib/debug/sfWebDebugPanel.class.php index 61a8495e0..b4ed56760 100644 --- a/lib/debug/sfWebDebugPanel.class.php +++ b/lib/debug/sfWebDebugPanel.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -18,14 +19,14 @@ abstract class sfWebDebugPanel { protected $webDebug; - protected $status = sfLogger::INFO; + protected $status = \sfLogger::INFO; /** * Constructor. * - * @param sfWebDebug $webDebug The web debug toolbar instance + * @param \sfWebDebug $webDebug The web debug toolbar instance */ - public function __construct(sfWebDebug $webDebug) + public function __construct(\sfWebDebug $webDebug) { $this->webDebug = $webDebug; } @@ -117,7 +118,7 @@ public function getToggleableDebugStack($debugStack) $file = isset($trace['file']) ? $trace['file'] : null; $line = isset($trace['line']) ? $trace['line'] : null; - $isProjectFile = $file && 0 === strpos($file, sfConfig::get('sf_root_dir')) && !preg_match('/(cache|plugins|vendor)/', $file); + $isProjectFile = $file && str_starts_with($file, \sfConfig::get('sf_root_dir')) && !preg_match('/(cache|plugins|vendor)/', $file); $html .= sprintf('#%s » ', $isProjectFile ? ' class="sfWebDebugHighlight"' : '', $keys[$j] + 1); @@ -150,24 +151,24 @@ public function getToggleableDebugStack($debugStack) public function formatFileLink($file, $line = null, $text = null) { // this method is called a lot so we avoid calling class_exists() - if ($file && !sfToolkit::isPathAbsolute($file)) { + if ($file && !\sfToolkit::isPathAbsolute($file)) { if (null === $text) { $text = $file; } // translate class to file name - $r = new ReflectionClass($file); + $r = new \ReflectionClass($file); $file = $r->getFileName(); } - $shortFile = sfDebug::shortenFilePath($file); + $shortFile = \sfDebug::shortenFilePath($file); - if ($linkFormat = sfConfig::get('sf_file_link_format', ini_get('xdebug.file_link_format'))) { + if ($linkFormat = \sfConfig::get('sf_file_link_format', ini_get('xdebug.file_link_format'))) { // return a link return sprintf( '%s', - htmlspecialchars(strtr($linkFormat, array('%f' => $file, '%l' => $line)), ENT_QUOTES, sfConfig::get('sf_charset')), - htmlspecialchars($shortFile, ENT_QUOTES, sfConfig::get('sf_charset')), + htmlspecialchars(strtr($linkFormat, ['%f' => $file, '%l' => $line]), ENT_QUOTES, \sfConfig::get('sf_charset')), + htmlspecialchars($shortFile, ENT_QUOTES, \sfConfig::get('sf_charset')), null === $text ? $shortFile : $text ); } diff --git a/lib/debug/sfWebDebugPanelCache.class.php b/lib/debug/sfWebDebugPanelCache.class.php index ba8fb9805..f00078c6f 100644 --- a/lib/debug/sfWebDebugPanelCache.class.php +++ b/lib/debug/sfWebDebugPanelCache.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +17,7 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelCache extends sfWebDebugPanel +class sfWebDebugPanelCache extends \sfWebDebugPanel { public function getTitle() { @@ -27,7 +28,7 @@ public function getTitleUrl() { $queryString = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY); - if (false === strpos($queryString, '_sf_ignore_cache')) { + if (!str_contains($queryString, '_sf_ignore_cache')) { return sprintf('?%s_sf_ignore_cache=1', $queryString ? $queryString.'&' : ''); } diff --git a/lib/debug/sfWebDebugPanelConfig.class.php b/lib/debug/sfWebDebugPanelConfig.class.php index c0bee63e4..c4688ce1f 100644 --- a/lib/debug/sfWebDebugPanelConfig.class.php +++ b/lib/debug/sfWebDebugPanelConfig.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelConfig extends sfWebDebugPanel +class sfWebDebugPanelConfig extends \sfWebDebugPanel { public function getTitle() { @@ -29,17 +30,17 @@ public function getPanelTitle() public function getPanelContent() { - $config = array( - 'debug' => sfConfig::get('sf_debug') ? 'on' : 'off', + $config = [ + 'debug' => \sfConfig::get('sf_debug') ? 'on' : 'off', 'xdebug' => extension_loaded('xdebug') ? 'on' : 'off', - 'logging' => sfConfig::get('sf_logging_enabled') ? 'on' : 'off', - 'cache' => sfConfig::get('sf_cache') ? 'on' : 'off', - 'compression' => sfConfig::get('sf_compressed') ? 'on' : 'off', + 'logging' => \sfConfig::get('sf_logging_enabled') ? 'on' : 'off', + 'cache' => \sfConfig::get('sf_cache') ? 'on' : 'off', + 'compression' => \sfConfig::get('sf_compressed') ? 'on' : 'off', 'tokenizer' => function_exists('token_get_all') ? 'on' : 'off', 'eaccelerator' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') ? 'on' : 'off', 'apc' => extension_loaded('apc') && ini_get('apc.enabled') ? 'on' : 'off', 'xcache' => extension_loaded('xcache') && ini_get('xcache.cacher') ? 'on' : 'off', - ); + ]; $html = '
      '; foreach ($config as $key => $value) { @@ -47,14 +48,14 @@ public function getPanelContent() } $html .= '
    '; - $context = sfContext::getInstance(); - $html .= $this->formatArrayAsHtml('request', sfDebug::requestAsArray($context->getRequest())); - $html .= $this->formatArrayAsHtml('response', sfDebug::responseAsArray($context->getResponse())); - $html .= $this->formatArrayAsHtml('user', sfDebug::userAsArray($context->getUser())); - $html .= $this->formatArrayAsHtml('settings', sfDebug::settingsAsArray()); - $html .= $this->formatArrayAsHtml('globals', sfDebug::globalsAsArray()); - $html .= $this->formatArrayAsHtml('php', sfDebug::phpInfoAsArray()); - $html .= $this->formatArrayAsHtml('symfony', sfDebug::symfonyInfoAsArray()); + $context = \sfContext::getInstance(); + $html .= $this->formatArrayAsHtml('request', \sfDebug::requestAsArray($context->getRequest())); + $html .= $this->formatArrayAsHtml('response', \sfDebug::responseAsArray($context->getResponse())); + $html .= $this->formatArrayAsHtml('user', \sfDebug::userAsArray($context->getUser())); + $html .= $this->formatArrayAsHtml('settings', \sfDebug::settingsAsArray()); + $html .= $this->formatArrayAsHtml('globals', \sfDebug::globalsAsArray()); + $html .= $this->formatArrayAsHtml('php', \sfDebug::phpInfoAsArray()); + $html .= $this->formatArrayAsHtml('symfony', \sfDebug::symfonyInfoAsArray()); return $html; } @@ -73,7 +74,7 @@ protected function formatArrayAsHtml($id, $values) return '

    '.$id.' '.$this->getToggler('sfWebDebug'.$id).'

    - + '; } } diff --git a/lib/debug/sfWebDebugPanelLogs.class.php b/lib/debug/sfWebDebugPanelLogs.class.php index 58802582c..fe489c451 100644 --- a/lib/debug/sfWebDebugPanelLogs.class.php +++ b/lib/debug/sfWebDebugPanelLogs.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelLogs extends sfWebDebugPanel +class sfWebDebugPanelLogs extends \sfWebDebugPanel { public function getTitle() { @@ -29,7 +30,7 @@ public function getPanelTitle() public function getPanelContent() { - $event = $this->webDebug->getEventDispatcher()->filter(new sfEvent($this, 'debug.web.filter_logs'), $this->webDebug->getLogger()->getLogs()); + $event = $this->webDebug->getEventDispatcher()->filter(new \sfEvent($this, 'debug.web.filter_logs'), $this->webDebug->getLogger()->getLogs()); $logs = $event->getReturnValue(); $html = ' @@ -61,7 +62,7 @@ class_exists($log['type'], false) ? $this->formatFileLink($log['type']) : $log[' } $html .= '
    '; - $types = array(); + $types = []; foreach ($this->webDebug->getLogger()->getTypes() as $type) { $types[] = ''.$type.''; } @@ -91,26 +92,26 @@ protected function formatLogLine($logLine) static $constants; if (!$constants) { - foreach (array('sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir') as $constant) { - $constants[realpath(sfConfig::get($constant)).DIRECTORY_SEPARATOR] = $constant.DIRECTORY_SEPARATOR; + foreach (['sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir'] as $constant) { + $constants[realpath(\sfConfig::get($constant)).DIRECTORY_SEPARATOR] = $constant.DIRECTORY_SEPARATOR; } } // escape HTML - $logLine = htmlspecialchars($logLine, ENT_QUOTES, sfConfig::get('sf_charset')); + $logLine = htmlspecialchars($logLine, ENT_QUOTES, \sfConfig::get('sf_charset')); // replace constants value with constant name $logLine = str_replace(array_keys($constants), array_values($constants), $logLine); - $logLine = sfToolkit::pregtr($logLine, array('/"(.+?)"/s' => '"\\1"', + $logLine = \sfToolkit::pregtr($logLine, ['/"(.+?)"/s' => '"\\1"', '/^(.+?)\(\)\:/S' => '\\1():', - '/line (\d+)$/' => 'line \\1')); + '/line (\d+)$/' => 'line \\1']); // special formatting for SQL lines $logLine = $this->formatSql($logLine); // remove username/password from DSN - if (false !== strpos($logLine, 'DSN')) { + if (str_contains($logLine, 'DSN')) { $logLine = preg_replace("/=>\\s+'?[^'\\s,]+'?/", "=> '****'", $logLine); } diff --git a/lib/debug/sfWebDebugPanelMailer.class.php b/lib/debug/sfWebDebugPanelMailer.class.php index ab31b24be..afddaa5b3 100644 --- a/lib/debug/sfWebDebugPanelMailer.class.php +++ b/lib/debug/sfWebDebugPanelMailer.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,21 +16,21 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelMailer extends sfWebDebugPanel +class sfWebDebugPanelMailer extends \sfWebDebugPanel { - /** @var sfMailer */ + /** @var \sfMailer */ protected $mailer; /** * Constructor. * - * @param sfWebDebug $webDebug The web debug toolbar instance + * @param \sfWebDebug $webDebug The web debug toolbar instance */ - public function __construct(sfWebDebug $webDebug) + public function __construct(\sfWebDebug $webDebug) { parent::__construct($webDebug); - $this->webDebug->getEventDispatcher()->connect('mailer.configure', array($this, 'listenForMailerConfigure')); + $this->webDebug->getEventDispatcher()->connect('mailer.configure', [$this, 'listenForMailerConfigure']); } public function getTitle() @@ -52,14 +53,14 @@ public function getPanelContent() return false; } - $html = array(); + $html = []; // configuration information $strategy = $this->mailer->getDeliveryStrategy(); $html[] = '

    Configuration

    '; $html[] = 'Delivery strategy: '.$strategy; - if (sfMailer::SINGLE_ADDRESS == $strategy) { + if (\sfMailer::SINGLE_ADDRESS == $strategy) { $html[] = ' - all emails are delivered to: '.$this->mailer->getDeliveryAddress(); } @@ -75,12 +76,12 @@ public function getPanelContent() /** * Listens for the mailer.configure event and captures a reference to the mailer. */ - public function listenForMailerConfigure(sfEvent $event) + public function listenForMailerConfigure(\sfEvent $event) { $this->mailer = $event->getSubject(); } - protected function renderMessageInformation(Swift_Message $message) + protected function renderMessageInformation(\Swift_Message $message) { static $i = 0; @@ -88,7 +89,7 @@ protected function renderMessageInformation(Swift_Message $message) $to = null === $message->getTo() ? '' : implode(', ', array_keys($message->getTo())); - $html = array(); + $html = []; $html[] = sprintf('

    %s (to: %s) %s

    ', $message->getSubject(), $to, $this->getToggler('sfWebDebugMailTemplate'.$i)); $html[] = '
    '; $html[] = '
    '.htmlentities($message->toString(), ENT_QUOTES, $message->getCharset()).'
    '; diff --git a/lib/debug/sfWebDebugPanelMemory.class.php b/lib/debug/sfWebDebugPanelMemory.class.php index dc1ffe2b9..28bcf316d 100644 --- a/lib/debug/sfWebDebugPanelMemory.class.php +++ b/lib/debug/sfWebDebugPanelMemory.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelMemory extends sfWebDebugPanel +class sfWebDebugPanelMemory extends \sfWebDebugPanel { public function getTitle() { diff --git a/lib/debug/sfWebDebugPanelSymfonyVersion.class.php b/lib/debug/sfWebDebugPanelSymfonyVersion.class.php index e97bbd8ee..47ccbd6d9 100644 --- a/lib/debug/sfWebDebugPanelSymfonyVersion.class.php +++ b/lib/debug/sfWebDebugPanelSymfonyVersion.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +16,7 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelSymfonyVersion extends sfWebDebugPanel +class sfWebDebugPanelSymfonyVersion extends \sfWebDebugPanel { public function getTitle() { diff --git a/lib/debug/sfWebDebugPanelTimer.class.php b/lib/debug/sfWebDebugPanelTimer.class.php index dc932edc5..c95271156 100644 --- a/lib/debug/sfWebDebugPanelTimer.class.php +++ b/lib/debug/sfWebDebugPanelTimer.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,20 +16,20 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelTimer extends sfWebDebugPanel +class sfWebDebugPanelTimer extends \sfWebDebugPanel { protected static $startTime; /** * Constructor. * - * @param sfWebDebug $webDebug The web debug toolbar instance + * @param \sfWebDebug $webDebug The web debug toolbar instance */ - public function __construct(sfWebDebug $webDebug) + public function __construct(\sfWebDebug $webDebug) { parent::__construct($webDebug); - $this->webDebug->getEventDispatcher()->connect('debug.web.filter_logs', array($this, 'filterLogs')); + $this->webDebug->getEventDispatcher()->connect('debug.web.filter_logs', [$this, 'filterLogs']); } public function getTitle() @@ -43,10 +44,10 @@ public function getPanelTitle() public function getPanelContent() { - if (sfTimerManager::getTimers()) { + if (\sfTimerManager::getTimers()) { $totalTime = $this->getTotalTime(); $panel = ''; - foreach (sfTimerManager::getTimers() as $name => $timer) { + foreach (\sfTimerManager::getTimers() as $name => $timer) { $panel .= sprintf('', $name, $timer->getCalls(), $timer->getElapsedTime() * 1000, $totalTime ? ($timer->getElapsedTime() * 1000 * 100 / $totalTime) : 'N/A'); } $panel .= '
    typecallstime (ms)time (%)
    %s%d%.2f%d
    '; @@ -55,9 +56,9 @@ public function getPanelContent() } } - public function filterLogs(sfEvent $event, $logs) + public function filterLogs(\sfEvent $event, $logs) { - $newLogs = array(); + $newLogs = []; foreach ($logs as $log) { if ('sfWebDebugLogger' != $log['type']) { $newLogs[] = $log; diff --git a/lib/debug/sfWebDebugPanelView.class.php b/lib/debug/sfWebDebugPanelView.class.php index 7072ea25a..c72b5d6f5 100644 --- a/lib/debug/sfWebDebugPanelView.class.php +++ b/lib/debug/sfWebDebugPanelView.class.php @@ -1,8 +1,9 @@ + * This file is part of the Symfony1 package. + * + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,31 +16,31 @@ * * @version SVN: $Id$ */ -class sfWebDebugPanelView extends sfWebDebugPanel +class sfWebDebugPanelView extends \sfWebDebugPanel { - protected $actions = array(); - protected $partials = array(); + protected $actions = []; + protected $partials = []; /** * Constructor. * - * @param sfWebDebug $webDebug The web debug toolbar instance + * @param \sfWebDebug $webDebug The web debug toolbar instance */ - public function __construct(sfWebDebug $webDebug) + public function __construct(\sfWebDebug $webDebug) { parent::__construct($webDebug); - $this->webDebug->getEventDispatcher()->connect('controller.change_action', array($this, 'listenForChangeAction')); - $this->webDebug->getEventDispatcher()->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); + $this->webDebug->getEventDispatcher()->connect('controller.change_action', [$this, 'listenForChangeAction']); + $this->webDebug->getEventDispatcher()->connect('template.filter_parameters', [$this, 'filterTemplateParameters']); } /** * Resets the parameter collections. */ - public function listenForChangeAction(sfEvent $event) + public function listenForChangeAction(\sfEvent $event) { - $this->actions = array(); - $this->partials = array(); + $this->actions = []; + $this->partials = []; } /** @@ -49,21 +50,21 @@ public function listenForChangeAction(sfEvent $event) * * @return array */ - public function filterTemplateParameters(sfEvent $event, $parameters) + public function filterTemplateParameters(\sfEvent $event, $parameters) { - $entry = array('parameters' => $parameters); + $entry = ['parameters' => $parameters]; if ('action' == $parameters['sf_type'] && $file = $this->getLastTemplate()) { - $this->actions[] = $entry + array('file' => $file); + $this->actions[] = $entry + ['file' => $file]; } elseif ('partial' == $parameters['sf_type'] && $file = $this->getLastTemplate('sfPartialView')) { - $this->partials[] = $entry + array('file' => $file); + $this->partials[] = $entry + ['file' => $file]; } return $parameters; } /** - * @see sfWebDebugPanel + * @see \sfWebDebugPanel */ public function getTitle() { @@ -73,7 +74,7 @@ public function getTitle() } /** - * @see sfWebDebugPanel + * @see \sfWebDebugPanel */ public function getPanelTitle() { @@ -81,11 +82,11 @@ public function getPanelTitle() } /** - * @see sfWebDebugPanel + * @see \sfWebDebugPanel */ public function getPanelContent() { - $html = array(); + $html = []; foreach ($this->actions as $action) { $html[] = $this->renderTemplateInformation($action['file'], $action['parameters']); @@ -103,7 +104,7 @@ public function getPanelContent() * * @param string $class Name of the rendering view class * - * @return string|null + * @return \string|null */ protected function getLastTemplate($class = 'sfPHPView') { @@ -135,7 +136,7 @@ protected function renderTemplateInformation($file, $parameters, $label = 'Templ $parameters = $this->filterCoreParameters($parameters); ++$i; - $html = array(); + $html = []; $html[] = sprintf('

    %s: %s %s

    ', $label, $this->formatFileLink($file, null, $this->shortenTemplatePath($file)), $this->getToggler('sfWebDebugViewTemplate'.$i)); $html[] = '
    '; if (count($parameters)) { @@ -143,7 +144,7 @@ protected function renderTemplateInformation($file, $parameters, $label = 'Templ $html[] = '
      '; foreach ($parameters as $name => $parameter) { $presentation = '
    • '.$this->formatParameterAsHtml($name, $parameter).'
    • '; - $html[] = $this->webDebug->getEventDispatcher()->filter(new sfEvent($this, 'debug.web.view.filter_parameter_html', array('parameter' => $parameter)), $presentation)->getReturnValue(); + $html[] = $this->webDebug->getEventDispatcher()->filter(new \sfEvent($this, 'debug.web.view.filter_parameter_html', ['parameter' => $parameter]), $presentation)->getReturnValue(); } $html[] = '
    '; } else { @@ -180,7 +181,7 @@ protected function formatParameterAsHtml($name, $parameter) */ protected function formatObjectAsHtml($name, $parameter) { - if ($parameter instanceof sfForm) { + if ($parameter instanceof \sfForm) { return $this->formatFormAsHtml($name, $parameter); } @@ -194,17 +195,17 @@ protected function formatObjectAsHtml($name, $parameter) * * @return string */ - protected function formatFormAsHtml($name, sfForm $form) + protected function formatFormAsHtml($name, \sfForm $form) { static $i = 0; ++$i; - if ($form->hasErrors() && sfLogger::NOTICE < $this->getStatus()) { - $this->setStatus(sfLogger::NOTICE); + if ($form->hasErrors() && \sfLogger::NOTICE < $this->getStatus()) { + $this->setStatus(\sfLogger::NOTICE); } - $html = array(); + $html = []; $html[] = $this->getParameterDescription($name, $form, $form->hasErrors() ? '$%s' : null); $html[] = $this->getToggler('sfWebDebugViewForm'.$i); $html[] = '