summaryrefslogtreecommitdiffstats
path: root/php-symfony2-Validator-tests-bootstrap.patch
blob: 567f679ba42770d53594bfcdd0ff4c4b3a80b228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- Symfony/Component/Validator/Tests/bootstrap.php	2012-09-20 03:42:20.000000000 -0400
+++ Symfony/Component/Validator/Tests/bootstrap.php	2012-10-23 21:36:52.088489051 -0400
@@ -9,10 +9,20 @@
  * file that was distributed with this source code.
  */
 
+date_default_timezone_set('UTC');
 spl_autoload_register(function ($class) {
-    if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Validator')) {
-        if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Validator')).'.php')) {
-            require_once $file;
+    if (0 === strpos(ltrim($class, '/'), 'Symfony\Component')) {
+        $file = substr(str_replace('\\', '/', $class), strlen('Symfony\Component')).'.php';
+        if (file_exists(__DIR__.'/../..'.$file)) {
+            // Load from source tree
+            require_once __DIR__.'/../..'.$file;
+        } else {
+            try {
+                // Try loading from incude path
+                require_once 'Symfony/Component'.$file;
+            } catch (Exception $e) {
+                // Fail silently so class not found fatal error still raised
+            }
         }
     }
 });
@@ -23,9 +33,18 @@
 
 if (class_exists($annotationRegistry = 'Doctrine\Common\Annotations\AnnotationRegistry')) {
     $annotationRegistry::registerLoader(function($class) {
-        if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Validator')) {
-            if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Validator')).'.php')) {
-                require_once $file;
+        if (0 === strpos(ltrim($class, '/'), 'Symfony\Component')) {
+            $file = substr(str_replace('\\', '/', $class), strlen('Symfony\Component')).'.php';
+            if (file_exists(__DIR__.'/../..'.$file)) {
+                // Load from source tree
+                require_once __DIR__.'/../..'.$file;
+            } else {
+                try {
+                    // Try loading from incude path
+                    require_once 'Symfony/Component'.$file;
+                } catch (Exception $e) {
+                    // Fail silently for fall-through
+                }
             }
         }