Skip to content

Commit 6949f8a

Browse files
committed
Use __DIR__, not dirname(__FILE__).
1 parent ebb6ec7 commit 6949f8a

12 files changed

+18
-18
lines changed

examples/orders/orders.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2-
require_once dirname(__FILE__) . '/../../ActiveRecord.php';
2+
require_once __DIR__ . '/../../ActiveRecord.php';
33

44
// initialize ActiveRecord
55
ActiveRecord\Config::initialize(function($cfg)
66
{
7-
$cfg->set_model_directory(dirname(__FILE__) . '/models');
7+
$cfg->set_model_directory(__DIR__ . '/models');
88
$cfg->set_connections(array('development' => 'mysql://test:[email protected]/orders_test'));
99

1010
// you can change the default connection with the below

examples/simple/simple.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once dirname(__FILE__) . '/../../ActiveRecord.php';
2+
require_once __DIR__ . '/../../ActiveRecord.php';
33

44
// assumes a table named "books" with a pk named "id"
55
// see simple.sql

examples/simple/simple_with_options.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once dirname(__FILE__) . '/../../ActiveRecord.php';
2+
require_once __DIR__ . '/../../ActiveRecord.php';
33

44
class Book extends ActiveRecord\Model
55
{

lib/Cache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function initialize($url, $options=array())
2626
$url = parse_url($url);
2727
$file = ucwords(Inflector::instance()->camelize($url['scheme']));
2828
$class = "ActiveRecord\\$file";
29-
require_once dirname(__FILE__) . "/cache/$file.php";
29+
require_once __DIR__ . "/cache/$file.php";
3030
static::$adapter = new $class($url);
3131
}
3232
else

lib/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static function load_adapter_class($adapter)
121121
{
122122
$class = ucwords($adapter) . 'Adapter';
123123
$fqclass = 'ActiveRecord\\' . $class;
124-
$source = dirname(__FILE__) . "/adapters/$class.php";
124+
$source = __DIR__ . "/adapters/$class.php";
125125

126126
if (!file_exists($source))
127127
throw new DatabaseException("$fqclass not found!");

test/InflectorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
include 'helpers/config.php';
3-
require_once dirname(__FILE__) . '/../lib/Inflector.php';
3+
require_once __DIR__ . '/../lib/Inflector.php';
44

55
class InflectorTest extends SnakeCase_PHPUnit_Framework_TestCase
66
{

test/MysqlAdapterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use ActiveRecord\Column;
33

44
include 'helpers/config.php';
5-
require_once dirname(__FILE__) . '/../lib/adapters/MysqlAdapter.php';
5+
require_once __DIR__ . '/../lib/adapters/MysqlAdapter.php';
66

77
class MysqlAdapterTest extends AdapterTest
88
{

test/OciAdapterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
include 'helpers/config.php';
3-
require_once dirname(__FILE__) . '/../lib/adapters/OciAdapter.php';
3+
require_once __DIR__ . '/../lib/adapters/OciAdapter.php';
44

55
class OciAdapterTest extends AdapterTest
66
{

test/PgsqlAdapterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use ActiveRecord\Column;
33

44
include 'helpers/config.php';
5-
require_once dirname(__FILE__) . '/../lib/adapters/PgsqlAdapter.php';
5+
require_once __DIR__ . '/../lib/adapters/PgsqlAdapter.php';
66

77
class PgsqlAdapterTest extends AdapterTest
88
{

test/SqliteAdapterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
include 'helpers/config.php';
3-
require_once dirname(__FILE__) . '/../lib/adapters/SqliteAdapter.php';
3+
require_once __DIR__ . '/../lib/adapters/SqliteAdapter.php';
44

55
class SqliteAdapterTest extends AdapterTest
66
{
@@ -26,7 +26,7 @@ public function testConnectToInvalidDatabaseShouldNotCreateDbFile()
2626
}
2727
catch (ActiveRecord\DatabaseException $e)
2828
{
29-
$this->assertFalse(file_exists(dirname(__FILE__) . "/" . self::InvalidDb));
29+
$this->assertFalse(file_exists(__DIR__ . "/" . self::InvalidDb));
3030
}
3131
}
3232

test/helpers/DatabaseLoader.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function get_fixture_tables()
7878
{
7979
$tables = array();
8080

81-
foreach (glob(dirname(__FILE__) . '/../fixtures/*.csv') as $file)
81+
foreach (glob(__DIR__ . '/../fixtures/*.csv') as $file)
8282
{
8383
$info = pathinfo($file);
8484
$tables[] = $info['filename'];
@@ -89,7 +89,7 @@ public function get_fixture_tables()
8989

9090
public function get_sql($file)
9191
{
92-
$file = dirname(__FILE__) . "/../sql/$file.sql";
92+
$file = __DIR__ . "/../sql/$file.sql";
9393

9494
if (!file_exists($file))
9595
throw new Exception("File not found: $file");
@@ -99,7 +99,7 @@ public function get_sql($file)
9999

100100
public function load_fixture_data($table)
101101
{
102-
$fp = fopen(dirname(__FILE__) . "/../fixtures/$table.csv",'r');
102+
$fp = fopen(__DIR__ . "/../fixtures/$table.csv",'r');
103103
$fields = fgetcsv($fp);
104104

105105
if (!empty($fields))

test/helpers/config.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
require_once 'SnakeCase_PHPUnit_Framework_TestCase.php';
1414
require_once 'DatabaseTest.php';
1515
require_once 'AdapterTest.php';
16-
require_once dirname(__FILE__) . '/../../ActiveRecord.php';
16+
require_once __DIR__ . '/../../ActiveRecord.php';
1717

1818
// whether or not to run the slow non-crucial tests
1919
$GLOBALS['slow_tests'] = false;
@@ -27,7 +27,7 @@
2727

2828
ActiveRecord\Config::initialize(function($cfg)
2929
{
30-
$cfg->set_model_directory(realpath(dirname(__FILE__) . '/../models'));
30+
$cfg->set_model_directory(realpath(__DIR__ . '/../models'));
3131
$cfg->set_connections(array(
3232
'mysql' => getenv('PHPAR_MYSQL') ?: 'mysql://test:[email protected]/test',
3333
'pgsql' => getenv('PHPAR_PGSQL') ?: 'pgsql://test:[email protected]/test',
@@ -46,7 +46,7 @@
4646

4747
if (is_callable('Log::singleton')) // PEAR Log installed
4848
{
49-
$logger = Log::singleton('file', dirname(__FILE__) . '/../log/query.log','ident',array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
49+
$logger = Log::singleton('file', __DIR__ . '/../log/query.log','ident',array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
5050

5151
$cfg->set_logging(true);
5252
$cfg->set_logger($logger);

0 commit comments

Comments
 (0)