Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / phpunit / phpunit / src / Util / Blacklist.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Utility class for blacklisting PHPUnit's own source code files.
13  *
14  * @since Class available since Release 4.0.0
15  */
16 class PHPUnit_Util_Blacklist
17 {
18     /**
19      * @var array
20      */
21     public static $blacklistedClassNames = array(
22         'File_Iterator'                              => 1,
23         'PHP_CodeCoverage'                           => 1,
24         'PHP_Invoker'                                => 1,
25         'PHP_Timer'                                  => 1,
26         'PHP_Token'                                  => 1,
27         'PHPUnit_Framework_TestCase'                 => 2,
28         'PHPUnit_Extensions_Database_TestCase'       => 2,
29         'PHPUnit_Framework_MockObject_Generator'     => 2,
30         'PHPUnit_Extensions_SeleniumTestCase'        => 2,
31         'Text_Template'                              => 1,
32         'Symfony\Component\Yaml\Yaml'                => 1,
33         'SebastianBergmann\Diff\Diff'                => 1,
34         'SebastianBergmann\Environment\Runtime'      => 1,
35         'SebastianBergmann\Comparator\Comparator'    => 1,
36         'SebastianBergmann\Exporter\Exporter'        => 1,
37         'SebastianBergmann\GlobalState\Snapshot'     => 1,
38         'SebastianBergmann\RecursionContext\Context' => 1,
39         'SebastianBergmann\Version'                  => 1,
40         'Composer\Autoload\ClassLoader'              => 1,
41         'Doctrine\Instantiator\Instantiator'         => 1,
42         'phpDocumentor\Reflection\DocBlock'          => 1,
43         'Prophecy\Prophet'                           => 1
44     );
45
46     /**
47      * @var array
48      */
49     private static $directories;
50
51     /**
52      * @return array
53      *
54      * @since  Method available since Release 4.1.0
55      */
56     public function getBlacklistedDirectories()
57     {
58         $this->initialize();
59
60         return self::$directories;
61     }
62
63     /**
64      * @param string $file
65      *
66      * @return bool
67      */
68     public function isBlacklisted($file)
69     {
70         if (defined('PHPUNIT_TESTSUITE')) {
71             return false;
72         }
73
74         $this->initialize();
75
76         foreach (self::$directories as $directory) {
77             if (strpos($file, $directory) === 0) {
78                 return true;
79             }
80         }
81
82         return false;
83     }
84
85     private function initialize()
86     {
87         if (self::$directories === null) {
88             self::$directories = array();
89
90             foreach (self::$blacklistedClassNames as $className => $parent) {
91                 if (!class_exists($className)) {
92                     continue;
93                 }
94
95                 $reflector = new ReflectionClass($className);
96                 $directory = $reflector->getFileName();
97
98                 for ($i = 0; $i < $parent; $i++) {
99                     $directory = dirname($directory);
100                 }
101
102                 self::$directories[] = $directory;
103             }
104
105             // Hide process isolation workaround on Windows.
106             // @see PHPUnit_Util_PHP::factory()
107             // @see PHPUnit_Util_PHP_Windows::process()
108             if (DIRECTORY_SEPARATOR === '\\') {
109                 // tempnam() prefix is limited to first 3 chars.
110                 // @see http://php.net/manual/en/function.tempnam.php
111                 self::$directories[] = sys_get_temp_dir() . '\\PHP';
112             }
113         }
114     }
115 }