Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'dhazel/hotfix/autoloader-error-improvem…
Browse files Browse the repository at this point in the history
…ent'
  • Loading branch information
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ClassMapAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setOptions($options)
* An autoload map should be an associative array containing
* classname/file pairs.
*
* @param string|array $location
* @param string|array $map
* @return ClassMapAutoloader
*/
public function registerAutoloadMap($map)
Expand All @@ -99,7 +99,10 @@ public function registerAutoloadMap($map)

if (!is_array($map)) {
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException('Map file provided does not return a map');
throw new Exception\InvalidArgumentException(sprintf(
'Map file provided does not return a map. Map file: "%s"',
(isset($location) && is_string($location) ? $location : 'unexpected type: ' . gettype($map))
));
}

$this->map = array_merge($this->map, $map);
Expand Down Expand Up @@ -177,7 +180,10 @@ protected function loadMapFromFile($location)
{
if (!file_exists($location)) {
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException('Map file provided does not exist');
throw new Exception\InvalidArgumentException(sprintf(
'Map file provided does not exist. Map file: "%s"',
(is_string($location) ? $location : 'unexpected type: ' . gettype($location))
));
}

if (!$path = static::realPharPath($location)) {
Expand Down

0 comments on commit af230b7

Please sign in to comment.