Skip to content

Commit 0db6172

Browse files
committed
replace dirname(__FILE__) by __DIR__
Since PHP 5.3 is now the requirement, we can use the __DIR__ magic constant instead of dirname(__FILE__) for a little extra performance.
1 parent d66b253 commit 0db6172

File tree

269 files changed

+448
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+448
-448
lines changed

autoload.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

3-
require_once dirname(__FILE__).'/lib/autoload/sfCoreAutoload.class.php';
3+
require_once __DIR__.'/lib/autoload/sfCoreAutoload.class.php';
44

55
sfCoreAutoload::register();

data/bin/changelog.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1818
* @version SVN: $Id$
1919
*/
20-
require_once dirname(__FILE__).'/../../lib/task/sfFilesystem.class.php';
20+
require_once __DIR__.'/../../lib/task/sfFilesystem.class.php';
2121

2222
if (!isset($argv[1]))
2323
{

data/bin/release.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1818
* @version SVN: $Id$
1919
*/
20-
require_once(dirname(__FILE__).'/../../lib/exception/sfException.class.php');
21-
require_once(dirname(__FILE__).'/../../lib/task/sfFilesystem.class.php');
22-
require_once(dirname(__FILE__).'/../../lib/util/sfFinder.class.php');
23-
require_once(dirname(__FILE__).'/../../lib/vendor/lime/lime.php');
20+
require_once(__DIR__.'/../../lib/exception/sfException.class.php');
21+
require_once(__DIR__.'/../../lib/task/sfFilesystem.class.php');
22+
require_once(__DIR__.'/../../lib/util/sfFinder.class.php');
23+
require_once(__DIR__.'/../../lib/vendor/lime/lime.php');
2424

2525
if (!isset($argv[1]))
2626
{

data/bin/sandbox_installer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
$this->installDir(dirname(__FILE__).'/sandbox_skeleton');
3+
$this->installDir(__DIR__.'/sandbox_skeleton');
44

55
$this->logSection('install', 'add symfony CLI for Windows users');
6-
$this->getFilesystem()->copy(dirname(__FILE__).'/symfony.bat', sfConfig::get('sf_root_dir').'/symfony.bat');
6+
$this->getFilesystem()->copy(__DIR__.'/symfony.bat', sfConfig::get('sf_root_dir').'/symfony.bat');
77

88
$this->logSection('install', 'add LICENSE');
9-
$this->getFilesystem()->copy(dirname(__FILE__).'/../../LICENSE', sfConfig::get('sf_root_dir').'/LICENSE');
9+
$this->getFilesystem()->copy(__DIR__.'/../../LICENSE', sfConfig::get('sf_root_dir').'/LICENSE');
1010

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

data/bin/symfony

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ if (file_exists('config/ProjectConfiguration.class.php'))
1717
}
1818
else
1919
{
20-
if (is_readable(dirname(__FILE__).'/../../lib/autoload/sfCoreAutoload.class.php'))
20+
if (is_readable(__DIR__.'/../../lib/autoload/sfCoreAutoload.class.php'))
2121
{
2222
// SVN
23-
$dir = realpath(dirname(__FILE__).'/../../lib');
23+
$dir = realpath(__DIR__.'/../../lib');
2424
}
2525
else
2626
{

lib/autoload/sfCoreAutoload.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class sfCoreAutoload
3636

3737
protected function __construct()
3838
{
39-
$this->baseDir = realpath(dirname(__FILE__).'/..');
39+
$this->baseDir = realpath(__DIR__.'/..');
4040
}
4141

4242
/**
@@ -141,7 +141,7 @@ public function getBaseDir()
141141
*/
142142
static public function make()
143143
{
144-
$libDir = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'));
144+
$libDir = str_replace(DIRECTORY_SEPARATOR, '/', realpath(__DIR__.DIRECTORY_SEPARATOR.'..'));
145145
require_once $libDir.'/util/sfFinder.class.php';
146146

147147
$files = sfFinder::type('file')

lib/cache/sfCache.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function initialize($options = array())
5757
$this->options = array_merge(array(
5858
'automatic_cleaning_factor' => 1000,
5959
'lifetime' => 86400,
60-
'prefix' => md5(dirname(__FILE__)),
60+
'prefix' => md5(__DIR__),
6161
), $options);
6262

6363
$this->options['prefix'] .= self::SEPARATOR;

lib/command/cli.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
*/
1010

1111
// Try autoloading using composer if available.
12-
if (!file_exists($autoload = dirname(__FILE__).'/../../../../autoload.php'))
12+
if (!file_exists($autoload = __DIR__.'/../../../../autoload.php'))
1313
{
14-
$autoload = dirname(__FILE__).'/../../autoload.php';
14+
$autoload = __DIR__.'/../../autoload.php';
1515
}
1616

1717
// Fall back to classic Symfony loading
1818
if (!file_exists($autoload))
1919
{
20-
require_once(dirname(__FILE__).'/../autoload/sfCoreAutoload.class.php');
20+
require_once(__DIR__.'/../autoload/sfCoreAutoload.class.php');
2121
sfCoreAutoload::register();
2222
}
2323
else
@@ -30,7 +30,7 @@
3030
$dispatcher = new sfEventDispatcher();
3131
$logger = new sfCommandLogger($dispatcher);
3232

33-
$application = new sfSymfonyCommandApplication($dispatcher, null, array('symfony_lib_dir' => realpath(dirname(__FILE__).'/..')));
33+
$application = new sfSymfonyCommandApplication($dispatcher, null, array('symfony_lib_dir' => realpath(__DIR__.'/..')));
3434
$statusCode = $application->run();
3535
}
3636
catch (Exception $e)

lib/config/sfProjectConfiguration.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($rootDir = null, sfEventDispatcher $dispatcher = nul
4545
}
4646

4747
$this->rootDir = null === $rootDir ? self::guessRootDir() : realpath($rootDir);
48-
$this->symfonyLibDir = realpath(dirname(__FILE__).'/..');
48+
$this->symfonyLibDir = realpath(__DIR__.'/..');
4949
$this->dispatcher = null === $dispatcher ? new sfEventDispatcher() : $dispatcher;
5050

5151
ini_set('magic_quotes_runtime', 'off');

lib/controller/default/templates/disabledSuccess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTAlert">
44
<?php echo image_tag('/sf/sf_default/images/icons/disabled48.png', array('alt' => 'module disabled', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/controller/default/templates/error404Success.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTAlert">
44
<?php echo image_tag('/sf/sf_default/images/icons/cancel48.png', array('alt' => 'page not found', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/controller/default/templates/indexSuccess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTMessage">
44
<?php echo image_tag('/sf/sf_default/images/icons/ok48.png', array('alt' => 'ok', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/controller/default/templates/loginSuccess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTLock">
44
<?php echo image_tag('/sf/sf_default/images/icons/lock48.png', array('alt' => 'login required', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/controller/default/templates/moduleSuccess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTMessage">
44
<?php echo image_tag('/sf/sf_default/images/icons/ok48.png', array('alt' => 'module created', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/controller/default/templates/secureSuccess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php decorate_with(dirname(__FILE__).'/defaultLayout.php') ?>
1+
<?php decorate_with(__DIR__.'/defaultLayout.php') ?>
22

33
<div class="sfTMessageContainer sfTLock">
44
<?php echo image_tag('/sf/sf_default/images/icons/lock48.png', array('alt' => 'credentials required', 'class' => 'sfTMessageIcon', 'size' => '48x48')) ?>

lib/exception/sfException.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static public function getTemplatePathForError($format, $debug)
259259
$templatePaths = array(
260260
sfConfig::get('sf_app_config_dir').'/error',
261261
sfConfig::get('sf_config_dir').'/error',
262-
dirname(__FILE__).'/data',
262+
__DIR__.'/data',
263263
);
264264

265265
$template = sprintf('%s.%s.php', $debug ? 'exception' : 'error', $format);

lib/helper/DateHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function distance_of_time_in_words($from_time, $to_time = null, $include_seconds
153153

154154
if (sfConfig::get('sf_i18n'))
155155
{
156-
require_once dirname(__FILE__).'/I18NHelper.php';
156+
require_once __DIR__.'/I18NHelper.php';
157157

158158
return __($string, $parameters);
159159
}

lib/i18n/Gettext/MO.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @license PHP License
2222
*/
2323

24-
require_once dirname(__FILE__).'/TGettext.class.php';
24+
require_once __DIR__.'/TGettext.class.php';
2525

2626
/**
2727
* File_Gettext_MO
@@ -334,4 +334,4 @@ function save($file = null)
334334
@fclose($this->_handle);
335335
return true;
336336
}
337-
}
337+
}

lib/i18n/Gettext/PO.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @license PHP License
2222
*/
2323

24-
require_once dirname(__FILE__).'/TGettext.class.php';
24+
require_once __DIR__.'/TGettext.class.php';
2525

2626
/**
2727
* File_Gettext_PO
@@ -140,4 +140,4 @@ function save($file = null)
140140
@fclose($fh);
141141
return true;
142142
}
143-
}
143+
}

lib/i18n/Gettext/TGettext.class.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class TGettext
8484
static function factory($format, $file = '')
8585
{
8686
$format = strToUpper($format);
87-
$filename = dirname(__FILE__).'/'.$format.'.php';
87+
$filename = __DIR__.'/'.$format.'.php';
8888
if (is_file($filename) == false)
8989
throw new Exception ("Class file $file not found");
9090

@@ -112,7 +112,7 @@ function poFile2moFile($pofile, $mofile)
112112
throw new Exception("File $pofile doesn't exist.");
113113
}
114114

115-
include_once dirname(__FILE__).'/PO.php';
115+
include_once __DIR__.'/PO.php';
116116

117117
$PO = new TGettext_PO($pofile);
118118
if (true !== ($e = $PO->load())) {
@@ -248,7 +248,7 @@ function fromArray($array)
248248
*/
249249
function toMO()
250250
{
251-
include_once dirname(__FILE__).'/MO.php';
251+
include_once __DIR__.'/MO.php';
252252
$MO = new TGettext_MO;
253253
$MO->fromArray($this->toArray());
254254
return $MO;
@@ -262,9 +262,9 @@ function toMO()
262262
*/
263263
function toPO()
264264
{
265-
include_once dirname(__FILE__).'/PO.php';
265+
include_once __DIR__.'/PO.php';
266266
$PO = new TGettext_PO;
267267
$PO->fromArray($this->toArray());
268268
return $PO;
269269
}
270-
}
270+
}

lib/i18n/sfCultureInfo.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function __construct($culture = 'en')
225225
*/
226226
protected static function dataDir()
227227
{
228-
return dirname(__FILE__).'/data/';
228+
return __DIR__.'/data/';
229229
}
230230

231231
/**

lib/task/generator/sfGenerateAppTask.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php');
11+
require_once(__DIR__.'/sfGeneratorBaseTask.class.php');
1212

1313
/**
1414
* Generates a new application.
@@ -101,7 +101,7 @@ protected function execute($arguments = array(), $options = array())
101101
}
102102
else
103103
{
104-
$skeletonDir = dirname(__FILE__).'/skeleton/app';
104+
$skeletonDir = __DIR__.'/skeleton/app';
105105
}
106106

107107
// Create basic application structure

lib/task/generator/sfGenerateModuleTask.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php');
11+
require_once(__DIR__.'/sfGeneratorBaseTask.class.php');
1212

1313
/**
1414
* Generates a new module.
@@ -96,7 +96,7 @@ protected function execute($arguments = array(), $options = array())
9696
}
9797
else
9898
{
99-
$skeletonDir = dirname(__FILE__).'/skeleton/module';
99+
$skeletonDir = __DIR__.'/skeleton/module';
100100
}
101101

102102
// create basic application structure

lib/task/generator/sfGenerateProjectTask.class.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php');
11+
require_once(__DIR__.'/sfGeneratorBaseTask.class.php');
1212

1313
/**
1414
* Generates a new project.
@@ -104,11 +104,11 @@ protected function execute($arguments = array(), $options = array())
104104
$this->options = $options;
105105

106106
// create basic project structure
107-
$this->installDir(dirname(__FILE__).'/skeleton/project');
107+
$this->installDir(__DIR__.'/skeleton/project');
108108

109109
// update ProjectConfiguration class (use a relative path when the symfony core is nested within the project)
110110
$symfonyCoreAutoload = 0 === strpos(sfConfig::get('sf_symfony_lib_dir'), sfConfig::get('sf_root_dir')) ?
111-
sprintf('dirname(__FILE__).\'/..%s/autoload/sfCoreAutoload.class.php\'', str_replace(sfConfig::get('sf_root_dir'), '', sfConfig::get('sf_symfony_lib_dir'))) :
111+
sprintf('__DIR__.\'/..%s/autoload/sfCoreAutoload.class.php\'', str_replace(sfConfig::get('sf_root_dir'), '', sfConfig::get('sf_symfony_lib_dir'))) :
112112
var_export(sfConfig::get('sf_symfony_lib_dir').'/autoload/sfCoreAutoload.class.php', true);
113113

114114
$this->replaceTokens(array(sfConfig::get('sf_config_dir')), array('SYMFONY_CORE_AUTOLOAD' => str_replace('\\', '/', $symfonyCoreAutoload)));
@@ -125,7 +125,7 @@ protected function execute($arguments = array(), $options = array())
125125
// execute the choosen ORM installer script
126126
if (in_array($options['orm'], array('Doctrine')))
127127
{
128-
include dirname(__FILE__).'/../../plugins/sf'.$options['orm'].'Plugin/config/installer.php';
128+
include __DIR__.'/../../plugins/sf'.$options['orm'].'Plugin/config/installer.php';
129129
}
130130

131131
// execute a custom installer
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
##IP_CHECK##
4-
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
4+
require_once(__DIR__.'/../config/ProjectConfiguration.class.php');
55

66
$configuration = ProjectConfiguration::getApplicationConfiguration('##APP_NAME##', '##ENVIRONMENT##', ##IS_DEBUG##);
77
sfContext::createInstance($configuration)->dispatch();

lib/task/generator/skeleton/module/test/actionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
include(dirname(__FILE__).'/../../bootstrap/functional.php');
3+
include(__DIR__.'/../../bootstrap/functional.php');
44

55
$browser = new sfTestFunctional(new sfBrowser());
66

lib/task/generator/skeleton/project/symfony

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
chdir(dirname(__FILE__));
13-
require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php');
12+
chdir(__DIR__);
13+
require_once(__DIR__.'/config/ProjectConfiguration.class.php');
1414
include(sfCoreAutoload::getInstance()->getBaseDir().'/command/cli.php');

lib/task/generator/skeleton/project/test/bootstrap/functional.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$app = array_pop($dirPieces);
1919
}
2020

21-
require_once dirname(__FILE__).'/../../config/ProjectConfiguration.class.php';
21+
require_once __DIR__.'/../../config/ProjectConfiguration.class.php';
2222
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true);
2323
sfContext::createInstance($configuration);
2424

lib/task/generator/skeleton/project/test/bootstrap/unit.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
$_test_dir = realpath(dirname(__FILE__).'/..');
11+
$_test_dir = realpath(__DIR__.'/..');
1212

1313
// configuration
14-
require_once dirname(__FILE__).'/../../config/ProjectConfiguration.class.php';
14+
require_once __DIR__.'/../../config/ProjectConfiguration.class.php';
1515
$configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir.'/..'));
1616

1717
// autoloader

lib/task/plugin/sfPluginAddChannelTask.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php');
11+
require_once(__DIR__.'/sfPluginBaseTask.class.php');
1212

1313
/**
1414
* Installs a plugin.

lib/task/plugin/sfPluginInstallTask.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php');
11+
require_once(__DIR__.'/sfPluginBaseTask.class.php');
1212

1313
/**
1414
* Installs a plugin.

0 commit comments

Comments
 (0)