Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Issue 16 Refactor Routing #336

Merged
merged 40 commits into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
35b0ea1
fixes 16
prisis Aug 6, 2016
e74caa5
micro-optimization
prisis Aug 6, 2016
7a32f98
working on route
prisis Aug 6, 2016
670f058
remove old tests
prisis Aug 7, 2016
182978d
added a ByteCountingStream
prisis Aug 7, 2016
52a6f5f
update interfaces
prisis Aug 7, 2016
362398a
added more functions to route
prisis Aug 8, 2016
f85a692
remove interface
prisis Aug 8, 2016
dc16244
added Container\Traits\ContainerAwareTrait,
prisis Aug 8, 2016
ac762be
fix
prisis Aug 9, 2016
91d2421
Added some tests
prisis Aug 9, 2016
cd173e3
remove rapid route
prisis Aug 9, 2016
df45b96
More work on routing
prisis Aug 10, 2016
e82fcf4
added more tests | start adding benchmarks | adding matcher for uri s…
prisis Aug 12, 2016
7d1cda0
cs fix
prisis Aug 12, 2016
a64168e
fix call for a stdclass VarExporter
prisis Aug 12, 2016
8356efb
cs fixes | remove some magic
prisis Aug 13, 2016
afd1e05
remove some magic
prisis Aug 13, 2016
b247d7a
cs fixes
prisis Aug 13, 2016
b05559e
added new matcher
prisis Aug 13, 2016
5acb592
added all matcher
prisis Aug 13, 2016
59a4058
remove ParameterMatcher | start adding tests
prisis Aug 14, 2016
32aebd7
added more tests
prisis Aug 14, 2016
299740d
more tests
prisis Aug 14, 2016
d4f8145
more tests
prisis Aug 14, 2016
4c364b2
added more tests
prisis Aug 14, 2016
63bab5e
added more tests
prisis Aug 15, 2016
7c5cab8
Scrutinizer Auto-Fixes (#339)
scrutinizer-auto-fixer Aug 15, 2016
a677e60
cs fixes
prisis Aug 15, 2016
dee7c14
Merge branch 'develop' into issue-16-switch_to_RapidRoute
prisis Aug 15, 2016
1d8abad
added all tests for parser
prisis Aug 15, 2016
10c51d6
Cs fixes
prisis Aug 15, 2016
16bfc95
remove need for str class
prisis Aug 15, 2016
db9c7b5
Support command aliases
prisis Aug 15, 2016
781aca4
update dispatcher
prisis Aug 15, 2016
8695267
improve Console
prisis Aug 16, 2016
12015b1
Scrutinizer Auto-Fixes (#342)
scrutinizer-auto-fixer Aug 16, 2016
e246d32
Scrutinizer Auto-Fixes (#343)
scrutinizer-auto-fixer Aug 16, 2016
e6d6baa
cs fixes
prisis Aug 16, 2016
3371e87
Scrutinizer Auto-Fixes (#344)
scrutinizer-auto-fixer Aug 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions benchmarks/Routing/RouteParserBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Narrowspark\Routing;

use Benchmark;

class RouteParserBench implements Benchmark
{

}
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"php" : "7.0.0 - 7.0.5 || ^7.0.7",
"ext-openssl" : "*",
"ext-fileinfo" : "*",
"cache/chain-adapter" : "^0.3",
"cache/chain-adapter" : "^0.4",
"cache/namespaced-cache" : "^0.1",
"classpreloader/classpreloader" : "^3.0",
"container-interop/container-interop" : "^1.1",
Expand All @@ -47,14 +47,13 @@
"php-di/invoker" : "^1.3",
"phpseclib/phpseclib" : "^2.0",
"nesbot/carbon" : "^1.21",
"nikic/fast-route" : "^0.6",
"ramsey/uuid" : "^3.4",
"paragonie/constant_time_encoding" : "^2.0",
"paragonie/password_lock" : "^3.0",
"psr/cache" : "^1.0",
"psr/log" : "^1.0",
"psr/http-message" : "^1.0",
"psy/psysh" : "^0.6",
"ramsey/uuid" : "^3.4",
"roave/security-advisories" : "dev-master",
"schnittstabil/csrf-tokenservice" : "^2.0",
"stecman/symfony-console-completion" : "^0.6",
Expand Down Expand Up @@ -104,7 +103,7 @@
"aws/aws-sdk-php" : "^3.18",
"cache/array-adapter" : "^0.4",
"cache/filesystem-adapter" : "^0.3",
"cache/session-handler" : "^0.1",
"cache/session-handler" : "^0.2",
"cache/void-adapter" : "^0.3",
"fzaninotto/faker" : "^1.6",
"guzzlehttp/guzzle" : "^6.0",
Expand Down Expand Up @@ -133,9 +132,10 @@
},
"autoload": {
"psr-4": {
"Viserio\\" : "src/Viserio/"
"Viserio\\" : "src/Viserio/",
"Narrowspark\\" : "benchmarks/"
},
"exclude-from-classmap" : ["src/Viserio/**/Tests/"]
"exclude-from-classmap" : ["src/Viserio/**/Tests/", "benchmarks/"]
},
"extra": {
"branch-alias": {
Expand Down
5 changes: 5 additions & 0 deletions phpbench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"bootstrap": "vendor/autoload.php",
"path": "benchmarks",
"progress": "dots"
}
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
<testsuite name="Narrowspark Queue Component Test Suite">
<directory>./src/Viserio/Queue/Tests</directory>
</testsuite>
<!-- <testsuite name="Narrowspark Routing Component Test Suite">
<testsuite name="Narrowspark Routing Component Test Suite">
<directory>./src/Viserio/Routing/Tests</directory>
</testsuite> -->
</testsuite>
<testsuite name="Narrowspark Session Component Test Suite">
<directory>./src/Viserio/Session/Tests</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Viserio\Contracts\Bus\Dispatcher as DispatcherContract;
use Viserio\Pipeline\Pipeline;
use Viserio\Support\Invoker;
use Viserio\Support\Traits\ContainerAwareTrait;
use Viserio\Contracts\Container\Traits\ContainerAwareTrait;

class Dispatcher implements DispatcherContract
{
Expand Down
10 changes: 5 additions & 5 deletions src/Viserio/Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
],
"require": {
"php" : "7.0.0 - 7.0.5 || ^7.0.7",
"cache/chain-adapter" : "^0.3",
"cache/chain-adapter" : "^0.4",
"cache/namespaced-cache" : "^0.1",
"psr/cache" : "^1.0",
"viserio/config" : "self.version",
"viserio/cotracts" : "self.version"
},
"require-dev": {
"cache/array-adapter" : "^0.2",
"cache/array-adapter" : "^0.4",
"cache/filesystem-adapter" : "^0.3",
"cache/session-handler" : "^0.1",
"cache/session-handler" : "^0.2",
"cache/void-adapter" : "^0.3",
"narrowspark/php-cs-fixer-config" : "^1.1",
"narrowspark/testing-helper" : "^1.5",
Expand Down Expand Up @@ -76,13 +76,13 @@
"suggest": {
"cache/apc-adapter" : "Required to use the Apc cache (^0.3).",
"cache/apcu-adapter" : "Required to use the Apcu cache (^0.3).",
"cache/array-adapter" : "Required to use the Array cache (^0.2)",
"cache/array-adapter" : "Required to use the Array cache (^0.4)",
"cache/filesystem-adapter" : "Required to use the Filesystem cache (^0.3).",
"cache/memcache-adapter" : "Required to use the Memcache cache (^0.3).",
"cache/memcached-adapter" : "Required to use the Memcached cache (^0.3).",
"cache/mongodb-adapter" : "Required to use the Mongodb cache (^0.2).",
"cache/predis-adapter" : "Required to use the Predis cache (^0.4).",
"cache/session-handler" : "Required to use the Session cache (^0.1).",
"cache/session-handler" : "Required to use the Session cache (^0.2).",
"cache/void-adapter" : "Required to use the Void cache (^0.3)."
},
"minimum-stability" : "dev",
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Viserio\Console\Input\InputOption;
use Viserio\Contracts\Console\Application as ApplicationContract;
use Viserio\Support\Invoker;
use Viserio\Support\Traits\ContainerAwareTrait;
use Viserio\Contracts\Container\Traits\ContainerAwareTrait;

class Application extends SymfonyConsole implements ApplicationContract
{
Expand Down
8 changes: 4 additions & 4 deletions src/Viserio/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
Question\Question
};
use Viserio\Console\Style\NarrowsparkStyle;
use Viserio\Contracts\Support\Arrayable;
use Viserio\Support\{
Invoker,
Traits\ContainerAwareTrait
use Viserio\Contracts\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

Support\Arrayable,
Container\Traits\ContainerAwareTrait
};
use Viserio\Support\Invoker;

abstract class Command extends BaseCommand implements CompletionAwareInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Container/ContextualBindingBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Viserio\Container;

use Viserio\Contracts\Container\ContextualBindingBuilder as ContextualBindingBuilderContract;
use Viserio\Support\Traits\ContainerAwareTrait;
use Viserio\Contracts\Container\Traits\ContainerAwareTrait;

/**
* ContextualBindingBuilder.
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Container/Inflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Viserio\Container;

use Viserio\Support\Traits\ContainerAwareTrait;
use Viserio\Contracts\Container\Traits\ContainerAwareTrait;

class Inflector
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace Viserio\Support\Traits;
namespace Viserio\Contracts\Container\Traits;

use Interop\Container\ContainerInterface;
use RuntimeException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace Viserio\Contracts\Http\Exceptions;

use RuntimeException;
use Throwable;

class ByteCountingStreamException extends RuntimeException
{
/**
* Expect number of bytes to be read.
*
* @var int
*/
private $expectBytes;

/**
* Actual number of bytes remaining.
*
* @var int
*/
private $actualBytes;

/**
* ByteCountingStreamException constructor.
*
* @param int $expect expected bytes to be read
* @param int $actual actual available bytes to read
* @param \Throwable|null $previous Exception being thrown
*/
public function __construct(int $expect, int $actual, Throwable $previous = null)
{
$msg = 'The ByteCountingStream decorator expects to be able to '
. sprintf('read %s bytes from a stream, but the stream being decorated ', $expect)
. sprintf('only contains %s bytes.', $actual);

$this->expectBytes = $expect;
$this->actualBytes = $actual;

parent::__construct($msg, 0, $previous);
}

/**
* Get expected bytes to be read.
*
* @return int
*/
public function getExpectBytes(): int
{
return $this->expectBytes;
}

/**
* Get remaining bytes available for read.
*
* @return int
*/
public function getRemainingBytes(): int
{
return $this->actualBytes;
}
}
24 changes: 0 additions & 24 deletions src/Viserio/Contracts/Routing/CustomStrategy.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/Viserio/Contracts/Routing/DataGenerator.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Viserio\Contracts\Routing\Exceptions;

use Exception;

class InvalidRouteDataException extends Exception
{
public function __construct($data)
{
parent::__construct(
sprintf(
'The supplied route data is invalid: expecting object or array, %s given',
gettype($data)
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Viserio\Contracts\Routing\Exceptions;

use Exception;

class InvalidRoutePatternException extends Exception
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Viserio\Contracts\Routing\Exceptions;

use Exception;

class UrlGenerationException extends Exception
{
/**
* Create a new exception for missing route parameters.
*
* @param \Viserio\Routing\Route $route
*
* @return static
*/
public static function forMissingParameters($route)
{
return new static(sprintf(
'Missing required parameters for [Route: %s] [URI: %s].',
$route->getName(),
$route->getUri()
));
}
}