@@ -83,13 +83,18 @@ public function getLocator()
8383 */
8484 public function import ($ resource , $ type = null , $ ignoreErrors = false , $ sourceResource = null )
8585 {
86- if (is_string ($ resource ) && false !== strpbrk ($ resource , '*?{[ ' )) {
86+ if (is_string ($ resource ) && strlen ( $ resource ) !== $ i = strcspn ($ resource , '*?{[ ' )) {
8787 $ ret = array ();
88- foreach ($ this ->glob ($ resource , false , $ _ , true ) as $ path => $ info ) {
89- $ ret [] = $ this ->doImport ($ path , $ type , $ ignoreErrors , $ sourceResource );
88+ $ isSubpath = 0 !== $ i && false !== strpos (substr ($ resource , 0 , $ i ), '/ ' );
89+ foreach ($ this ->glob ($ resource , false , $ _ , $ ignoreErrors || !$ isSubpath ) as $ path => $ info ) {
90+ if (null !== $ res = $ this ->doImport ($ path , $ type , $ ignoreErrors , $ sourceResource )) {
91+ $ ret [] = $ res ;
92+ }
93+ $ isSubpath = true ;
9094 }
91- if ($ ret ) {
92- return count ($ ret ) > 1 ? $ ret : $ ret [0 ];
95+
96+ if ($ isSubpath ) {
97+ return isset ($ ret [1 ]) ? $ ret : (isset ($ ret [0 ]) ? $ ret [0 ] : null );
9398 }
9499 }
95100
@@ -104,7 +109,7 @@ protected function glob($pattern, $recursive, &$resource = null, $ignoreErrors =
104109 if (strlen ($ pattern ) === $ i = strcspn ($ pattern , '*?{[ ' )) {
105110 $ prefix = $ pattern ;
106111 $ pattern = '' ;
107- } elseif (0 === $ i ) {
112+ } elseif (0 === $ i || false === strpos ( substr ( $ pattern , 0 , $ i ), ' / ' ) ) {
108113 $ prefix = '. ' ;
109114 $ pattern = '/ ' .$ pattern ;
110115 } else {
0 commit comments