Skip to content

Commit

Permalink
Revert all changes to v0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Nov 15, 2023
1 parent bfa6a9a commit f4c6f9f
Show file tree
Hide file tree
Showing 41 changed files with 444 additions and 532 deletions.
18 changes: 0 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@

All notable changes to `Slytherin` will be documented in this file.

## [0.9.6](https://github.com/rougin/slytherin/compare/v0.9.5...v0.9.6) - Unreleased

**NOTE**: This release may break your application if upgrading from `v0.9.5` release.

### Added
- `AbstractDispatcher` for identicals methods in route dispatchers
- Compatability for multiple `http-interop/http-middleware` versions

### Changed
- Add `\` when `$namespace` property is defined in `Routing\Router`
- Single uploaded file will not return an array in `UploadedFile::normalize`

### Removed
- Extension of other route dispatchers to `Routing\Dispatcher`

### Fixed
- Compatability of `LeagueContainer` in PHP v7.2.0 (only supports versions until `2.9`)

## [0.9.5](https://github.com/rougin/slytherin/compare/v0.9.4...v0.9.5) - 2017-02-23

### Changed
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Rougin Gutib
Copyright (c) 2023 Rougin Gutib

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 2 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@
},
"require-dev":
{
"phpunit/phpunit": "~4.2|~5.7",
"scrutinizer/ocular": "~1.1.0"
"phpunit/phpunit": "~4.2",
"scrutinizer/ocular": "~1.1"
},
"autoload":
{
"files":
[
"src/Middleware/HandlerInterface.php",
"src/Middleware/MiddlewareInterface.php"
],
"psr-4":
{
"Rougin\\Slytherin\\": "src"
Expand All @@ -42,16 +37,5 @@
{
"Rougin\\Slytherin\\": "tests"
}
},
"scripts":
{
"test": "phpunit"
},
"extra":
{
"branch-alias":
{
"dev-master": "1.0-dev"
}
}
}
2 changes: 0 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<testsuites>
<testsuite name="Slytherin Test Suite">
<directory>tests</directory>
<exclude>./src/Middleware/HandlerInterface.php</exclude>
<exclude>./src/Middleware/MiddlewareInterface.php</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Application
// NOTE: To be removed in v1.0.0
const ERROR_HANDLER = 'Rougin\Slytherin\Debug\ErrorHandlerInterface';

const MIDDLEWARE = 'Rougin\Slytherin\Middleware\MiddlewareInterface';
const MIDDLEWARE = 'Interop\Http\ServerMiddleware\MiddlewareInterface';

const SERVER_REQUEST = 'Psr\Http\Message\ServerRequestInterface';

Expand Down
11 changes: 2 additions & 9 deletions src/Container/AurynContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,9 @@ class AurynContainer extends Injector implements ContainerInterface
*/
public function __construct($data = null)
{
if ($data instanceof Injector)
{
$this->injector = $data;
}
else
{
parent::__construct($data);
is_a($data, 'Auryn\Injector') || parent::__construct($data);

$this->injector = $this;
}
$this->injector = get_class($data) === 'Auryn\Injector' ? $data : $this;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/Container/LeagueContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ class LeagueContainer extends BaseContainer implements ContainerInterface
* @throws \Psr\Container\ContainerExceptionInterface
*
* @param string $id
* @param array $arguments
* @return mixed
*/
public function get($id, array $arguments = array())
public function get($id)
{
return parent::get($id, $arguments);
return parent::get($id);
}

/**
Expand Down
82 changes: 38 additions & 44 deletions src/Http/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,77 +144,71 @@ public function moveTo($target)
}

/**
* Returns a \UploadedFile instance from $_FILES.
* Parses the $_FILES into multiple \File instances.
*
* @param array $file
* @return \Psr\Http\Message\UploadedFileInterface
* @param array $uploaded
* @param array $files
* @return \Zapheus\Http\Message\FileInterface[]
*/
public static function create(array $file)
public static function normalize(array $uploaded, $files = array())
{
if (is_array($file['tmp_name']) === false) {
$tmp = (string) $file['tmp_name'];

$size = $file['size'];

$error = $file['error'];
foreach (self::diverse($uploaded) as $name => $file) {
list($files[$name], $items) = array($file, array());

$original = $file['name'];
if (isset($file['name']) === true) {
foreach ($file['name'] as $key => $value) {
$instance = self::create($file, $key);

$type = $file['type'];
$items[] = $instance;
}

return new UploadedFile($tmp, $size, $error, $original, $type);
$files[$name] = (array) $items;
}
}

return self::nested($file);
return $files;
}

/**
* Returns an array of \UploadedFile instances from $_FILES.
* Creates a new UploadedFile instance.
*
* @param array $files
* @return \Psr\Http\Message\UploadedFileInterface[]
* @param array $file
* @param integer $key
* @return \Psr\Http\Message\UploadedFile
*/
public static function nested(array $files)
protected static function create(array $file, $key)
{
$normalized = array();

foreach (array_keys($files['tmp_name']) as $key) {
$file = array('tmp_name' => $files['tmp_name'][$key]);
$tmp = $file['tmp_name'][$key];

$file['size'] = $files['size'][$key];
$size = $file['size'][$key];

$file['error'] = $files['error'][$key];
$error = $file['error'][$key];

$file['name'] = $files['name'][$key];
$original = $file['name'][$key];

$file['type'] = $files['type'][$key];
$type = $file['type'][$key];

$normalized[$key] = self::create($file);
}

return $normalized;
return new UploadedFile($tmp, $size, $error, $original, $type);
}

/**
* Parses the $_FILES into multiple \UploadedFile instances.
* Diverse the $_FILES into a consistent result.
*
* @param array $files
* @return \Psr\Http\Message\UploadedFileInterface[]
* @param array $uploaded
* @return array
*/
public static function normalize(array $files)
protected static function diverse(array $uploaded)
{
$normalized = array();

foreach ((array) $files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
} elseif (isset($value['tmp_name']) === true) {
$normalized[$key] = self::create($value);
} elseif (is_array($value) === true) {
$normalized[$key] = self::normalize($value);
$result = array();

foreach ($uploaded as $file => $item) {
foreach ($item as $key => $value) {
$diversed = (array) $value;

$result[$file][$key] = $diversed;
}
}

return $normalized;
return $result;
}
}
12 changes: 2 additions & 10 deletions src/Integration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@ class Configuration implements ConfigurationInterface
protected $data = array();

/**
* Initializes the configuration instance.
*
* @param array|string|null $data
*/
public function __construct($data = null)
{
if (is_array($data))
{
$this->data = $data;
}
$this->data = is_array($data) ? $data : $this->data;

if (is_string($data))
{
$this->load($data);
}
$this->data = is_string($data) ? $this->load($data) : $this->data;
}

/**
Expand Down
22 changes: 9 additions & 13 deletions src/Middleware/CallableMiddlewareWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rougin\Slytherin\Middleware;

use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Rougin\Slytherin\Middleware\HandlerInterface;

/**
* Callable Middleware Wrapper
Expand Down Expand Up @@ -43,26 +43,22 @@ public function __construct($middleware, ResponseInterface $response = null)
/**
* Processes an incoming server request and return a response.
*
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Rougin\Slytherin\Middleware\HandlerInterface $handler
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Interop\Http\ServerMiddleware\DelegateInterface $delegate
* @return \Psr\Http\Message\ResponseInterface
*/
public function process(ServerRequestInterface $request, HandlerInterface $handler)
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$middleware = $this->middleware;

if ($this->response !== null)
{
$handler = function ($request) use ($handler)
{
return $handler->{HANDLER_METHOD}($request);
if ($this->response instanceof ResponseInterface) {
$delegate = function ($request) use ($delegate) {
return $delegate->process($request);
};

$response = $this->response;

return $middleware($request, $response, $handler);
return $middleware($request, $this->response, $delegate);
}

return $middleware($request, $handler);
return $middleware($request, $delegate);
}
}
11 changes: 0 additions & 11 deletions src/Middleware/Delegate.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ public function process(ServerRequestInterface $request)
return call_user_func($this->callback, $request);
}

/**
* Dispatch the next available middleware and return the response.
*
* @param \Psr\Http\Message\ServerRequestInterface $request
* @return \Psr\Http\Message\ResponseInterface
*/
public function handle(ServerRequestInterface $request)
{
return $this->process($request);
}

/**
* Dispatch the next available middleware and return the response.
*
Expand Down
Loading

0 comments on commit f4c6f9f

Please sign in to comment.