Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some new php cs rules #316

Draft
wants to merge 4 commits into
base: 1.6.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
45 changes: 37 additions & 8 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<?php

$finder = PhpCsFixer\Finder::create()
/*
* This file is part of the Symfony1 package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->ignoreVCSIgnored(true)
->in(__DIR__.'/lib')
->in(__DIR__.'/data/bin')
->in(__DIR__.'/test')
->append(array(__FILE__))
->append([__FILE__])
// Exclude PHP classes templates/generators, which are not valid PHP files
->exclude('task/generator/skeleton/')
->exclude('plugins/sfDoctrinePlugin/data/generator/')
Expand All @@ -14,14 +26,31 @@
->notPath('unit/config/fixtures/sfFilterConfigHandler/result.php')
;

$config = new PhpCsFixer\Config();
$config->setRules(array(
$config = new Config();
$config->setRules([
'@PhpCsFixer' => true,
'@Symfony' => true,
'array_syntax' => array(
'syntax' => 'long',
),
))
'@PSR12' => true,
'array_syntax' => [
'syntax' => 'short',
],
'fully_qualified_strict_types' => [
'import_symbols' => true,
'leading_backslash_in_global_namespace' => true,
],
'header_comment' => [
'header' => <<<'EOF'
This file is part of the Symfony1 package.

(c) Fabien Potencier <fabien@symfony.com>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF
],
'modernize_strpos' => true,
])
->setRiskyAllowed(true)
->setCacheFile('.php-cs-fixer.cache')
->setFinder($finder)
;
Expand Down
15 changes: 8 additions & 7 deletions data/bin/changelog.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
* This file is part of the Symfony1 package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -31,16 +32,16 @@
exit(1);
}

$filesystem = new sfFilesystem();
$filesystem = new \sfFilesystem();

list($out, $err) = $filesystem->execute('svn info --xml');
$info = new SimpleXMLElement($out);
$info = new \SimpleXMLElement($out);

list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', array(
list($out, $err) = $filesystem->execute(vsprintf('svn log %s --xml %s', array_map('escapeshellarg', [
$argv[1],
(string) $info->entry->repository->root.$argv[2],
))));
$log = new SimpleXMLElement($out);
])));
$log = new \SimpleXMLElement($out);

foreach ($log->logentry as $logentry) {
echo sprintf(' * [%d] %s', $logentry['revision'], trim(preg_replace('/\s*\[[\d\., ]+\]\s*/', '', (string) $logentry->msg)));
Expand Down
11 changes: 10 additions & 1 deletion data/bin/check_configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony1 package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

function is_cli()
{
return !isset($_SERVER['HTTP_HOST']);
Expand Down Expand Up @@ -67,7 +76,7 @@ function get_ini_path()
echo "\n** Optional checks **\n\n";
check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Doctrine)', false);
if (class_exists('PDO')) {
$drivers = PDO::getAvailableDrivers();
$drivers = \PDO::getAvailableDrivers();
check(count($drivers), 'PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Doctrine)');
}
check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false);
Expand Down
23 changes: 12 additions & 11 deletions data/bin/release.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/*
* This file is part of the symfony package.
* (c) 2004-2007 Fabien Potencier <fabien.potencier@symfony-project.com>
* This file is part of the Symfony1 package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -26,16 +27,16 @@
require_once __DIR__.'/../../lib/vendor/lime/lime.php';

if (!isset($argv[1])) {
throw new Exception('You must provide version prefix.');
throw new \Exception('You must provide version prefix.');
}

if (!isset($argv[2])) {
throw new Exception('You must provide stability status (alpha/beta/stable).');
throw new \Exception('You must provide stability status (alpha/beta/stable).');
}

$stability = $argv[2];

$filesystem = new sfFilesystem();
$filesystem = new \sfFilesystem();

if (('beta' == $stability || 'alpha' == $stability) && count(explode('.', $argv[1])) < 2) {
$version_prefix = $argv[1];
Expand All @@ -46,7 +47,7 @@
}

if (!isset($version)) {
throw new Exception('Unable to find last SVN revision.');
throw new \Exception('Unable to find last SVN revision.');
}

// make a PEAR compatible version
Expand All @@ -61,7 +62,7 @@
list($result) = $filesystem->execute('php data/bin/symfony symfony:test');

if (0 != $result) {
throw new Exception('Some tests failed. Release process aborted!');
throw new \Exception('Some tests failed. Release process aborted!');
}

if (is_file('package.xml')) {
Expand All @@ -71,9 +72,9 @@
$filesystem->copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml');

// add class files
$finder = sfFinder::type('file')->relative();
$finder = \sfFinder::type('file')->relative();
$xml_classes = '';
$dirs = array('lib' => 'php', 'data' => 'data');
$dirs = ['lib' => 'php', 'data' => 'data'];
foreach ($dirs as $dir => $role) {
$class_files = $finder->in($dir);
foreach ($class_files as $file) {
Expand All @@ -82,12 +83,12 @@
}

// replace tokens
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', array(
$filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', [
'SYMFONY_VERSION' => $version,
'CURRENT_DATE' => date('Y-m-d'),
'CLASS_FILES' => $xml_classes,
'STABILITY' => $stability,
));
]);

list($results) = $filesystem->execute('pear package');
echo $results;
Expand Down
25 changes: 17 additions & 8 deletions data/bin/sandbox_installer.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
<?php

/*
* This file is part of the Symfony1 package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$this->installDir(__DIR__.'/sandbox_skeleton');

$this->logSection('install', 'add symfony CLI for Windows users');
$this->getFilesystem()->copy(__DIR__.'/symfony.bat', sfConfig::get('sf_root_dir').'/symfony.bat');
$this->getFilesystem()->copy(__DIR__.'/symfony.bat', \sfConfig::get('sf_root_dir').'/symfony.bat');

$this->logSection('install', 'add LICENSE');
$this->getFilesystem()->copy(__DIR__.'/../../LICENSE', sfConfig::get('sf_root_dir').'/LICENSE');
$this->getFilesystem()->copy(__DIR__.'/../../LICENSE', \sfConfig::get('sf_root_dir').'/LICENSE');

$this->logSection('install', 'default to sqlite');
$this->runTask('configure:database', sprintf("'sqlite:%s/sandbox.db'", sfConfig::get('sf_data_dir')));
$this->runTask('configure:database', sprintf("'sqlite:%s/sandbox.db'", \sfConfig::get('sf_data_dir')));

$this->logSection('install', 'create an application');
$this->runTask('generate:app', 'frontend');
Expand All @@ -18,13 +27,13 @@
$this->runTask('plugin:publish-assets');

$this->logSection('install', 'fix sqlite database permissions');
touch(sfConfig::get('sf_data_dir').'/sandbox.db');
chmod(sfConfig::get('sf_data_dir'), 0777);
chmod(sfConfig::get('sf_data_dir').'/sandbox.db', 0777);
touch(\sfConfig::get('sf_data_dir').'/sandbox.db');
chmod(\sfConfig::get('sf_data_dir'), 0777);
chmod(\sfConfig::get('sf_data_dir').'/sandbox.db', 0777);

$this->logSection('install', 'add an empty file in empty directories');
$seen = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(sfConfig::get('sf_root_dir')), RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) {
$seen = [];
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(\sfConfig::get('sf_root_dir')), \RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) {
if (!isset($seen[$path]) && $item->isDir() && !$item->isLink()) {
touch($item->getRealPath().'/.sf');
}
Expand Down
Loading
Loading