Skip to content
This repository
Browse code

replace __DIR__ with dirname(__FILE__)

  • Loading branch information...
commit 550da214552b632c2ac672202668458f512c0fd9 1 parent bec9ce8
Cristi Burcă scribu authored committed
6 src/Mustache/Autoloader.php
@@ -19,16 +19,16 @@ class Mustache_Autoloader {
19 19 /**
20 20 * Autoloader constructor.
21 21 *
22   - * @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
  22 + * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
23 23 */
24 24 public function __construct($baseDir = null) {
25   - $this->baseDir = rtrim($baseDir, '/') ?: __DIR__.'/..';
  25 + $this->baseDir = rtrim($baseDir, '/') ?: dirname(__FILE__).'/..';
26 26 }
27 27
28 28 /**
29 29 * Register a new instance as an SPL autoloader.
30 30 *
31   - * @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
  31 + * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
32 32 *
33 33 * @return Mustache_Autoloader Registered Autoloader instance
34 34 */
10 src/Mustache/Loader/FilesystemLoader.php
@@ -14,14 +14,14 @@
14 14 *
15 15 * An ArrayLoader instance loads Mustache Template source from the filesystem by name:
16 16 *
17   - * $loader = new FilesystemLoader(__DIR__.'/views');
18   - * $tpl = $loader->load('foo'); // equivalent to `file_get_contents(__DIR__.'/views/foo.mustache');
  17 + * $loader = new FilesystemLoader(dirname(__FILE__).'/views');
  18 + * $tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');
19 19 *
20 20 * This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
21 21 *
22 22 * $m = new Mustache(array(
23   - * 'loader' => new FilesystemLoader(__DIR__.'/views'),
24   - * 'partials_loader' => new FilesystemLoader(__DIR__.'/views/partials'),
  23 + * 'loader' => new FilesystemLoader(dirname(__FILE__).'/views'),
  24 + * 'partials_loader' => new FilesystemLoader(dirname(__FILE__).'/views/partials'),
25 25 * ));
26 26 *
27 27 * @implements Loader
@@ -61,7 +61,7 @@ public function __construct($baseDir, array $options = array()) {
61 61 /**
62 62 * Load a Template by name.
63 63 *
64   - * $loader = new FilesystemLoader(__DIR__.'/views');
  64 + * $loader = new FilesystemLoader(dirname(__FILE__).'/views');
65 65 * $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
66 66 *
67 67 * @param string $name
8 src/Mustache/Mustache.php
@@ -47,17 +47,17 @@ class Mustache_Mustache {
47 47 * 'template_class_prefix' => '__MyTemplates_',
48 48 *
49 49 * // A cache directory for compiled templates. Mustache will not cache templates unless this is set
50   - * 'cache' => __DIR__.'/tmp/cache/mustache',
  50 + * 'cache' => dirname(__FILE__).'/tmp/cache/mustache',
51 51 *
52 52 * // A Mustache template loader instance. Uses a StringLoader if not specified
53   - * 'loader' => new Mustache_Loader_FilesystemLoader(__DIR__.'/views'),
  53 + * 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
54 54 *
55 55 * // A Mustache loader instance for partials.
56   - * 'partials_loader' => new Mustache_Loader_FilesystemLoader(__DIR__.'/views/partials'),
  56 + * 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
57 57 *
58 58 * // An array of Mustache partials. Useful for quick-and-dirty string template loading, but not as
59 59 * // efficient or lazy as a Filesystem (or database) loader.
60   - * 'partials' => array('foo' => file_get_contents(__DIR__.'/views/partials/foo.mustache')),
  60 + * 'partials' => array('foo' => file_get_contents(dirname(__FILE__).'/views/partials/foo.mustache')),
61 61 *
62 62 * // An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order
63 63 * // sections), or any other valid Mustache context value. They will be prepended to the context stack,
2  test/Mustache/Test/AutoloaderTest.php
@@ -19,7 +19,7 @@ public function testRegister() {
19 19 }
20 20
21 21 public function testAutoloader() {
22   - $loader = new Mustache_Autoloader(__DIR__.'/../../fixtures/autoloader');
  22 + $loader = new Mustache_Autoloader(dirname(__FILE__).'/../../fixtures/autoloader');
23 23
24 24 $this->assertNull($loader->autoload('NonMustacheClass'));
25 25 $this->assertFalse(class_exists('NonMustacheClass'));
2  test/Mustache/Test/Functional/ExamplesTest.php
@@ -46,7 +46,7 @@ public function testExamples($context, $source, $partials, $expected) {
46 46 * @return array
47 47 */
48 48 public function getExamples() {
49   - $path = realpath(__DIR__.'/../../../../examples');
  49 + $path = realpath(dirname(__FILE__).'/../../../../examples');
50 50 $examples = array();
51 51
52 52 $handle = opendir($path);
4 test/Mustache/Test/Functional/MustacheSpecTest.php
@@ -28,7 +28,7 @@ public static function setUpBeforeClass() {
28 28 * simply to provide a 'skipped' test if the `spec` submodule isn't initialized.
29 29 */
30 30 public function testSpecInitialized() {
31   - if (!file_exists(__DIR__.'/../../../../vendor/spec/specs/')) {
  31 + if (!file_exists(dirname(__FILE__).'/../../../../vendor/spec/specs/')) {
32 32 $this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"');
33 33 }
34 34 }
@@ -156,7 +156,7 @@ public function loadSectionsSpec() {
156 156 * @return array
157 157 */
158 158 private function loadSpec($name) {
159   - $filename = __DIR__ . '/../../../../vendor/spec/specs/' . $name . '.yml';
  159 + $filename = dirname(__FILE__) . '/../../../../vendor/spec/specs/' . $name . '.yml';
160 160 if (!file_exists($filename)) {
161 161 return array();
162 162 }
8 test/Mustache/Test/Loader/FilesystemLoaderTest.php
@@ -14,14 +14,14 @@
14 14 */
15 15 class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCase {
16 16 public function testConstructor() {
17   - $baseDir = realpath(__DIR__.'/../../../fixtures/templates');
  17 + $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
18 18 $loader = new Mustache_Loader_FilesystemLoader($baseDir, array('extension' => '.ms'));
19 19 $this->assertEquals('alpha contents', $loader->load('alpha'));
20 20 $this->assertEquals('beta contents', $loader->load('beta.ms'));
21 21 }
22 22
23 23 public function testLoadTemplates() {
24   - $baseDir = realpath(__DIR__.'/../../../fixtures/templates');
  24 + $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
25 25 $loader = new Mustache_Loader_FilesystemLoader($baseDir);
26 26 $this->assertEquals('one contents', $loader->load('one'));
27 27 $this->assertEquals('two contents', $loader->load('two.mustache'));
@@ -31,14 +31,14 @@ public function testLoadTemplates() {
31 31 * @expectedException \RuntimeException
32 32 */
33 33 public function testMissingBaseDirThrowsException() {
34   - $loader = new Mustache_Loader_FilesystemLoader(__DIR__.'/not_a_directory');
  34 + $loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/not_a_directory');
35 35 }
36 36
37 37 /**
38 38 * @expectedException \InvalidArgumentException
39 39 */
40 40 public function testMissingTemplateThrowsException() {
41   - $baseDir = realpath(__DIR__.'/../../../fixtures/templates');
  41 + $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
42 42 $loader = new Mustache_Loader_FilesystemLoader($baseDir);
43 43
44 44 $loader->load('fake');
4 test/bootstrap.php
@@ -9,7 +9,7 @@
9 9 * file that was distributed with this source code.
10 10 */
11 11
12   -require __DIR__.'/../src/Mustache/Autoloader.php';
  12 +require dirname(__FILE__).'/../src/Mustache/Autoloader.php';
13 13 Mustache_Autoloader::register();
14 14
15   -require __DIR__.'/../vendor/yaml/lib/sfYamlParser.php';
  15 +require dirname(__FILE__).'/../vendor/yaml/lib/sfYamlParser.php';

0 comments on commit 550da21

Please sign in to comment.
Something went wrong with that request. Please try again.