Skip to content

Commit

Permalink
Version 0.4.5
Browse files Browse the repository at this point in the history
- Improved Inphinit\Experimental\Dir class to extended classes
- Removed unused "use"s
- New method: Inphinit\Helper::ksort (sort multidimensional arrays by keys)
- Fixed Inphinit\Http\Request::raw() method for old PHP versions
- Fixed Inphinit\Http\Response::removeHeader() method for dispatched headers
- Improved Inphinit\Uri::canonquery
  • Loading branch information
brcontainer committed Oct 13, 2019
1 parent 19f0e97 commit 8c6b676
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 19 deletions.
8 changes: 3 additions & 5 deletions src/Experimental/Dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace Inphinit\Experimental;

use Inphinit\File;

class Dir implements \IteratorAggregate
{
private $iterator;
Expand Down Expand Up @@ -85,7 +83,7 @@ public function getIterator()
*/
public static function root()
{
return new self(INPHINIT_ROOT);
return new static(INPHINIT_ROOT);
}

/**
Expand All @@ -95,7 +93,7 @@ public static function root()
*/
public static function storage()
{
return new self(INPHINIT_PATH . 'storage/');
return new static(INPHINIT_PATH . 'storage/');
}

/**
Expand All @@ -105,7 +103,7 @@ public static function storage()
*/
public static function application()
{
return new self(INPHINIT_PATH . 'application/');
return new static(INPHINIT_PATH . 'application/');
}

public function __destruct()
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Inphinit\Experimental;

use Inphinit\App;
use Inphinit\Storage;

class Maintenance
{
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Routing/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Inphinit\Experimental\Routing;

use Inphinit\App;
use Inphinit\Regex;
use Inphinit\Http\Request;
use Inphinit\Routing\Router;
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Routing/Quick.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Inphinit\Experimental\Routing;

use Inphinit\App;
use Inphinit\Routing\Route;
use Inphinit\Routing\Router;
use Inphinit\Experimental\Exception;
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Routing/Redirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Inphinit\Experimental\Routing;

use Inphinit\Uri;
use Inphinit\Regex;
use Inphinit\Experimental\Exception;
use Inphinit\Experimental\Http\Redirect;
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Routing/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Inphinit\Experimental\Routing;

use Inphinit\App;
use Inphinit\Routing\Route;
use Inphinit\Routing\Router;
use Inphinit\Experimental\Exception;
Expand Down
1 change: 0 additions & 1 deletion src/Experimental/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Inphinit\Experimental;

use Inphinit\Storage;
use Inphinit\Http\Response;

class Session implements \IteratorAggregate
{
Expand Down
2 changes: 1 addition & 1 deletion src/Inphinit/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class App
{
/** Inphinit framework version */
const VERSION = '0.4.4';
const VERSION = '0.4.5';

private static $events = array();
private static $configs = array();
Expand Down
18 changes: 18 additions & 0 deletions src/Inphinit/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,22 @@ public static function assoc($array)
{
return false === self::seq($array);
}

/**
* Check if array is associative, like [ 'bar' => foo', 'baz' => 'bar']
*
* @param array $array
* @param int $flags See details in https://www.php.net/manual/en/function.sort.php#refsect1-function.sort-parameters
* @return null
*/
public static function ksort(array &$array, $flags = \SORT_REGULAR)
{
foreach ($array as &$item) {
if (is_array($item)) {
self::ksort($item, $flags);
}
}

ksort($array, $flags);
}
}
1 change: 1 addition & 0 deletions src/Inphinit/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Inphinit\Http;

use Inphinit\Helper;
use Inphinit\Storage;

class Request
{
Expand Down
12 changes: 8 additions & 4 deletions src/Inphinit/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ public static function putHeader($name, $value, $replace = true)
}

/**
* Remove registered header
* Remove registered (or setted) header
*
* @param string $name
* @return void
*/
public static function removeHeader($name)
{
self::$headers = array_filter(self::$headers, function ($header) use ($name) {
return strcasecmp($header[0], $name) !== 0;
});
if (self::$dispatchedHeaders || App::state() > 2) {
header_remove($name);
} else {
self::$headers = array_filter(self::$headers, function ($header) use ($name) {
return strcasecmp($header[0], $name) !== 0;
});
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Inphinit/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace Inphinit;

use Inphinit\Helper;

class Uri
{
/** Use with `Uri::encodepath` for allow path with ascii characters */
Expand Down Expand Up @@ -187,7 +185,7 @@ public static function canonquery($query, $prefix = '')
return '';
}

ksort($args);
Helper::ksort($args);
return $prefix . http_build_query($args);
}
}

0 comments on commit 8c6b676

Please sign in to comment.