diff --git a/.docker/php74_82/Dockerfile b/.docker/Dockerfile similarity index 100% rename from .docker/php74_82/Dockerfile rename to .docker/Dockerfile diff --git a/.docker/php53/Dockerfile b/.docker/php53/Dockerfile deleted file mode 100644 index 99ca06bf0..000000000 --- a/.docker/php53/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM buildpack-deps:jessie - -ENV PHP_VERSION 5.3.29 - -# php 5.3 needs older autoconf -RUN set -eux; \ - \ - apt-get update; \ - apt-get install -y \ - curl \ - autoconf2.13 \ - ; \ - rm -r /var/lib/apt/lists/*; \ - \ - curl -sSLfO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb; \ - curl -sSLfO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb; \ - dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb; \ - dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \ - rm *.deb; \ - \ - curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ - echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \ - \ - mkdir -p /usr/src/php; \ - tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1; \ - rm php.tar.bz2*; \ - \ - cd /usr/src/php; \ - ./buildconf --force; \ - ./configure --disable-cgi \ - $(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \ - --with-pdo-mysql \ - --with-zlib \ - --enable-mbstring \ - ; \ - make -j"$(nproc)"; \ - make install; \ - \ - dpkg -r \ - bison \ - libbison-dev \ - ; \ - apt-get purge -y --auto-remove \ - autoconf2.13 \ - ; \ - rm -r /usr/src/php - -# Install APC PHP extension -# -RUN set -eux; \ - \ - pecl install apc-3.1.13; \ - echo 'extension=apc.so' >> /usr/local/lib/php.ini; \ - \ - rm -r /tmp/pear; - -CMD ["php", "-a"] diff --git a/.docker/php54/Dockerfile b/.docker/php54/Dockerfile deleted file mode 100644 index ef5acfd0e..000000000 --- a/.docker/php54/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM php:5.4-cli - -RUN docker-php-ext-install pdo -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install mbstring - -# Install APC PHP extension -# -RUN set -eux; \ - pecl install apc-3.1.13; \ - docker-php-ext-enable apc; \ - rm -r /tmp/pear; - -# Install memcache PHP extension -# -ARG MEMCACHE_VERSION -RUN set -eux; \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ - \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ - $buildDeps \ - ; \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/*; \ - rm -r /tmp/pear diff --git a/.docker/php55_71/Dockerfile b/.docker/php55_71/Dockerfile deleted file mode 100644 index 1aa2171a3..000000000 --- a/.docker/php55_71/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -ARG PHP_TAG -FROM php:${PHP_TAG} - -RUN docker-php-ext-install pdo -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install mbstring - -# Install APCu PHP extension -# -ARG APCU_VERSION -RUN set -eux; \ - \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } - -# Install memcache PHP extension -# -ARG MEMCACHE_VERSION -RUN set -eux; \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ - \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ - $buildDeps \ - ; \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/*; \ - rm -r /tmp/pear diff --git a/.docker/php72_73/Dockerfile b/.docker/php72_73/Dockerfile deleted file mode 100644 index 69353468b..000000000 --- a/.docker/php72_73/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -ARG PHP_VERSION -FROM php:${PHP_VERSION}-cli - -RUN docker-php-ext-install pdo -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install mbstring - -# Install APCu PHP extension -# -ARG APCU_VERSION -RUN set -eux; \ - \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } - -# Install memcache PHP extension -# -ARG MEMCACHE_VERSION -RUN set -eux; \ - buildDeps=' \ - libzip-dev \ - '; \ - apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ - $buildDeps \ - ; \ - \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ - $buildDeps \ - ; \ - apt-get clean; \ - rm -rf /var/lib/apt/lists/*; \ - rm -r /tmp/pear - -# For consistent mime type file guesser -RUN set -eux; \ - distFilePath=`which file`; \ - \ - mv ${distFilePath} ${distFilePath}.dist; \ - { \ - echo '#! /bin/sh -eu'; \ - echo ''; \ - echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \ - } | tee ${distFilePath}; \ - \ - chmod +x ${distFilePath}; \ - \ - file /bin/ls --mime | grep application/x-executable; \ - :; diff --git a/.env.dist b/.env.dist index 14b756ef5..c4d23d59a 100644 --- a/.env.dist +++ b/.env.dist @@ -3,9 +3,3 @@ # # Copy to `.env` in order to use it. # - -# APC test are disabled. -# -# To enable them in order to provide a fix, set to "on". -# -APC_ENABLE_CLI=off diff --git a/.gitattributes b/.gitattributes index 9645b77e9..282650056 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,5 @@ docker-compose.yml export-ignore phpstan.neon export-ignore phpunit.xml export-ignore +test/ export-ignore tests/ export-ignore diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 08fc2566c..a6366b71b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -18,9 +18,9 @@ jobs: matrix: php-version: - "7.4" - - "8.0" - "8.1" - "8.2" + - "8.3" memcached-version: - "1.6" @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "true" @@ -38,13 +38,15 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" + extensions: apcu + ini-values: apc.enable_cli=1 - name: Get composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2c31663d6..99adc703b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,31 +1,43 @@ name: "Code Linting" on: push: + paths: + - .php-cs-fixer.dist.php + - autoload.php + - lib/** + - data/** + - tests/** branches: - master pull_request: + paths: + - .php-cs-fixer.dist.php + - autoload.php + - lib/** + - data/** + - tests/** jobs: php-cs-fixer: name: 'PHP-CS-Fixer' runs-on: 'ubuntu-latest' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 - tools: php-cs-fixer, cs2pr + php-version: 7.4 + tools: php-cs-fixer:3.52, cs2pr - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: '.php-cs-fixer.cache' - key: ${{ github.repository }}-8.2-phpcsfixer-${{ github.ref_name }} + key: ${{ github.repository }}-7.4-phpcsfixer-${{ github.ref_name }} restore-keys: | - ${{ github.repository }}-8.2-phpcsfixer-master - ${{ github.repository }}-8.2-phpcsfixer- + ${{ github.repository }}-7.4-phpcsfixer-master + ${{ github.repository }}-7.4-phpcsfixer- - name: Run PHP-CS-Fixer # Using cs2pr settings, see: https://github.com/shivammathur/setup-php#tools-with-checkstyle-support - run: 'php-cs-fixer fix --dry-run --format checkstyle | cs2pr' + run: 'php-cs-fixer fix --dry-run --format=checkstyle | cs2pr' diff --git a/.gitignore b/.gitignore index 3c17d4767..1c5624fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.cache/ + /test/functional/fixtures/cache /test/functional/fixtures/log /lib/plugins/sfDoctrinePlugin/test/functional/fixtures/lib/*/doctrine/base/ @@ -6,4 +8,3 @@ lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/ /vendor /composer.lock -.php-cs-fixer.cache diff --git a/.gitmodules b/.gitmodules index 3ee8d0c7d..be0be53cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "lib/vendor/swiftmailer"] path = lib/vendor/swiftmailer - url = https://github.com/swiftmailer/swiftmailer.git + url = https://github.com/FriendsOfSymfony1/swiftmailer.git branch = 5.x [submodule "lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine"] path = lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f5e11f987..fccc2b3f9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,24 +5,32 @@ ->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/') + ->exclude('plugins/sfDoctrinePlugin/test/functional/fixtures/') + + // Exclude sub-modules folders + ->exclude('plugins/sfDoctrinePlugin/lib/vendor/doctrine') + + // Exclude generated files (whole directories) + ->exclude('functional/fixtures/cache') + ->exclude('functional/fixtures/log') + // Exclude generated files (single files) ->notPath('unit/config/fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php') ->notPath('unit/config/fixtures/sfFilterConfigHandler/result.php') ; $config = new PhpCsFixer\Config(); -$config->setRules(array( - '@PhpCsFixer' => true, - '@Symfony' => true, - 'array_syntax' => array( - 'syntax' => 'long', - ), -)) - ->setCacheFile('.php-cs-fixer.cache') +$config + ->setRules([ + '@PhpCsFixer' => true, + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setCacheFile('.cache/php-cs-fixer.cache') ->setFinder($finder) ; diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c65db4f..7f5430169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,51 @@ CHANGELOG ========= ======= -xx/xx/xxxx: Version 1.5.16 + +xx/xx/xxxx: Version 1.5.xx +-------------------------- + +* Remove sfXCacheCache as the extension is not available on PHP v7.4 anymore. +* Remove sfEAcceleratorCache as the extension is not available on PHP v7.4 anymore. +* Remove sfAPCCache as it uses the `apc` extension, which is not available on PHP v7.4 anymore. + **[BC-Break]** Use `sfAPCuCache` class instead, available from Symfony1 v1.5.16 + +28/02/2024: Version 1.5.18 +-------------------------- + +* Set min versions of swiftmailer to 5.4.13 and 6.2.5 and updated swiftmailer submodule by @thirsch in #331 + +23/02/2024: Version 1.5.17 +-------------------------- + +* Update min PHP requirement to v7.4 or v8.1 by @thePanz in #325 +* Updated gh workflow to use latest actions by @thirsch in #330 +* Backported display_errors-handling to sf1 by @thirsch in #328 + +15/02/2024: Version 1.5.16 -------------------------- +* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, by @thePanz in #277 +* Add(linting) Add code linting to GitHub workflow, use php-cs-fixer by @thePanz in #283 +* Add(gitattributes) Add .gitattributes to repository by @thePanz in #287 +* fix: avoid creating dynamic property $options by @vimar in #290 +* Update(github) Update github workflows by @thePanz in #292 +* php8.3 in the party by @connorhu in #294 +* Fix(php-cs-fixer) Fix php-cs-fixer to v3.45 and apply code fixes by @thePanz in #300 +* 8.3 compat/string to array by @iricketson in #298 +* Fix APC tests and add APCu support by @mentalstring in #267 +* [8.x Compatiblity] sfDebug::shortenFilePath by @iricketson in #299 +* Fix strpos() deprecation on sfCacheSessionStorage check for cookie by @thePanz in #303 +* Fix setrawcookie() deprecation on null parameter by @thePanz in #304 +* Fix str_replace() deprecated null parameter on sfNumberFormat by @thePanz in #305 +* [PHP] Replace default $flags variable with 0 by @iricketson in #307 +* [PHP8] Declare sfDoctrineFormGenerator $params property by @iricketson in #306 +* Update README by @mentalstring in #310 +* minor fix: remove fourth argument by @connorhu in #308 +* Fix PHP8.1 sfForm - Unsupported operand types: array + null on sfForm by @Tybaze in #281 +* Fix link to GitHub pipeline badge by @thePanz in #311 +* fix(phpdoc) remove html code from throws phpdoc. phpstan don't like this by @connorhu in #309 +* fix(phpdoc) remove version tag by @connorhu in #313 12/01/2023: Version 1.5.15 -------------------------- diff --git a/README.md b/README.md index 4b285a0b0..9cf3d95cc 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -[![Build Status](https://secure.travis-ci.org/FriendsOfSymfony1/symfony1.png?branch=master)](http://travis-ci.org/FriendsOfSymfony1/symfony1) +![Build Status](https://github.com/FriendsOfSymfony1/symfony1/actions/workflows/continuous-integration.yml/badge.svg) About this version ------------------ -This is a community driven fork of symfony 1, as official support has been [interrupted in November 2012](http://symfony.com/blog/symfony-1-4-end-of-maintenance-what-does-it-mean). +This is a community driven fork of symfony 1, as official support has been [interrupted in November 2012](https://symfony.com/blog/symfony-1-4-end-of-maintenance-what-does-it-mean). -**Do not use it for new projects: this version is great to improve existing symfony1 applications, but [Symfony5](http://symfony.com/) is the way to go today.** +**Do not use it for new projects: this version is great to improve existing symfony1 applications, but [newer Symfony](https://symfony.com/) versions is the way to go today.** All the enhancements and BC breaks are listed in the [WHATS_NEW](https://github.com/FriendsOfSymfony1/symfony1/blob/master/WHATS_NEW.md) file, this include: - [DIC](https://github.com/FriendsOfSymfony1/symfony1/wiki/ServiceContainer) - Composer support -- PHP 8.2 support +- PHP 8.3 support - performance boost - new widgets & validators - some tickets fixed from the symfony trac @@ -34,22 +34,22 @@ It runs on *nix and Windows platforms*. Requirements ------------ -PHP 5.3.4 and up. See prerequisites on http://symfony.com/legacy/doc/getting-started/1_4/en/02-Prerequisites +PHP 5.3.4 and up. See prerequisites on https://symfony.com/legacy/doc/getting-started/1_4/en/02-Prerequisites Installation ------------ -See http://symfony.com/legacy/doc/getting-started/1_4/en/03-Symfony-Installation +See https://symfony.com/legacy/doc/getting-started/1_4/en/03-Symfony-Installation -Option 1: Using [Composer](http://getcomposer.org/doc/00-intro.md) as dependency management: +Option 1: Using [Composer](https://getcomposer.org/doc/00-intro.md) as dependency management: composer require friendsofsymfony1/symfony1 "1.5.*" composer install - -Note: On windows, if your project is a few directories down from the drive root, composer can throw an error relating to ZipArchive::extractTo(), this can be because pathnames are too long. There currently appears to be no proper solution but a workaround is to move your project to the drive root, run the commands from there, where they will run happily, and then move your project back. + +Note: On windows, if your project is a few directories down from the drive root, composer can throw an error relating to ZipArchive::extractTo(), this can be because pathnames are too long. There currently appears to be no proper solution but a workaround is to move your project to the drive root, run the commands from there, where they will run happily, and then move your project back. Option 2: Using Git submodules: - + git init # your project git submodule add https://github.com/FriendsOfSymfony1/symfony1.git lib/vendor/symfony git submodule update --init --recursive @@ -88,7 +88,7 @@ Tests Documentation ------------- -Read the official [symfony1 documentation](http://symfony.com/legacy) +Read the official [symfony1 documentation](https://symfony.com/legacy) Contributing ------------ diff --git a/composer.json b/composer.json index 181478ba6..135a13907 100755 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "type": "library", "license": "MIT", "require": { - "php" : ">=5.3.0", - "swiftmailer/swiftmailer": "~5.2 || ^6.0" + "php" : "^7.4 || ^8.1", + "friendsofsymfony1/swiftmailer": "^5.4.13 || ^6.2.5" }, "require-dev": { "psr/log": "*" diff --git a/data/bin/changelog.php b/data/bin/changelog.php index 4eaf5868a..6a3218a4b 100644 --- a/data/bin/changelog.php +++ b/data/bin/changelog.php @@ -36,10 +36,10 @@ list($out, $err) = $filesystem->execute('svn info --xml'); $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); foreach ($log->logentry as $logentry) { diff --git a/data/bin/check_configuration.php b/data/bin/check_configuration.php index cdb3276e5..ad542be16 100644 --- a/data/bin/check_configuration.php +++ b/data/bin/check_configuration.php @@ -22,7 +22,7 @@ function check($boolean, $message, $help = '', $fatal = false) } /** - * Gets the php.ini path used by the current PHP interpretor. + * Gets the php.ini path used by the current PHP interpreter. * * @return string the php.ini path */ @@ -61,7 +61,7 @@ function get_ini_path() // mandatory echo "\n** Mandatory requirements **\n\n"; -check(version_compare(phpversion(), '5.3.1', '>='), sprintf('PHP version is at least 5.3.1 (%s)', phpversion()), 'Current version is '.phpversion(), true); +check(PHP_VERSION_ID >= 70400, sprintf('PHP version is at least 7.4.0 (%s)', PHP_VERSION), 'Current version is '.PHP_VERSION, true); // warnings echo "\n** Optional checks **\n\n"; @@ -76,15 +76,10 @@ function get_ini_path() check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install and enable the XML extension', false); check(function_exists('posix_isatty'), 'The posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false); -$accelerator = - (function_exists('apc_store') && ini_get('apc.enabled')) - || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') - || function_exists('xcache_set'); -check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false); +$apcu = (function_exists('apc_store') || function_exists('apcu_store')) && ini_get('apc.enabled'); +check($apcu, 'A PHP accelerator is installed', 'Install a PHP accelerator like APCu (highly recommended)', false); check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false); -check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false); -check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false); check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false); check(class_exists('Memcache'), 'Memcache is available', 'You must have memcache installed and enabled to use sfMemcacheCache class.', false); diff --git a/data/bin/release.php b/data/bin/release.php index df6dec94f..ad652a3bf 100644 --- a/data/bin/release.php +++ b/data/bin/release.php @@ -73,7 +73,7 @@ // add class files $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 +82,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..3f35604aa 100644 --- a/data/bin/sandbox_installer.php +++ b/data/bin/sandbox_installer.php @@ -23,7 +23,7 @@ chmod(sfConfig::get('sf_data_dir').'/sandbox.db', 0777); $this->logSection('install', 'add an empty file in empty directories'); -$seen = array(); +$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/docker-compose.yml b/docker-compose.yml index 373560b09..326393e41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,154 +15,61 @@ services: - | exec tail -f /dev/null - php53: - build: .docker/php53 - working_dir: /app - volumes: - - .:/app - - db_socket:/var/run/mysqld - entrypoint: - - sh - - -c - - | - { - echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' - echo 'memory_limit = -1' - echo 'short_open_tag = off' - echo 'magic_quotes_gpc = off' - echo 'date.timezone = "UTC"' - echo 'apc.enable_cli = ${APC_ENABLE_CLI-off}' - echo 'apc.use_request_time = 0' - } | tee -a /usr/local/lib/php.ini - - exec tail -f /dev/null - depends_on: - - db - - php54: &services_php54 + php74: &services_php74 build: - context: .docker/php54 + context: .docker args: - MEMCACHE_VERSION: '3.0.8' + PHP_VERSION: '7.4' + MEMCACHE_VERSION: '4.0.5.2' + APCU_VERSION: '5.1.23' environment: - MEMCACHED_HOST: memcached + MEMCACHED_HOST: memcached working_dir: /app volumes: - - .:/app - - db_socket:/var/run/mysqld + - .:/app + - db_socket:/var/run/mysqld entrypoint: - - sh - - -c - - | - { - echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' - echo 'memory_limit = -1' - echo 'short_open_tag = off' - echo 'magic_quotes_gpc = off' - echo 'date.timezone = "UTC"' - echo 'apc.enable_cli = ${APC_ENABLE_CLI-off}' - echo 'apc.use_request_time = 0' - } | tee -a /usr/local/etc/php/php.ini - - exec tail -f /dev/null + - sh + - -c + - | + { + echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' + echo 'memory_limit = -1' + echo 'short_open_tag = off' + echo 'magic_quotes_gpc = off' + echo 'date.timezone = "UTC"' + echo 'apc.enable_cli = on' + echo 'apc.use_request_time = 0' + } | tee -a /usr/local/etc/php/php.ini + + exec tail -f /dev/null depends_on: - - db - - memcached - - php55: - <<: *services_php54 - build: - context: .docker/php55_71 - args: - PHP_TAG: '5.5-cli' - MEMCACHE_VERSION: '3.0.8' - APCU_VERSION: '4.0.11' - - php56: - <<: *services_php54 - build: - context: .docker/php55_71 - args: - PHP_TAG: '5.6-cli-jessie' - MEMCACHE_VERSION: '3.0.8' - APCU_VERSION: '4.0.11' - - php70: - <<: *services_php54 - build: - context: .docker/php55_71 - args: - PHP_TAG: '7.0-cli-jessie' - MEMCACHE_VERSION: '4.0.5.2' - APCU_VERSION: '' - - php71: - <<: *services_php54 - build: - context: .docker/php55_71 - args: - PHP_TAG: '7.1-cli-jessie' - MEMCACHE_VERSION: '4.0.5.2' - APCU_VERSION: '' - - - php72: - <<: *services_php54 - build: - context: .docker/php72_73 - args: - PHP_VERSION: '7.2' - MEMCACHE_VERSION: '4.0.5.2' - APCU_VERSION: '' - - - php73: - <<: *services_php54 - build: - context: .docker/php72_73 - args: - PHP_VERSION: '7.3' - MEMCACHE_VERSION: '4.0.5.2' - APCU_VERSION: '' - - - php74: - <<: *services_php54 - build: - context: .docker/php74_82 - args: - PHP_VERSION: '7.4' - MEMCACHE_VERSION: '4.0.5.2' - APCU_VERSION: '' - - - php80: - <<: *services_php54 - build: - context: .docker/php74_82 - args: - PHP_VERSION: '8.0' - MEMCACHE_VERSION: '8.0' - APCU_VERSION: '' - + - db + - memcached php81: - <<: *services_php54 + <<: *services_php74 build: - context: .docker/php74_82 args: PHP_VERSION: '8.1' MEMCACHE_VERSION: '8.0' - APCU_VERSION: '' + APCU_VERSION: '5.1.23' php82: - <<: *services_php54 + <<: *services_php74 build: - context: .docker/php74_82 args: PHP_VERSION: '8.2' MEMCACHE_VERSION: '8.0' - APCU_VERSION: '' + APCU_VERSION: '5.1.23' + + php83: + <<: *services_php74 + build: + args: + PHP_VERSION: '8.3' + MEMCACHE_VERSION: '8.0' + APCU_VERSION: '5.1.23' db: diff --git a/lib/action/sfAction.class.php b/lib/action/sfAction.class.php index 4753c3c6a..cabab27f0 100644 --- a/lib/action/sfAction.class.php +++ b/lib/action/sfAction.class.php @@ -15,14 +15,12 @@ * @author Fabien Potencier * @author Sean Kerr * - * @version SVN: $Id$ - * * @method sfWebController getController() * @method sfWebResponse getResponse() */ abstract class sfAction extends sfComponent { - protected $security = array(); + protected $security = []; /** * Initializes this action. @@ -46,14 +44,18 @@ public function initialize($context, $moduleName, $actionName) * * By default, this method is empty. */ - public function preExecute() {} + public function preExecute() + { + } /** * Execute an application defined process immediately after execution of this sfAction object. * * By default, this method is empty. */ - public function postExecute() {} + public function postExecute() + { + } /** * Forwards current action to the default 404 error action. @@ -120,7 +122,7 @@ public function redirect404() 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)))); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Forward to action "%s/%s"', $module, $action)])); } $this->getController()->forward($module, $action); @@ -182,7 +184,7 @@ 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; } @@ -209,7 +211,7 @@ 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)); } } @@ -231,7 +233,7 @@ 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)); } } @@ -428,7 +430,7 @@ 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)))); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name)])); } if (null !== $module) { @@ -466,7 +468,7 @@ 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)))); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change layout to "%s"', $name)])); } sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name); diff --git a/lib/action/sfActionStack.class.php b/lib/action/sfActionStack.class.php index 41c17e228..09242f6ef 100644 --- a/lib/action/sfActionStack.class.php +++ b/lib/action/sfActionStack.class.php @@ -15,13 +15,11 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfActionStack { /** @var sfActionStackEntry[] */ - protected $stack = array(); + protected $stack = []; /** * Adds an entry to the action stack. diff --git a/lib/action/sfActionStackEntry.class.php b/lib/action/sfActionStackEntry.class.php index 1624e710b..2d65536e3 100644 --- a/lib/action/sfActionStackEntry.class.php +++ b/lib/action/sfActionStackEntry.class.php @@ -14,8 +14,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfActionStackEntry { diff --git a/lib/action/sfActions.class.php b/lib/action/sfActions.class.php index 2a2de62da..2950780fc 100644 --- a/lib/action/sfActions.class.php +++ b/lib/action/sfActions.class.php @@ -14,8 +14,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ abstract class sfActions extends sfAction { @@ -43,13 +41,13 @@ public function execute($request) 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)); } if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Call "%s->%s()"', get_class($this), $actionToRun)))); + $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 245fe778b..368336eb4 100644 --- a/lib/action/sfComponent.class.php +++ b/lib/action/sfComponent.class.php @@ -14,8 +14,6 @@ * sfComponent. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfComponent { @@ -66,7 +64,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); } @@ -132,7 +130,7 @@ public function __unset($name) */ 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)); } @@ -251,7 +249,7 @@ final public function getLogger() 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))))); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [$message, 'priority' => constant('sfLogger::'.strtoupper($priority))])); } } @@ -343,7 +341,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); } diff --git a/lib/action/sfComponents.class.php b/lib/action/sfComponents.class.php index ce96e70e5..10028b7c8 100644 --- a/lib/action/sfComponents.class.php +++ b/lib/action/sfComponents.class.php @@ -12,8 +12,6 @@ * sfComponents. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfComponents extends sfComponent { diff --git a/lib/addon/sfData.class.php b/lib/addon/sfData.class.php index b03a4a55e..4d5e4e448 100644 --- a/lib/addon/sfData.class.php +++ b/lib/addon/sfData.class.php @@ -13,13 +13,11 @@ * as default implementations. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ 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 @@ -68,7 +66,7 @@ public function getFiles($element = null) $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)); @@ -108,8 +106,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..9f97829ea 100644 --- a/lib/addon/sfPager.class.php +++ b/lib/addon/sfPager.class.php @@ -12,8 +12,6 @@ * sfPager class. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfPager implements Iterator, Countable { @@ -25,7 +23,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; @@ -99,7 +97,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; diff --git a/lib/autoload/sfAutoload.class.php b/lib/autoload/sfAutoload.class.php index 8eba99269..4c3b364ce 100644 --- a/lib/autoload/sfAutoload.class.php +++ b/lib/autoload/sfAutoload.class.php @@ -15,18 +15,18 @@ * of the same class (why?). * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfAutoload { protected static $freshCache = false; protected static $instance; - protected $overriden = array(); - protected $classes = array(); + protected $overriden = []; + protected $classes = []; - protected function __construct() {} + protected function __construct() + { + } /** * Retrieves the singleton instance of this class. @@ -51,7 +51,7 @@ public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { + 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()))); } } @@ -61,7 +61,7 @@ public static function register() */ public static function unregister() { - spl_autoload_unregister(array(self::getInstance(), 'autoload')); + spl_autoload_unregister([self::getInstance(), 'autoload']); } /** diff --git a/lib/autoload/sfAutoloadAgain.class.php b/lib/autoload/sfAutoloadAgain.class.php index d44d70ed3..a2771e604 100644 --- a/lib/autoload/sfAutoloadAgain.class.php +++ b/lib/autoload/sfAutoloadAgain.class.php @@ -12,8 +12,6 @@ * Autoload again for dev environments. * * @author Kris Wallsmith - * - * @version SVN: $Id$ */ class sfAutoloadAgain { @@ -25,7 +23,9 @@ class sfAutoloadAgain /** * Constructor. */ - protected function __construct() {} + protected function __construct() + { + } /** * Returns the singleton autoloader. @@ -65,7 +65,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])) { @@ -102,7 +102,7 @@ public function isRegistered() public function register() { if (!$this->isRegistered()) { - spl_autoload_register(array($this, 'autoload')); + spl_autoload_register([$this, 'autoload']); $this->registered = true; } } @@ -112,7 +112,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 2b711629c..e13b737c3 100755 --- a/lib/autoload/sfCoreAutoload.class.php +++ b/lib/autoload/sfCoreAutoload.class.php @@ -9,7 +9,7 @@ */ // The current symfony version. -define('SYMFONY_VERSION', '1.5.16-dev'); +define('SYMFONY_VERSION', '1.5.20-dev'); /** * sfCoreAutoload class. @@ -18,8 +18,6 @@ * of the same class (why?). * * @author Fabien Potencier - * - * @version SVN: $Id: sfCoreAutoload.class.php 32415 2011-03-30 16:09:00Z Kris.Wallsmith */ class sfCoreAutoload { @@ -30,7 +28,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', @@ -43,15 +41,13 @@ class sfCoreAutoload 'sfautoloadagain' => 'autoload/sfAutoloadAgain.class.php', 'sfcoreautoload' => 'autoload/sfCoreAutoload.class.php', 'sfsimpleautoload' => 'autoload/sfSimpleAutoload.class.php', - 'sfapccache' => 'cache/sfAPCCache.class.php', + 'sfapcucache' => 'cache/sfAPCuCache.class.php', 'sfcache' => 'cache/sfCache.class.php', - 'sfeacceleratorcache' => 'cache/sfEAcceleratorCache.class.php', 'sffilecache' => 'cache/sfFileCache.class.php', 'sffunctioncache' => 'cache/sfFunctionCache.class.php', 'sfmemcachecache' => 'cache/sfMemcacheCache.class.php', 'sfnocache' => 'cache/sfNoCache.class.php', 'sfsqlitecache' => 'cache/sfSQLiteCache.class.php', - 'sfxcachecache' => 'cache/sfXCacheCache.class.php', 'sfansicolorformatter' => 'command/sfAnsiColorFormatter.class.php', 'sfcommandapplication' => 'command/sfCommandApplication.class.php', 'sfcommandargument' => 'command/sfCommandArgument.class.php', @@ -393,7 +389,7 @@ class sfCoreAutoload 'sfyamldumper' => 'yaml/sfYamlDumper.class.php', 'sfyamlinline' => 'yaml/sfYamlInline.class.php', 'sfyamlparser' => 'yaml/sfYamlParser.class.php', - ); + ]; protected function __construct() { @@ -426,7 +422,7 @@ public static function register() } ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { + 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()))); } @@ -438,7 +434,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; } diff --git a/lib/autoload/sfSimpleAutoload.class.php b/lib/autoload/sfSimpleAutoload.class.php index b63cfe47e..b20d89644 100755 --- a/lib/autoload/sfSimpleAutoload.class.php +++ b/lib/autoload/sfSimpleAutoload.class.php @@ -17,8 +17,6 @@ * of the same class (why?). * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfSimpleAutoload { @@ -28,10 +26,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) { @@ -70,12 +68,12 @@ public static function register() } ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { + 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; @@ -86,7 +84,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; } @@ -144,7 +142,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; @@ -156,7 +154,7 @@ public function saveCache() */ public function reload() { - $this->classes = array(); + $this->classes = []; $this->cacheLoaded = false; foreach ($this->dirs as $dir) { diff --git a/lib/cache/sfAPCCache.class.php b/lib/cache/sfAPCuCache.class.php similarity index 79% rename from lib/cache/sfAPCCache.class.php rename to lib/cache/sfAPCuCache.class.php index 721bea021..673eede28 100644 --- a/lib/cache/sfAPCCache.class.php +++ b/lib/cache/sfAPCuCache.class.php @@ -9,13 +9,12 @@ */ /** - * Cache class that stores cached content in APC. + * Cache class that stores cached content in APCu. * * @author Fabien Potencier - * - * @version SVN: $Id$ + * @author Paulo M */ -class sfAPCCache extends sfCache +class sfAPCuCache extends sfCache { protected $enabled; @@ -28,11 +27,11 @@ class sfAPCCache extends sfCache * * @see sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); - $this->enabled = function_exists('apc_store') && ini_get('apc.enabled'); + $this->enabled = function_exists('apcu_store') && ini_get('apc.enabled'); } /** @@ -76,7 +75,7 @@ public function set($key, $data, $lifetime = null) return true; } - return apc_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime)); + return apcu_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime)); } /** @@ -88,7 +87,7 @@ public function remove($key) return true; } - return apc_delete($this->getOption('prefix').$key); + return apcu_delete($this->getOption('prefix').$key); } /** @@ -101,8 +100,10 @@ public function clean($mode = sfCache::ALL) } if (sfCache::ALL === $mode) { - return apc_clear_cache('user'); + return apcu_clear_cache(); } + + return true; } /** @@ -138,18 +139,20 @@ public function removePattern($pattern) return true; } - $infos = apc_cache_info('user'); + $infos = apcu_cache_info(); if (!is_array($infos['cache_list'])) { - return; + return true; } - $regexp = self::patternToRegexp($this->getOption('prefix').$pattern); + $regexp = $this->patternToRegexp($this->getOption('prefix').$pattern); foreach ($infos['cache_list'] as $info) { if (preg_match($regexp, $info['info'])) { - apc_delete($info['info']); + apcu_delete($info['info']); } } + + return true; } /** @@ -157,7 +160,7 @@ public function removePattern($pattern) * * @param string $key The cache key * - * @return string + * @return string|false|array */ protected function getCacheInfo($key) { @@ -165,7 +168,7 @@ protected function getCacheInfo($key) return false; } - $infos = apc_cache_info('user'); + $infos = apcu_cache_info(); if (is_array($infos['cache_list'])) { foreach ($infos['cache_list'] as $info) { @@ -178,10 +181,17 @@ protected function getCacheInfo($key) return null; } + /** + * @param string $key + * + * @param-out bool $success + * + * @return false|mixed + */ private function fetch($key, &$success) { $has = null; - $value = apc_fetch($key, $has); + $value = apcu_fetch($key, $has); // the second argument was added in APC 3.0.17. If it is still null we fall back to the value returned if (null !== $has) { $success = $has; diff --git a/lib/cache/sfCache.class.php b/lib/cache/sfCache.class.php index 656e3fc71..60b9a2858 100644 --- a/lib/cache/sfCache.class.php +++ b/lib/cache/sfCache.class.php @@ -12,8 +12,6 @@ * sfCache is an abstract class for all cache classes in symfony. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfCache { @@ -21,7 +19,7 @@ abstract class sfCache public const ALL = 2; public const SEPARATOR = ':'; - protected $options = array(); + protected $options = []; /** * Class constructor. @@ -30,7 +28,7 @@ abstract class sfCache * * @param array $options */ - public function __construct($options = array()) + public function __construct($options = []) { $this->initialize($options); } @@ -50,15 +48,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; } @@ -151,7 +149,7 @@ abstract public function getLastModified($key); */ public function getMany($keys) { - $data = array(); + $data = []; foreach ($keys as $key) { $data[$key] = $this->get($key); } @@ -222,8 +220,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 deleted file mode 100644 index c97092456..000000000 --- a/lib/cache/sfEAcceleratorCache.class.php +++ /dev/null @@ -1,172 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Cache class that stores cached content in EAccelerator. - * - * @author Fabien Potencier - * - * @version SVN: $Id$ - */ -class sfEAcceleratorCache extends sfCache -{ - /** - * Initializes this sfCache instance. - * - * Available options: - * - * * see sfCache for options available for all drivers - * - * @see sfCache - * - * @param array $options - * - * @throws sfInitializationException - */ - public function initialize($options = array()) - { - 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).'); - } - } - - /** - * @see sfCache - * - * @param string $key - * @param mixed|null $default - * - * @return string|null - */ - public function get($key, $default = null) - { - $value = eaccelerator_get($this->getOption('prefix').$key); - - return null === $value ? $default : $value; - } - - /** - * @see sfCache - * - * @param string $key - * - * @return bool - */ - public function has($key) - { - return null !== eaccelerator_get($this->getOption('prefix'.$key)); - } - - /** - * @see sfCache - * - * @param string $key - * @param string $data - * @param int|null $lifetime - * - * @return bool - */ - public function set($key, $data, $lifetime = null) - { - return eaccelerator_put($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime)); - } - - /** - * @see sfCache - */ - public function remove($key) - { - return eaccelerator_rm($this->getOption('prefix').$key); - } - - /** - * @see sfCache - */ - public function removePattern($pattern) - { - $infos = eaccelerator_list_keys(); - - if (is_array($infos)) { - $regexp = self::patternToRegexp($this->getOption('prefix').$pattern); - - foreach ($infos as $info) { - if (preg_match($regexp, $info['name'])) { - eaccelerator_rm($this->getOption('prefix').$key); - } - } - } - } - - /** - * @see sfCache - */ - public function clean($mode = sfCache::ALL) - { - 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'))) { - // eaccelerator bug (http://eaccelerator.net/ticket/287) - $key = 0 === strpos($info['name'], ':') ? substr($info['name'], 1) : $info['name']; - if (!eaccelerator_rm($key)) { - return false; - } - } - } - } - - return true; - } - - /** - * @see sfCache - */ - public function getLastModified($key) - { - if ($info = $this->getCacheInfo($key)) { - return $info['created']; - } - - return 0; - } - - /** - * @see sfCache - */ - public function getTimeout($key) - { - if ($info = $this->getCacheInfo($key)) { - return -1 == $info['ttl'] ? 0 : $info['created'] + $info['ttl']; - } - - return 0; - } - - protected function getCacheInfo($key) - { - $infos = eaccelerator_list_keys(); - - if (is_array($infos)) { - foreach ($infos as $info) { - if ($this->getOption('prefix').$key == $info['name']) { - return $info; - } - } - } - - return null; - } -} diff --git a/lib/cache/sfFileCache.class.php b/lib/cache/sfFileCache.class.php index 11d2d3c84..dd5a9864e 100644 --- a/lib/cache/sfFileCache.class.php +++ b/lib/cache/sfFileCache.class.php @@ -12,8 +12,6 @@ * Cache class that stores content in files. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfFileCache extends sfCache { @@ -34,7 +32,7 @@ class sfFileCache extends sfCache * * @see sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); @@ -107,7 +105,7 @@ public function removePattern($pattern) $pattern = str_replace(sfCache::SEPARATOR, DIRECTORY_SEPARATOR, $pattern).self::EXTENSION; $regexp = self::patternToRegexp($pattern); - $paths = array(); + $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; @@ -124,6 +122,8 @@ public function removePattern($pattern) @unlink($path); } } + + return true; } /** @@ -264,7 +264,7 @@ protected function write($path, $data, $timeout) $cacheDir = dirname($path); if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - throw new \sfCacheException(sprintf('Cache was not able to create a directory "%s".', $cacheDir)); + throw new sfCacheException(sprintf('Cache was not able to create a directory "%s".', $cacheDir)); } $tmpFile = tempnam($cacheDir, basename($path)); diff --git a/lib/cache/sfFunctionCache.class.php b/lib/cache/sfFunctionCache.class.php index 08da5f124..8d890099d 100644 --- a/lib/cache/sfFunctionCache.class.php +++ b/lib/cache/sfFunctionCache.class.php @@ -12,8 +12,6 @@ * This class can be used to cache the result and output of any PHP callable (function and method calls). * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfFunctionCache { @@ -47,7 +45,7 @@ public function __construct(sfCache $cache) * @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,7 +54,7 @@ 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.'); @@ -101,7 +99,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..0caae1753 100644 --- a/lib/cache/sfMemcacheCache.class.php +++ b/lib/cache/sfMemcacheCache.class.php @@ -12,8 +12,6 @@ * Cache class that stores cached content in memcache. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfMemcacheCache extends sfCache { @@ -37,7 +35,7 @@ class sfMemcacheCache extends sfCache * * @see sfCache */ - public function initialize($options = array()) + public function initialize($options = []) { parent::initialize($options); @@ -147,6 +145,8 @@ public function clean($mode = sfCache::ALL) if (sfCache::ALL === $mode) { return $this->memcache->flush(); } + + return true; } /** @@ -190,6 +190,8 @@ public function removePattern($pattern) $this->remove(substr($key, strlen($this->getOption('prefix')))); } } + + return true; } /** @@ -197,7 +199,7 @@ public function removePattern($pattern) */ 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 +230,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 +243,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 +268,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..788d68dc2 100644 --- a/lib/cache/sfNoCache.class.php +++ b/lib/cache/sfNoCache.class.php @@ -12,8 +12,6 @@ * Cache class that does nothing. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfNoCache extends sfCache { diff --git a/lib/cache/sfSQLiteCache.class.php b/lib/cache/sfSQLiteCache.class.php index 5200cb60d..30484ad2d 100644 --- a/lib/cache/sfSQLiteCache.class.php +++ b/lib/cache/sfSQLiteCache.class.php @@ -12,8 +12,6 @@ * Cache class that stores cached content in a SQLite database. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfSQLiteCache extends sfCache { @@ -32,7 +30,7 @@ class sfSQLiteCache extends 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.'); @@ -198,8 +196,8 @@ public function removePatternRegexpCallback($regexp, $key) 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 +208,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']; } @@ -257,7 +255,7 @@ protected function setDatabase($database) } } - $this->dbh->createFunction('regexp', array($this, 'removePatternRegexpCallback'), 2); + $this->dbh->createFunction('regexp', [$this, 'removePatternRegexpCallback'], 2); if ($new) { $this->createSchema(); @@ -271,7 +269,7 @@ protected function setDatabase($database) */ protected function createSchema() { - $statements = array( + $statements = [ 'CREATE TABLE [cache] ( [key] VARCHAR(255), [data] LONGVARCHAR, @@ -279,7 +277,7 @@ protected function createSchema() [last_modified] TIMESTAMP )', 'CREATE UNIQUE INDEX [cache_unique] ON [cache] ([key])', - ); + ]; foreach ($statements as $statement) { if (false === $this->dbh->query($statement)) { @@ -308,7 +306,7 @@ protected function isSqLite3() protected function getSqLiteVersion() { if (null === $this->sqlLiteVersion) { - $this->sqlLiteVersion = version_compare(PHP_VERSION, '5.3', '>') ? 3 : 2; + $this->sqlLiteVersion = 3; } return $this->sqlLiteVersion; diff --git a/lib/cache/sfXCacheCache.class.php b/lib/cache/sfXCacheCache.class.php deleted file mode 100644 index 8c5c53e5e..000000000 --- a/lib/cache/sfXCacheCache.class.php +++ /dev/null @@ -1,203 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Cache class that stores cached content in XCache. - * - * @author Fabien Potencier - * - * @version SVN: $Id$ - */ -class sfXCacheCache extends sfCache -{ - /** - * Initializes this sfCache instance. - * - * Available options: - * - * * see sfCache for options available for all drivers - * - * @see sfCache - */ - public function initialize($options = array()) - { - parent::initialize($options); - - if (!function_exists('xcache_set')) { - 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.'); - } - } - - /** - * @see sfCache - * - * @param mixed|null $default - */ - public function get($key, $default = null) - { - $set = $this->getBaseValue($key); - - if (!is_array($set) || !array_key_exists('data', $set)) { - return $default; - } - - return $set['data']; - } - - /** - * @see sfCache - */ - public function has($key) - { - return xcache_isset($this->getOption('prefix').$key); - } - - /** - * @see sfCache - * - * @param mixed|null $lifetime - */ - public function set($key, $data, $lifetime = null) - { - $lifetime = $this->getLifetime($lifetime); - - $set = array( - 'timeout' => time() + $lifetime, - 'data' => $data, - 'ctime' => time(), - ); - - return xcache_set($this->getOption('prefix').$key, $set, $lifetime); - } - - /** - * @see sfCache - */ - public function remove($key) - { - return xcache_unset($this->getOption('prefix').$key); - } - - /** - * @see sfCache - */ - public function clean($mode = sfCache::ALL) - { - if (sfCache::ALL !== $mode) { - return true; - } - - $this->checkAuth(); - - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; ++$i) { - if (false === xcache_clear_cache(XC_TYPE_VAR, $i)) { - return false; - } - } - - return true; - } - - /** - * @see sfCache - */ - public function getLastModified($key) - { - $set = $this->getBaseValue($key); - - if (!is_array($set) || !array_key_exists('ctime', $set)) { - return 0; - } - - return $set['ctime']; - } - - /** - * @see sfCache - */ - public function getTimeout($key) - { - $set = $this->getBaseValue($key); - - if (!is_array($set) || !array_key_exists('timeout', $set)) { - return 0; - } - - return $set['timeout']; - } - - /** - * @param string $key - * - * @return mixed|null - */ - public function getBaseValue($key) - { - return xcache_isset($this->getOption('prefix').$key) ? xcache_get($this->getOption('prefix').$key) : null; - } - - /** - * @see sfCache - */ - public function removePattern($pattern) - { - $this->checkAuth(); - - $regexp = self::patternToRegexp($this->getOption('prefix').$pattern); - - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; ++$i) { - $infos = xcache_list(XC_TYPE_VAR, $i); - if (!is_array($infos['cache_list'])) { - return; - } - - foreach ($infos['cache_list'] as $info) { - if (preg_match($regexp, $info['name'])) { - xcache_unset($info['name']); - } - } - } - } - - /** - * @param string $key - * - * @return array|null - */ - public function getCacheInfo($key) - { - $this->checkAuth(); - - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; ++$i) { - $infos = xcache_list(XC_TYPE_VAR, $i); - - if (is_array($infos['cache_list'])) { - foreach ($infos['cache_list'] as $info) { - if ($this->getOption('prefix').$key == $info['name']) { - return $info; - } - } - } - } - - return null; - } - - 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.'); - } - } -} diff --git a/lib/command/cli.php b/lib/command/cli.php index 8b423443c..e5f6904e9 100644 --- a/lib/command/cli.php +++ b/lib/command/cli.php @@ -25,7 +25,7 @@ $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) { if (!isset($application)) { diff --git a/lib/command/sfAnsiColorFormatter.class.php b/lib/command/sfAnsiColorFormatter.class.php index bae2f2406..6bb298b84 100644 --- a/lib/command/sfAnsiColorFormatter.class.php +++ b/lib/command/sfAnsiColorFormatter.class.php @@ -12,20 +12,18 @@ * sfAnsiColorFormatter provides methods to colorize text to be displayed on a console. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ 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 +31,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 +44,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 +54,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..15bad631d 100644 --- a/lib/command/sfCommandApplication.class.php +++ b/lib/command/sfCommandApplication.class.php @@ -12,8 +12,6 @@ * sfCommandApplication manages the lifecycle of a CLI application. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfCommandApplication { @@ -39,7 +37,7 @@ abstract class sfCommandApplication protected $version = 'UNKNOWN'; /** @var array */ - protected $tasks = array(); + protected $tasks = []; /** @var sfTask */ protected $currentTask; @@ -48,7 +46,7 @@ abstract class sfCommandApplication protected $dispatcher; /** @var array */ - protected $options = array(); + protected $options = []; /** @var sfFormatter */ protected $formatter; @@ -62,7 +60,7 @@ abstract class sfCommandApplication * @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,17 +68,17 @@ public function __construct(sfEventDispatcher $dispatcher, sfFormatter $formatte $this->fixCgi(); - $argumentSet = new sfCommandArgumentSet(array( + $argumentSet = new sfCommandArgumentSet([ new sfCommandArgument('task', sfCommandArgument::REQUIRED, 'The task to execute'), - )); - $optionSet = new sfCommandOptionSet(array( + ]); + $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(); @@ -131,7 +129,7 @@ public function setFormatter(sfFormatter $formatter) public function clearTasks() { - $this->tasks = array(); + $this->tasks = []; } /** @@ -183,7 +181,7 @@ public function registerTask(sfTask $task) */ public function autodiscoverTasks() { - $tasks = array(); + $tasks = []; foreach (get_declared_classes() as $class) { $r = new ReflectionClass($class); @@ -329,11 +327,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( @@ -356,13 +354,13 @@ 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)); @@ -390,12 +388,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'] : ''; @@ -429,7 +427,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(); @@ -450,7 +448,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 +461,7 @@ public function getTaskToExecute($name) } // aliases - $aliases = array(); + $aliases = []; foreach ($this->tasks as $taskName => $task) { if ($taskName == $task->getFullName()) { foreach ($task->getAliases() as $alias) { @@ -594,8 +592,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 +607,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 +621,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; diff --git a/lib/command/sfCommandArgument.class.php b/lib/command/sfCommandArgument.class.php index 380590e80..3d6d2515c 100644 --- a/lib/command/sfCommandArgument.class.php +++ b/lib/command/sfCommandArgument.class.php @@ -12,8 +12,6 @@ * Represents a command line argument. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCommandArgument { @@ -97,7 +95,7 @@ public function setDefault($default = null) 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.'); } diff --git a/lib/command/sfCommandArgumentSet.class.php b/lib/command/sfCommandArgumentSet.class.php index b641a8603..3e7f882d3 100644 --- a/lib/command/sfCommandArgumentSet.class.php +++ b/lib/command/sfCommandArgumentSet.class.php @@ -12,12 +12,10 @@ * Represent a set of command line arguments. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCommandArgumentSet { - protected $arguments = array(); + protected $arguments = []; protected $requiredCount = 0; protected $hasAnArrayArgument = false; protected $hasOptional = false; @@ -27,7 +25,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 +35,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 +48,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) { @@ -160,7 +158,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 e489fa311..6147ab02b 100644 --- a/lib/command/sfCommandArgumentsException.class.php +++ b/lib/command/sfCommandArgumentsException.class.php @@ -12,7 +12,7 @@ * sfCommandException is thrown when an error occurs in a task. * * @author Fabien Potencier - * - * @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 3a680ad9d..12e5cc9c6 100644 --- a/lib/command/sfCommandException.class.php +++ b/lib/command/sfCommandException.class.php @@ -12,7 +12,7 @@ * sfCommandException is thrown when an error occurs in a task. * * @author Fabien Potencier - * - * @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..77673b5c1 100644 --- a/lib/command/sfCommandLogger.class.php +++ b/lib/command/sfCommandLogger.class.php @@ -10,8 +10,6 @@ /** * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCommandLogger extends sfConsoleLogger { @@ -21,9 +19,9 @@ class sfCommandLogger extends sfConsoleLogger * @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); } diff --git a/lib/command/sfCommandManager.class.php b/lib/command/sfCommandManager.class.php index 7d148ada3..aea4b6bf3 100644 --- a/lib/command/sfCommandManager.class.php +++ b/lib/command/sfCommandManager.class.php @@ -12,8 +12,6 @@ * Class to manage command line arguments and options. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCommandManager { @@ -21,22 +19,22 @@ class sfCommandManager protected $arguments = ''; /** @var string[] */ - protected $errors = array(); + protected $errors = []; /** @var sfCommandOptionSet */ protected $optionSet; /** @var sfCommandArgumentSet */ - protected $argumentSet = array(); + protected $argumentSet = []; /** @var array */ - protected $optionValues = array(); + protected $optionValues = []; /** @var array */ - protected $argumentValues = array(); + protected $argumentValues = []; /** @var array */ - protected $parsedArgumentValues = array(); + protected $parsedArgumentValues = []; /** * Constructor. @@ -44,7 +42,7 @@ class sfCommandManager * @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(); @@ -123,10 +121,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); diff --git a/lib/command/sfCommandOption.class.php b/lib/command/sfCommandOption.class.php index 43e1f91d3..d525aa7e9 100644 --- a/lib/command/sfCommandOption.class.php +++ b/lib/command/sfCommandOption.class.php @@ -12,8 +12,6 @@ * Represents a command line option. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCommandOption { @@ -145,7 +143,7 @@ public function setDefault($default = null) 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.'); } diff --git a/lib/command/sfCommandOptionSet.class.php b/lib/command/sfCommandOptionSet.class.php index 49792f5db..e8e00cb57 100644 --- a/lib/command/sfCommandOptionSet.class.php +++ b/lib/command/sfCommandOptionSet.class.php @@ -12,20 +12,18 @@ * Represent a set of command line options. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ 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 +33,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 +45,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); @@ -147,7 +145,7 @@ public function getOptionForShortcut($shortcut) */ public function getDefaults() { - $values = array(); + $values = []; foreach ($this->options as $option) { $values[$option->getName()] = $option->getDefault(); } diff --git a/lib/command/sfFormatter.class.php b/lib/command/sfFormatter.class.php index a73feedc1..d37829c87 100644 --- a/lib/command/sfFormatter.class.php +++ b/lib/command/sfFormatter.class.php @@ -12,8 +12,6 @@ * sfFormatter provides methods to format text to be displayed on a console. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfFormatter { @@ -39,7 +37,9 @@ 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 = []) + { + } /** * Formats a text according to the given parameters. @@ -49,7 +49,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..bec81a576 100644 --- a/lib/command/sfSymfonyCommandApplication.class.php +++ b/lib/command/sfSymfonyCommandApplication.class.php @@ -12,12 +12,10 @@ * sfSymfonyCommandApplication manages the symfony CLI. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfSymfonyCommandApplication extends sfCommandApplication { - protected $taskFiles = array(); + protected $taskFiles = []; /** * Configures the current symfony command application. @@ -83,7 +81,7 @@ public function run($options = null) 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) { @@ -101,7 +99,7 @@ public function loadTasks(sfProjectConfiguration $configuration) } // 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 +108,7 @@ class_exists($task, true); } // unregister local autoloader - spl_autoload_unregister(array($this, 'autoloadTask')); + spl_autoload_unregister([$this, 'autoloadTask']); } /** diff --git a/lib/config/sfApplicationConfiguration.class.php b/lib/config/sfApplicationConfiguration.class.php index ecf4db22a..cf7aba139 100644 --- a/lib/config/sfApplicationConfiguration.class.php +++ b/lib/config/sfApplicationConfiguration.class.php @@ -14,19 +14,17 @@ * sfConfiguration represents a configuration for a symfony application. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ 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; /** @@ -37,7 +35,7 @@ abstract class sfApplicationConfiguration extends ProjectConfiguration * @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; @@ -68,14 +66,18 @@ public function __construct($environment, $debug, $rootDir = null, sfEventDispat * * Override this method if you want to customize your application configuration. */ - public function configure() {} + public function configure() + { + } /** * Initialized the current configuration. * * Override this method if you want to customize your application initialization. */ - public function initialize() {} + public function initialize() + { + } public function activate() { @@ -101,7 +103,7 @@ public function initConfiguration() } // autoloader(s) - $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); + $this->dispatcher->connect('autoload.filter_config', [$this, 'filterAutoloadConfig']); sfAutoload::getInstance()->register(); if ($this->isDebug()) { sfAutoloadAgain::getInstance()->register(); @@ -128,7 +130,23 @@ public function initConfiguration() } // error settings - ini_set('display_errors', $this->isDebug() ? 'on' : 'off'); + // Based on the debug setting ($this->isDebug()), it controls if errors should be displayed + // (display_errors). If the application is not in the debug mode or if it's running in a + // CLI, PHPDBG, or embed server API, then errors are not displayed (display_errors is set + // to 0). However, if the application is in debug mode and errors are not already logged to + // the error log, then errors are displayed (display_errors is set to 1). + if ( + !$this->isDebug() + || !in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) + ) { + ini_set('display_errors', 0); + } elseif ( + !filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) + || ini_get('error_log') + ) { + // CLI - display errors only if they're not already logged to STDERR + ini_set('display_errors', 1); + } error_reporting(sfConfig::get('sf_error_reporting')); // initialize plugin configuration objects @@ -180,12 +198,12 @@ public function checkLock() || $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( + $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)) { @@ -211,12 +229,12 @@ 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()); } @@ -228,7 +246,7 @@ public function setRootDir($rootDir) */ public function setAppDir($appDir) { - sfConfig::add(array( + sfConfig::add([ 'sf_app_dir' => $appDir, // SF_APP_DIR directory structure @@ -237,7 +255,7 @@ 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', - )); + ]); } /** @@ -247,7 +265,7 @@ 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(), @@ -257,7 +275,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', - )); + ]); } /** @@ -270,7 +288,7 @@ 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 @@ -299,7 +317,7 @@ public function getControllerDirs($moduleName) */ public function getLibDirs($moduleName) { - $dirs = array(); + $dirs = []; $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib'; // application $dirs = array_merge($dirs, $this->getPluginSubPaths('/modules/'.$moduleName.'/lib')); // plugins @@ -318,7 +336,7 @@ public function getLibDirs($moduleName) */ public function getTemplateDirs($moduleName) { - $dirs = array(); + $dirs = []; $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/templates'; // application $dirs = array_merge($dirs, $this->getPluginSubPaths('/modules/'.$moduleName.'/templates')); // plugins @@ -337,7 +355,7 @@ public function getTemplateDirs($moduleName) */ public function getHelperDirs($moduleName = '') { - $dirs = array(); + $dirs = []; if ($moduleName) { $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/lib/helper'; // module @@ -347,12 +365,12 @@ public function getHelperDirs($moduleName = '') return array_merge( $dirs, - array( + [ 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 ); } @@ -414,7 +432,7 @@ public function getPluginPaths() */ public function getDecoratorDirs() { - return array(sfConfig::get('sf_app_template_dir')); + return [sfConfig::get('sf_app_template_dir')]; } /** @@ -440,7 +458,7 @@ public function getDecoratorDir($template) */ public function getI18NGlobalDirs() { - $dirs = array(); + $dirs = []; // application if (is_dir($dir = sfConfig::get('sf_app_i18n_dir'))) { @@ -460,7 +478,7 @@ public function getI18NGlobalDirs() */ public function getI18NDirs($moduleName) { - $dirs = array(); + $dirs = []; // module if (is_dir($dir = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/i18n')) { @@ -490,9 +508,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)) { @@ -500,12 +518,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 - )); + ]); foreach ($this->getPluginPaths() as $path) { if (is_file($file = $path.'/'.$configPath)) { @@ -515,7 +533,7 @@ public function getConfigPaths($configPath) $files[] = sfConfig::get('sf_app_dir').'/'.$configPath; // module - $configs = array(); + $configs = []; foreach (array_unique($files) as $file) { if (is_readable($file)) { $configs[] = $file; @@ -560,7 +578,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..2b7cb7a5c 100755 --- a/lib/config/sfAutoloadConfigHandler.class.php +++ b/lib/config/sfAutoloadConfigHandler.class.php @@ -12,8 +12,6 @@ /** * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfAutoloadConfigHandler extends sfYamlConfigHandler { @@ -30,9 +28,9 @@ class sfAutoloadConfigHandler extends sfYamlConfigHandler 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 +51,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 +63,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 = ''; @@ -91,7 +89,7 @@ public static function getConfiguration(array $configFiles) $configuration = sfProjectConfiguration::getActive(); $pluginPaths = $configuration->getPluginPaths(); - $pluginConfigFiles = array(); + $pluginConfigFiles = []; // move plugin files to front foreach ($configFiles as $i => $configFile) { @@ -124,9 +122,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'])) { diff --git a/lib/config/sfCacheConfigHandler.class.php b/lib/config/sfCacheConfigHandler.class.php index 45b87138f..b531d9555 100644 --- a/lib/config/sfCacheConfigHandler.class.php +++ b/lib/config/sfCacheConfigHandler.class.php @@ -12,12 +12,10 @@ * sfCacheConfigHandler allows you to configure cache. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfCacheConfigHandler extends sfYamlConfigHandler { - protected $cacheConfig = array(); + protected $cacheConfig = []; /** * Executes this configuration handler. @@ -26,9 +24,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 +34,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) { @@ -80,7 +78,7 @@ public static function getConfiguration(array $configFiles) */ protected function addCache($actionName = '') { - $data = array(); + $data = []; // enabled? $enabled = $this->getConfigValue('enabled', $actionName); @@ -92,15 +90,15 @@ protected function addCache($actionName = '') $lifeTime = !$enabled ? '0' : $this->getConfigValue('lifetime', $actionName, '0'); // client_lifetime - $clientLifetime = !$enabled ? '0' : $this->getConfigValue('client_lifetime', $actionName, $lifeTime, '0'); + $clientLifetime = !$enabled ? '0' : $this->getConfigValue('client_lifetime', $actionName, $lifeTime); // contextual $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..7bbd8cffb 100644 --- a/lib/config/sfCompileConfigHandler.class.php +++ b/lib/config/sfCompileConfigHandler.class.php @@ -15,8 +15,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfCompileConfigHandler extends sfYamlConfigHandler { @@ -53,13 +51,13 @@ public function execute($configFiles) } // 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; @@ -81,7 +79,7 @@ public function execute($configFiles) */ 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..2ad673ea7 100644 --- a/lib/config/sfConfig.class.php +++ b/lib/config/sfConfig.class.php @@ -12,12 +12,10 @@ * sfConfig stores all configuration information for a symfony application. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfConfig { - protected static $config = array(); + protected static $config = []; /** * Retrieves a config parameter. @@ -65,7 +63,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 +83,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 6280b7242..24654543f 100644 --- a/lib/config/sfConfigCache.class.php +++ b/lib/config/sfConfigCache.class.php @@ -16,14 +16,12 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfConfigCache { protected $configuration; - protected $handlers = array(); - protected $userHandlers = array(); + protected $handlers = []; + protected $userHandlers = []; /** * Constructor. @@ -49,7 +47,7 @@ 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() */ @@ -69,7 +67,7 @@ public function checkConfig($configPath, $optional = false) 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])) { @@ -125,7 +123,7 @@ 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; @@ -159,11 +157,11 @@ 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 string $params An array of options for the handler class initialization + * @param string $handler The handler to use when parsing a configuration file + * @param class-string $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 +173,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 +204,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)) { @@ -251,7 +249,7 @@ 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() { @@ -270,7 +268,7 @@ protected function loadConfigHandlers() } // 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 +283,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); @@ -365,6 +363,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 728033f8f..1c402f540 100644 --- a/lib/config/sfConfigHandler.class.php +++ b/lib/config/sfConfigHandler.class.php @@ -16,8 +16,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ abstract class sfConfigHandler { @@ -41,7 +39,7 @@ 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) { @@ -56,8 +54,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); diff --git a/lib/config/sfDatabaseConfigHandler.class.php b/lib/config/sfDatabaseConfigHandler.class.php index 8113693f7..c1ed33ac6 100644 --- a/lib/config/sfDatabaseConfigHandler.class.php +++ b/lib/config/sfDatabaseConfigHandler.class.php @@ -16,8 +16,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfDatabaseConfigHandler extends sfYamlConfigHandler { @@ -62,7 +60,7 @@ public function evaluate($configFiles) require_once $include; } - $databases = array(); + $databases = []; foreach ($data as $name => $database) { $databases[$name] = new $database[0]($database[1]); } @@ -92,9 +90,9 @@ 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) { @@ -125,16 +123,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..b43dd0b1a 100644 --- a/lib/config/sfDefineEnvironmentConfigHandler.class.php +++ b/lib/config/sfDefineEnvironmentConfigHandler.class.php @@ -10,8 +10,6 @@ /** * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfDefineEnvironmentConfigHandler extends sfYamlConfigHandler { @@ -41,7 +39,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)); } @@ -85,10 +83,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 +110,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 eb61473ca..95e067f7b 100644 --- a/lib/config/sfFactoryConfigHandler.class.php +++ b/lib/config/sfFactoryConfigHandler.class.php @@ -15,8 +15,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfFactoryConfigHandler extends sfYamlConfigHandler { @@ -27,8 +25,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 +34,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) { @@ -66,7 +64,7 @@ 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])); @@ -96,7 +94,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'); diff --git a/lib/config/sfFilterConfigHandler.class.php b/lib/config/sfFilterConfigHandler.class.php index 076c2af9e..d9d221e27 100644 --- a/lib/config/sfFilterConfigHandler.class.php +++ b/lib/config/sfFilterConfigHandler.class.php @@ -14,8 +14,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfFilterConfigHandler extends sfYamlConfigHandler { @@ -35,8 +33,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; @@ -125,7 +123,7 @@ 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; diff --git a/lib/config/sfGeneratorConfigHandler.class.php b/lib/config/sfGeneratorConfigHandler.class.php index adcf8700c..32279c9c1 100644 --- a/lib/config/sfGeneratorConfigHandler.class.php +++ b/lib/config/sfGeneratorConfigHandler.class.php @@ -12,8 +12,6 @@ * sfGeneratorConfigHandler. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfGeneratorConfigHandler extends sfYamlConfigHandler { @@ -46,7 +44,7 @@ public function execute($configFiles) 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)); } @@ -56,7 +54,7 @@ public function execute($configFiles) $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); diff --git a/lib/config/sfPluginConfiguration.class.php b/lib/config/sfPluginConfiguration.class.php index e5caac9b6..aa80e077d 100644 --- a/lib/config/sfPluginConfiguration.class.php +++ b/lib/config/sfPluginConfiguration.class.php @@ -12,8 +12,6 @@ * sfPluginConfiguration represents a configuration for a symfony plugin. * * @author Kris Wallsmith - * - * @version SVN: $Id$ */ abstract class sfPluginConfiguration { @@ -50,14 +48,18 @@ public function __construct(sfProjectConfiguration $configuration, $rootDir = nu * * This method can be used when creating a base plugin configuration class for other plugins to extend. */ - public function setup() {} + public function setup() + { + } /** * Configures the plugin. * * This method is called before the plugin's classes have been added to sfAutoload. */ - public function configure() {} + public function configure() + { + } /** * Initializes the plugin. @@ -66,7 +68,9 @@ public function configure() {} * * @return bool|null If false sfApplicationConfiguration will look for a config.php (maintains BC with symfony < 1.2) */ - public function initialize() {} + public function initialize() + { + } /** * Returns the plugin root directory. @@ -102,9 +106,9 @@ public function initializeAutoload() $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'); } @@ -121,22 +125,22 @@ 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; @@ -147,7 +151,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,7 +167,7 @@ public function filterTestFiles(sfEvent $event, $files) if ($task instanceof sfTestAllTask) { $directory = $this->rootDir.'/test'; - $names = array(); + $names = []; } elseif ($task instanceof sfTestFunctionalTask) { $directory = $this->rootDir.'/test/functional'; $names = $event['arguments']['controller']; @@ -173,7 +177,7 @@ public function filterTestFiles(sfEvent $event, $files) } if (!count($names)) { - $names = array('*'); + $names = ['*']; } foreach ($names as $name) { diff --git a/lib/config/sfPluginConfigurationGeneric.class.php b/lib/config/sfPluginConfigurationGeneric.class.php index d7d9eff99..a24661728 100644 --- a/lib/config/sfPluginConfigurationGeneric.class.php +++ b/lib/config/sfPluginConfigurationGeneric.class.php @@ -12,8 +12,6 @@ * sfPluginConfigurationGeneric represents a configuration for a plugin with no configuration class. * * @author Kris Wallsmith - * - * @version SVN: $Id$ */ class sfPluginConfigurationGeneric extends sfPluginConfiguration { diff --git a/lib/config/sfProjectConfiguration.class.php b/lib/config/sfProjectConfiguration.class.php index b31b4d084..c3d8fff3b 100644 --- a/lib/config/sfProjectConfiguration.class.php +++ b/lib/config/sfProjectConfiguration.class.php @@ -12,8 +12,6 @@ * sfProjectConfiguration represents a configuration for a symfony project. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfProjectConfiguration { @@ -27,16 +25,16 @@ class sfProjectConfiguration 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; @@ -87,7 +85,7 @@ public function __construct(?string $rootDir = null, ?sfEventDispatcher $dispatc */ 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)); } @@ -100,7 +98,9 @@ public function __call($method, $arguments) * * Override this method if you want to customize your project configuration. */ - public function setup() {} + public function setup() + { + } /** * Loads the project's plugin configurations. @@ -131,7 +131,9 @@ public function loadPlugins() * * Override this method if you want to customize plugin configurations. */ - public function setupPlugins() {} + public function setupPlugins() + { + } /** * Sets the project root directory. @@ -142,18 +144,18 @@ public function setRootDir($rootDir) { $this->rootDir = $rootDir; - sfConfig::add(array( + sfConfig::add([ 'sf_root_dir' => $rootDir, - // global directory structure - 'sf_apps_dir' => $rootDir.DIRECTORY_SEPARATOR.'portal', - 'sf_lib_dir' => $rootDir.DIRECTORY_SEPARATOR.'lib', - 'sf_log_dir' => $rootDir.DIRECTORY_SEPARATOR.'log', - 'sf_data_dir' => $rootDir.DIRECTORY_SEPARATOR.'data', - 'sf_config_dir' => $rootDir.DIRECTORY_SEPARATOR.'config', - 'sf_test_dir' => $rootDir.DIRECTORY_SEPARATOR.'test', - 'sf_plugins_dir' => $rootDir.DIRECTORY_SEPARATOR.'plugins', - )); + // global directory structure + 'sf_apps_dir' => $rootDir.DIRECTORY_SEPARATOR.'portal', + 'sf_lib_dir' => $rootDir.DIRECTORY_SEPARATOR.'lib', + 'sf_log_dir' => $rootDir.DIRECTORY_SEPARATOR.'log', + 'sf_data_dir' => $rootDir.DIRECTORY_SEPARATOR.'data', + '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'); @@ -196,11 +198,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, - )); + ]); } /** @@ -213,7 +215,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 ); } @@ -228,9 +230,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) ); } @@ -246,9 +248,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) ); } @@ -287,9 +289,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)) { @@ -297,10 +299,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)) { @@ -308,7 +310,7 @@ public function getConfigPaths($configPath) } } - $configs = array(); + $configs = []; foreach (array_unique($files) as $file) { if (is_readable($file)) { $configs[] = $file; @@ -333,7 +335,7 @@ public function setPlugins(array $plugins) $this->plugins = $plugins; - $this->pluginPaths = array(); + $this->pluginPaths = []; } /** @@ -347,7 +349,7 @@ public function enablePlugins($plugins) if (func_num_args() > 1) { $plugins = func_get_args(); } else { - $plugins = array($plugins); + $plugins = [$plugins]; } } @@ -368,7 +370,7 @@ public function disablePlugins($plugins) } if (!is_array($plugins)) { - $plugins = array($plugins); + $plugins = [$plugins]; } foreach ($plugins as $plugin) { @@ -379,7 +381,7 @@ public function disablePlugins($plugins) } } - $this->pluginPaths = array(); + $this->pluginPaths = []; } /** @@ -389,7 +391,7 @@ public function disablePlugins($plugins) * * @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.'); @@ -425,7 +427,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)) { @@ -448,7 +450,7 @@ 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]; @@ -468,15 +470,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( + $dirs = [ $this->getSymfonyLibDir().'/plugins', sfConfig::get('sf_plugins_dir'), - ); + ]; foreach ($finder->in($dirs) as $path) { $pluginPaths[basename($path)] = $path; diff --git a/lib/config/sfRootConfigHandler.class.php b/lib/config/sfRootConfigHandler.class.php index e4837cae6..d7dfcbf9d 100644 --- a/lib/config/sfRootConfigHandler.class.php +++ b/lib/config/sfRootConfigHandler.class.php @@ -13,8 +13,6 @@ * application or on a module level. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfRootConfigHandler extends sfYamlConfigHandler { @@ -42,8 +40,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) { diff --git a/lib/config/sfRoutingConfigHandler.class.php b/lib/config/sfRoutingConfigHandler.class.php index ac82d5cc9..f917bd4ab 100644 --- a/lib/config/sfRoutingConfigHandler.class.php +++ b/lib/config/sfRoutingConfigHandler.class.php @@ -10,8 +10,6 @@ /** * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfRoutingConfigHandler extends sfYamlConfigHandler { @@ -30,14 +28,14 @@ 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]); /** @var sfRoute $route */ $route = $r->newInstanceArgs($routeConfig[1]); - $routes = $route instanceof sfRouteCollection ? $route : array($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,7 +55,7 @@ public function evaluate($configFiles) { $routeDefinitions = $this->parse($configFiles); - $routes = array(); + $routes = []; foreach ($routeDefinitions as $name => $route) { $r = new ReflectionClass($route[0]); $routes[$name] = $r->newInstanceArgs($route[1]); @@ -87,24 +85,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')) ) { - $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 092f8e267..cf145cd9d 100644 --- a/lib/config/sfSecurityConfigHandler.class.php +++ b/lib/config/sfSecurityConfigHandler.class.php @@ -12,8 +12,6 @@ * sfSecurityConfigHandler allows you to configure action security. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfSecurityConfigHandler extends sfYamlConfigHandler { @@ -24,9 +22,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) { diff --git a/lib/config/sfServiceConfigHandler.class.php b/lib/config/sfServiceConfigHandler.class.php index 2bc86f8d0..0735f5fa6 100644 --- a/lib/config/sfServiceConfigHandler.class.php +++ b/lib/config/sfServiceConfigHandler.class.php @@ -12,8 +12,6 @@ * sfSecurityConfigHandler allows you to configure action security. * * @author Jerome Tamarelle - * - * @version SVN: $Id$ */ class sfServiceConfigHandler extends sfYamlConfigHandler { @@ -34,10 +32,10 @@ public function execute($configFiles) $loader->load(static::getConfiguration($configFiles)); $dumper = new sfServiceContainerDumperPhp($serviceContainerBuilder); - $code = $dumper->dump(array( + $code = $dumper->dump([ 'class' => $class, 'base_class' => $this->parameterHolder->get('base_class'), - )); + ]); // compile data $retval = sprintf( diff --git a/lib/config/sfSimpleYamlConfigHandler.class.php b/lib/config/sfSimpleYamlConfigHandler.class.php index 827f77e24..aaedc3574 100644 --- a/lib/config/sfSimpleYamlConfigHandler.class.php +++ b/lib/config/sfSimpleYamlConfigHandler.class.php @@ -12,8 +12,6 @@ * sfSimpleYamlConfigHandler allows you to load simple configuration files formatted as YAML. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfSimpleYamlConfigHandler extends sfYamlConfigHandler { diff --git a/lib/config/sfViewConfigHandler.class.php b/lib/config/sfViewConfigHandler.class.php index c34d6d539..4df6dd7e4 100644 --- a/lib/config/sfViewConfigHandler.class.php +++ b/lib/config/sfViewConfigHandler.class.php @@ -12,8 +12,6 @@ * sfViewConfigHandler allows you to configure views. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfViewConfigHandler extends sfYamlConfigHandler { @@ -24,9 +22,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 +32,7 @@ public function execute($configFiles) $this->yamlConfig = static::getConfiguration($configFiles); // init our data array - $data = array(); + $data = []; $data[] = "\$response = \$this->context->getResponse();\n\n"; @@ -125,7 +123,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,7 +213,7 @@ 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)); @@ -257,7 +255,7 @@ protected function addHtmlAsset($viewName = '') */ protected function addEscaping($viewName = '') { - $data = array(); + $data = []; $escaping = $this->getConfigValue('escaping', $viewName); @@ -271,16 +269,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() + isset($config['default']) && is_array($config['default']) ? $config['default'] : [], + isset($config['all']) && is_array($config['all']) ? $config['all'] : [] ); unset($config['default']); @@ -298,7 +296,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 +309,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..d1ea1e798 100644 --- a/lib/config/sfYamlConfigHandler.class.php +++ b/lib/config/sfYamlConfigHandler.class.php @@ -13,8 +13,6 @@ * provides a central location for parsing YAML files. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfYamlConfigHandler extends sfConfigHandler { @@ -30,10 +28,10 @@ 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; @@ -71,14 +69,14 @@ public static function parseYaml($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() + isset($config['default']) && is_array($config['default']) ? $config['default'] : [], + isset($config['all']) && is_array($config['all']) ? $config['all'] : [] ); unset($config['default']); @@ -96,9 +94,9 @@ 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() + 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 +110,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 65a7626b7..639ea95ed 100644 --- a/lib/controller/default/actions/actions.class.php +++ b/lib/controller/default/actions/actions.class.php @@ -12,38 +12,48 @@ * defaultActions module. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class defaultActions extends sfActions { /** * Congratulations page for creating an application. */ - public function executeIndex() {} + public function executeIndex() + { + } /** * Congratulations page for creating a module. */ - public function executeModule() {} + public function executeModule() + { + } /** * Error page for page not found (404) error. */ - public function executeError404() {} + public function executeError404() + { + } /** * Warning page for restricted area - requires login. */ - public function executeSecure() {} + public function executeSecure() + { + } /** * Warning page for restricted area - requires credentials. */ - public function executeLogin() {} + public function executeLogin() + { + } /** * Module disabled in settings.yml. */ - public function executeDisabled() {} + public function executeDisabled() + { + } } 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..ea2603779 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.
diff --git a/lib/controller/default/templates/moduleSuccess.php b/lib/controller/default/templates/moduleSuccess.php index b4dc0bdcd..f26727222 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.
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..b420285fc 100644 --- a/lib/controller/sfController.class.php +++ b/lib/controller/sfController.class.php @@ -14,8 +14,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ abstract class sfController { @@ -26,7 +24,7 @@ abstract class sfController protected $dispatcher; /** @var string[] */ - protected $controllerClasses = array(); + protected $controllerClasses = []; /** @var int */ protected $renderMode = sfView::RENDER_CLIENT; @@ -58,7 +56,7 @@ public function __construct($context) */ 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)); } @@ -131,7 +129,7 @@ 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)))); + $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)); @@ -163,13 +161,13 @@ public function forward($moduleName, $actionName) $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')) { $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 @@ -283,7 +281,7 @@ public function getView($moduleName, $actionName, $viewName) 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)))); + $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 @@ -450,7 +448,7 @@ 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)); + $dirs = array_map(['sfDebug', 'shortenFilePath'], array_keys($dirs)); throw new sfControllerException(sprintf('Controller "%s/%s" does not exist in: %s.', $moduleName, $controllerName, implode(', ', $dirs))); } diff --git a/lib/controller/sfFrontWebController.class.php b/lib/controller/sfFrontWebController.class.php index 5e2becdd5..073dea69c 100644 --- a/lib/controller/sfFrontWebController.class.php +++ b/lib/controller/sfFrontWebController.class.php @@ -16,8 +16,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfFrontWebController extends sfWebController { @@ -30,7 +28,7 @@ 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 */ diff --git a/lib/controller/sfWebController.class.php b/lib/controller/sfWebController.class.php index b4ca30b67..74eb60d85 100644 --- a/lib/controller/sfWebController.class.php +++ b/lib/controller/sfWebController.class.php @@ -14,8 +14,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ abstract class sfWebController extends sfController { @@ -27,7 +25,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 = ''; @@ -84,7 +82,7 @@ public function convertUrlStringToParameters($url) { $givenUrl = $url; - $params = array(); + $params = []; $queryString = ''; $route = ''; @@ -139,7 +137,7 @@ public function convertUrlStringToParameters($url) } } - return array($route, $params); + return [$route, $params]; } /** @@ -163,7 +161,7 @@ public function redirect($url, $delay = 0, $statusCode = 302) $url = str_replace('&', '&', $url); if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Redirect to "%s"', $url)))); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Redirect to "%s"', $url)])); } // redirect diff --git a/lib/database/sfDatabase.class.php b/lib/database/sfDatabase.class.php index 9034b2e27..a380050cd 100644 --- a/lib/database/sfDatabase.class.php +++ b/lib/database/sfDatabase.class.php @@ -15,8 +15,6 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ abstract class sfDatabase { @@ -36,7 +34,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,9 +44,9 @@ 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->add($parameters); @@ -57,7 +55,7 @@ public function initialize($parameters = array()) /** * 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 +67,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 +83,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() { @@ -163,7 +161,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 d1313aeae..c293005ed 100644 --- a/lib/database/sfDatabaseManager.class.php +++ b/lib/database/sfDatabaseManager.class.php @@ -16,14 +16,12 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ class sfDatabaseManager { /** @var sfProjectConfiguration */ protected $configuration; - protected $databases = array(); + protected $databases = []; /** * Class constructor. @@ -32,12 +30,12 @@ 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']); } } @@ -46,7 +44,7 @@ public function __construct(sfProjectConfiguration $configuration, $options = ar * * @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) { @@ -64,7 +62,7 @@ public function loadConfiguration() $databases = include $this->configuration->getConfigCache()->checkConfig('config/databases.yml'); } else { $configHandler = new sfDatabaseConfigHandler(); - $databases = $configHandler->evaluate(array($this->configuration->getRootDir().'/config/databases.yml')); + $databases = $configHandler->evaluate([$this->configuration->getRootDir().'/config/databases.yml']); } foreach ($databases as $name => $database) { @@ -90,7 +88,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') { @@ -115,7 +113,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 fac1ccd9f..88d315f12 100644 --- a/lib/database/sfMySQLDatabase.class.php +++ b/lib/database/sfMySQLDatabase.class.php @@ -22,15 +22,13 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ 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() { @@ -77,7 +75,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 3fb6554e8..a7c485c39 100644 --- a/lib/database/sfMySQLiDatabase.class.php +++ b/lib/database/sfMySQLiDatabase.class.php @@ -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 591f09119..73c02cbdb 100644 --- a/lib/database/sfPDODatabase.class.php +++ b/lib/database/sfPDODatabase.class.php @@ -12,12 +12,10 @@ /** * sfPDODatabase provides connectivity for the PDO database abstraction layer. * - * @author Daniel Swarbrick (daniel@pressure.net.nz) + * @author Daniel Swarbrick * @author Fabien Potencier * @author Sean Kerr * @author Dustin Whittle - * - * @version SVN: $Id$ */ class sfPDODatabase extends sfDatabase { @@ -29,13 +27,13 @@ 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() { @@ -50,7 +48,7 @@ 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) { diff --git a/lib/database/sfPostgreSQLDatabase.class.php b/lib/database/sfPostgreSQLDatabase.class.php index 3ebe5e30c..a66bb2a53 100644 --- a/lib/database/sfPostgreSQLDatabase.class.php +++ b/lib/database/sfPostgreSQLDatabase.class.php @@ -23,15 +23,13 @@ * * @author Fabien Potencier * @author Sean Kerr - * - * @version SVN: $Id$ */ 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() { @@ -68,7 +66,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 4a564d140..e671fe03a 100644 --- a/lib/debug/sfDebug.class.php +++ b/lib/debug/sfDebug.class.php @@ -12,8 +12,6 @@ * sfDebug provides some method to help debugging a symfony application. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfDebug { @@ -24,10 +22,10 @@ class sfDebug */ public static function symfonyInfoAsArray() { - return array( + return [ 'version' => SYMFONY_VERSION, 'path' => sfConfig::get('sf_symfony_lib_dir'), - ); + ]; } /** @@ -37,11 +35,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 +60,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; } @@ -101,17 +99,17 @@ public static function settingsAsArray() * * @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), - ); + ]; } /** @@ -121,22 +119,22 @@ public static function requestAsArray(sfRequest $request = null) * * @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() : [], + ]; } /** @@ -146,24 +144,24 @@ public static function responseAsArray(sfResponse $response = null) * * @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( + $data = array_merge($data, [ 'authenticated' => $user->isAuthenticated(), 'credentials' => $user->getCredentials(), 'lastRequest' => $user->getLastRequestTime(), - )); + ]); } return $data; @@ -179,10 +177,10 @@ public static function userAsArray(sfUser $user = null) */ public static function flattenParameterHolder($parameterHolder, $removeObjects = false) { - $values = array(); + $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 +210,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); @@ -235,7 +233,11 @@ public static function removeObjects($values) */ public static function shortenFilePath($file) { - foreach (array('sf_root_dir', 'sf_symfony_lib_dir') as $key) { + if (!$file) { + return $file; + } + + foreach (['sf_root_dir', 'sf_symfony_lib_dir'] as $key) { if (0 === strpos($file, $value = sfConfig::get($key))) { $file = str_replace($value, strtoupper($key), $file); diff --git a/lib/debug/sfTimer.class.php b/lib/debug/sfTimer.class.php index 8b85e0e9a..8540366fd 100644 --- a/lib/debug/sfTimer.class.php +++ b/lib/debug/sfTimer.class.php @@ -12,8 +12,6 @@ * sfTimer class allows to time some PHP code. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfTimer { diff --git a/lib/debug/sfTimerManager.class.php b/lib/debug/sfTimerManager.class.php index 110939ca8..e099797e2 100644 --- a/lib/debug/sfTimerManager.class.php +++ b/lib/debug/sfTimerManager.class.php @@ -12,13 +12,11 @@ * sfTimerManager is a container for sfTimer objects. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfTimerManager { /** @var sfTimer[] */ - public static $timers = array(); + public static $timers = []; /** * Gets a sfTimer instance. @@ -58,6 +56,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..3e1d2258b 100644 --- a/lib/debug/sfWebDebug.class.php +++ b/lib/debug/sfWebDebug.class.php @@ -12,15 +12,13 @@ * sfWebDebug creates debug information for easy debugging in the browser. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebug { protected $dispatcher; protected $logger; - protected $options = array(); - protected $panels = array(); + protected $options = []; + protected $panels = []; /** * Constructor. @@ -34,7 +32,7 @@ class sfWebDebug * @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,7 +43,7 @@ public function __construct(sfEventDispatcher $dispatcher, sfVarLogger $logger, } if (!isset($this->options['request_parameters'])) { - $this->options['request_parameters'] = array(); + $this->options['request_parameters'] = []; } $this->configure(); @@ -159,7 +157,7 @@ public function injectToolbar($content) } if (false !== $pos = $posFunction($content, '')) { - $styles = ''; + $styles = ''; $content = $substrFunction($content, 0, $pos).$styles.$substrFunction($content, $pos); } @@ -182,8 +180,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()) { diff --git a/lib/debug/sfWebDebugPanel.class.php b/lib/debug/sfWebDebugPanel.class.php index a6b3dc3b8..487feac49 100644 --- a/lib/debug/sfWebDebugPanel.class.php +++ b/lib/debug/sfWebDebugPanel.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanel represents a web debug panel. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ abstract class sfWebDebugPanel { @@ -35,7 +33,9 @@ public function __construct(sfWebDebug $webDebug) * * @return string The URL link */ - public function getTitleUrl() {} + public function getTitleUrl() + { + } /** * Gets the text for the link. @@ -164,7 +164,7 @@ public function formatFileLink($file, $line = null, $text = null) // return a link return sprintf( '%s', - htmlspecialchars(strtr($linkFormat, array('%f' => $file, '%l' => $line)), 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 ca98cee95..142067a74 100644 --- a/lib/debug/sfWebDebugPanelCache.class.php +++ b/lib/debug/sfWebDebugPanelCache.class.php @@ -13,8 +13,6 @@ * on the next request. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelCache extends sfWebDebugPanel { @@ -39,5 +37,7 @@ public function getPanelTitle() return 'reload and ignore cache'; } - public function getPanelContent() {} + public function getPanelContent() + { + } } diff --git a/lib/debug/sfWebDebugPanelConfig.class.php b/lib/debug/sfWebDebugPanelConfig.class.php index c0bee63e4..107281de1 100644 --- a/lib/debug/sfWebDebugPanelConfig.class.php +++ b/lib/debug/sfWebDebugPanelConfig.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelConfig adds a panel to the web debug toolbar with the current configuration. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelConfig extends sfWebDebugPanel { @@ -29,21 +27,19 @@ public function getPanelTitle() public function getPanelContent() { - $config = array( + $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', '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) { - $html .= '
  • '.$key.'
  • '; + $html .= '
  • '.$key.'
  • '; } $html .= '
'; diff --git a/lib/debug/sfWebDebugPanelLogs.class.php b/lib/debug/sfWebDebugPanelLogs.class.php index 58802582c..e077bed56 100644 --- a/lib/debug/sfWebDebugPanelLogs.class.php +++ b/lib/debug/sfWebDebugPanelLogs.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelLogs adds a panel to the web debug toolbar with log messages. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelLogs extends sfWebDebugPanel { @@ -61,7 +59,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,7 +89,7 @@ protected function formatLogLine($logLine) static $constants; if (!$constants) { - foreach (array('sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir') as $constant) { + foreach (['sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir'] as $constant) { $constants[realpath(sfConfig::get($constant)).DIRECTORY_SEPARATOR] = $constant.DIRECTORY_SEPARATOR; } } @@ -102,9 +100,9 @@ protected function formatLogLine($logLine) // 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); diff --git a/lib/debug/sfWebDebugPanelMailer.class.php b/lib/debug/sfWebDebugPanelMailer.class.php index ab31b24be..d1a7002f9 100644 --- a/lib/debug/sfWebDebugPanelMailer.class.php +++ b/lib/debug/sfWebDebugPanelMailer.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelMailer adds a panel to the web debug toolbar with sent emails. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelMailer extends sfWebDebugPanel { @@ -29,7 +27,7 @@ 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,7 +50,7 @@ public function getPanelContent() return false; } - $html = array(); + $html = []; // configuration information $strategy = $this->mailer->getDeliveryStrategy(); @@ -88,7 +86,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 c24d2f209..4fcf1d5c3 100644 --- a/lib/debug/sfWebDebugPanelMemory.class.php +++ b/lib/debug/sfWebDebugPanelMemory.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelMemory adds a panel to the web debug toolbar with the memory used by the script. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelMemory extends sfWebDebugPanel { @@ -24,7 +22,11 @@ public function getTitle() return 'Memory '.$totalMemory.' KB'; } - public function getPanelTitle() {} + public function getPanelTitle() + { + } - public function getPanelContent() {} + public function getPanelContent() + { + } } diff --git a/lib/debug/sfWebDebugPanelSymfonyVersion.class.php b/lib/debug/sfWebDebugPanelSymfonyVersion.class.php index 38fe66566..872453c52 100644 --- a/lib/debug/sfWebDebugPanelSymfonyVersion.class.php +++ b/lib/debug/sfWebDebugPanelSymfonyVersion.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelSymfonyVersion adds a panel to the web debug toolbar with the symfony version. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelSymfonyVersion extends sfWebDebugPanel { @@ -22,7 +20,11 @@ public function getTitle() return ''.SYMFONY_VERSION.''; } - public function getPanelTitle() {} + public function getPanelTitle() + { + } - public function getPanelContent() {} + public function getPanelContent() + { + } } diff --git a/lib/debug/sfWebDebugPanelTimer.class.php b/lib/debug/sfWebDebugPanelTimer.class.php index dc932edc5..3eb90d6c8 100644 --- a/lib/debug/sfWebDebugPanelTimer.class.php +++ b/lib/debug/sfWebDebugPanelTimer.class.php @@ -12,8 +12,6 @@ * sfWebDebugPanelTimer adds a panel to the web debug toolbar with timer information. * * @author Fabien Potencier - * - * @version SVN: $Id$ */ class sfWebDebugPanelTimer extends sfWebDebugPanel { @@ -28,7 +26,7 @@ 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() @@ -57,7 +55,7 @@ public function getPanelContent() 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..96af9c19f 100644 --- a/lib/debug/sfWebDebugPanelView.class.php +++ b/lib/debug/sfWebDebugPanelView.class.php @@ -17,8 +17,8 @@ */ class sfWebDebugPanelView extends sfWebDebugPanel { - protected $actions = array(); - protected $partials = array(); + protected $actions = []; + protected $partials = []; /** * Constructor. @@ -29,8 +29,8 @@ 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']); } /** @@ -38,8 +38,8 @@ public function __construct(sfWebDebug $webDebug) */ public function listenForChangeAction(sfEvent $event) { - $this->actions = array(); - $this->partials = array(); + $this->actions = []; + $this->partials = []; } /** @@ -51,12 +51,12 @@ public function listenForChangeAction(sfEvent $event) */ 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; @@ -85,7 +85,7 @@ public function getPanelTitle() */ public function getPanelContent() { - $html = array(); + $html = []; foreach ($this->actions as $action) { $html[] = $this->renderTemplateInformation($action['file'], $action['parameters']); @@ -135,7 +135,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 +143,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 { @@ -204,7 +204,7 @@ protected function formatFormAsHtml($name, sfForm $form) $this->setStatus(sfLogger::NOTICE); } - $html = array(); + $html = []; $html[] = $this->getParameterDescription($name, $form, $form->hasErrors() ? '$%s' : null); $html[] = $this->getToggler('sfWebDebugViewForm'.$i); $html[] = '