Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed the classmap autoloader to work under Windows in Phar files. #5813

Closed
wants to merge 1 commit into from

3 participants

@slaff

The following change makes it possible to use the classmap autoloader also under Windows in phar context.
(Example path: 'phar://D:/GDrive/zs-client.phar/module/Client/autoload_classmap.php')

Slavey Karadzhov Fixed the classmap autoloader to work under Windows in Phar files.
(Example path: 'phar://D:/GDrive/zs-client.phar/module/Client/autoload_classmap.php')
4dfad98
@slaff slaff referenced this pull request in zend-patterns/ZendServerSDK
Closed

Windows phar file issues #24

@ezimuel
Owner

@slaff can you provide a unit test to cover this use case? Thanks.

@slaff

@ezimuel There is already test case for this that before this patch was failing under Windows. The name of the test is testCanLoadClassMapFromPhar and is here: https://github.com/zendframework/zf2/blob/master/tests/ZendTest/Loader/ClassMapAutoloaderTest.php#L168

@ezimuel ezimuel self-assigned this
@ezimuel ezimuel added this to the 2.2.6 milestone
@ezimuel
Owner

Merged with commit @6f2d379

@ezimuel ezimuel closed this
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5813' into develop
Forward port #5813

Conflicts:
	library/Zend/Code/Reflection/FunctionReflection.php
	library/Zend/Code/Reflection/MethodReflection.php
	tests/ZendTest/Code/Reflection/FunctionReflectionTest.php
4d8a7eb
@weierophinney

Merged to develop as well with 4d8a7eb

@weierophinney weierophinney modified the milestone: 2.2.6
@weierophinney weierophinney referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-loader
@weierophinney weierophinney Merge branch 'hotfix/5813' into develop
Forward port zendframework/zf2#5813

Conflicts:
	library/Zend/Code/Reflection/FunctionReflection.php
	library/Zend/Code/Reflection/MethodReflection.php
	tests/ZendTest/Code/Reflection/FunctionReflectionTest.php
09e0edf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 11, 2014
  1. Fixed the classmap autoloader to work under Windows in Phar files.

    Slavey Karadzhov authored
    (Example path: 'phar://D:/GDrive/zs-client.phar/module/Client/autoload_classmap.php')
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 library/Zend/Loader/ClassMapAutoloader.php
View
7 library/Zend/Loader/ClassMapAutoloader.php
@@ -197,11 +197,12 @@ protected function loadMapFromFile($location)
*/
public static function realPharPath($path)
{
- if (strpos($path, 'phar:///') !== 0) {
+ if (!preg_match('|^phar:(/{2,3})|',$path, $match)) {
return;
}
- $parts = explode('/', str_replace(array('/', '\\'), '/', substr($path, 8)));
+ $prefixLength = 5 + strlen($match[1]);
+ $parts = explode('/', str_replace(array('/', '\\'), '/', substr($path, $prefixLength)));
$parts = array_values(array_filter($parts, function ($p) {
return ($p !== '' && $p !== '.');
}));
@@ -213,7 +214,7 @@ public static function realPharPath($path)
}
});
- if (file_exists($realPath = 'phar:///' . implode('/', $parts))) {
+ if (file_exists($realPath = str_pad('phar:', $prefixLength, '/') . implode('/', $parts))) {
return $realPath;
}
}
Something went wrong with that request. Please try again.