diff --git a/src/CurlHttpMessage/Factory.php b/src/CurlHttpMessage/Factory.php index b530c09f..883fb0a2 100644 --- a/src/CurlHttpMessage/Factory.php +++ b/src/CurlHttpMessage/Factory.php @@ -113,7 +113,7 @@ public function buildRequest($method, $uri, $headers = array(), $body = null) */ public function buildResponse($code = 200, $reasonPhrase = '', $headers = array(), $body = null) { - $response = new Response($code, $reasonPhrase); + $response = new Response($code, (string) $reasonPhrase); $response = $this->withHeaders($response, $headers); $response = $this->withBody($response, $body); return $response; diff --git a/src/Debug/Autoloader.php b/src/Debug/Autoloader.php index 7e109f35..cf4b7d5a 100644 --- a/src/Debug/Autoloader.php +++ b/src/Debug/Autoloader.php @@ -63,6 +63,34 @@ public function unregister() return \spl_autoload_unregister(array($this, 'autoload')); } + /** + * Add classname to classMap + * + * @param string $className ClassName + * @param string $filepath Filepath to class' definition + * + * @return static + */ + public function addClass($className, $filepath) + { + $this->classMap[$className] = $filepath; + return $this; + } + + /** + * Add Psr4 mapping to autoloader + * + * @param string $namespace Namespace prefix + * @param string $dir Directory containing namespace + * + * @return static + */ + public function addPsr4($namespace, $dir) + { + $this->psr4Map[$namespace] = $dir; + return $this; + } + /** * Debug class autoloader * diff --git a/src/Debug/Plugin/Method/ReqRes.php b/src/Debug/Plugin/Method/ReqRes.php index e85e4206..0746e182 100644 --- a/src/Debug/Plugin/Method/ReqRes.php +++ b/src/Debug/Plugin/Method/ReqRes.php @@ -14,7 +14,7 @@ use bdk\Debug; use bdk\Debug\Plugin\CustomMethodTrait; -use bdk\HttpMessage\HttpFoundationBridge; +use bdk\HttpMessage\Utility\HttpFoundationBridge; use bdk\HttpMessage\Utility\Response as ResponseUtil; use bdk\PubSub\Event; use bdk\PubSub\SubscriberInterface; diff --git a/tests/CurlHttpMessage/Middleware/FollowLocationTest.php b/tests/CurlHttpMessage/Middleware/FollowLocationTest.php index 6c0da755..85e15181 100644 --- a/tests/CurlHttpMessage/Middleware/FollowLocationTest.php +++ b/tests/CurlHttpMessage/Middleware/FollowLocationTest.php @@ -2,13 +2,7 @@ namespace bdk\Test\CurlHttpMessage\Middleware; -/* -use bdk\CurlHttpMessage\Handler\CurlMulti; -use bdk\HttpMessage\Request; -*/ - use bdk\CurlHttpMessage\Client; -use bdk\CurlHttpMessage\CurlReqRes; use bdk\CurlHttpMessage\Exception\RequestException; use bdk\CurlHttpMessage\Handler\Mock as MockHandler; use bdk\CurlHttpMessage\Middleware\FollowLocation; diff --git a/tests/Debug/noComposer.php b/tests/Debug/noComposer.php index 52a454de..cc4bbb3d 100644 --- a/tests/Debug/noComposer.php +++ b/tests/Debug/noComposer.php @@ -7,6 +7,8 @@ require __DIR__ . '/../../src/Debug/Autoloader.php'; $autoloader = new \bdk\Debug\Autoloader(); $autoloader->register(); +$autoloader->addPsr4('bdk\\HttpMessage\\', __DIR__ . '/../../vendor/bdk/http-message/src/HttpMessage'); +$autoloader->addPsr4('Psr\\Http\\Message\\', __DIR__ . '/../../vendor/psr/http-message/src'); $debug = new \bdk\Debug(array( 'collect' => true,