This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Issue 16 Refactor Routing #336
Merged
Merged
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
35b0ea1
fixes 16
prisis e74caa5
micro-optimization
prisis 7a32f98
working on route
prisis 670f058
remove old tests
prisis 182978d
added a ByteCountingStream
prisis 52a6f5f
update interfaces
prisis 362398a
added more functions to route
prisis f85a692
remove interface
prisis dc16244
added Container\Traits\ContainerAwareTrait,
prisis ac762be
fix
prisis 91d2421
Added some tests
prisis cd173e3
remove rapid route
prisis df45b96
More work on routing
prisis e82fcf4
added more tests | start adding benchmarks | adding matcher for uri s…
prisis 7d1cda0
cs fix
prisis a64168e
fix call for a stdclass VarExporter
prisis 8356efb
cs fixes | remove some magic
prisis afd1e05
remove some magic
prisis b247d7a
cs fixes
prisis b05559e
added new matcher
prisis 5acb592
added all matcher
prisis 59a4058
remove ParameterMatcher | start adding tests
prisis 32aebd7
added more tests
prisis 299740d
more tests
prisis d4f8145
more tests
prisis 4c364b2
added more tests
prisis 63bab5e
added more tests
prisis 7c5cab8
Scrutinizer Auto-Fixes (#339)
scrutinizer-auto-fixer a677e60
cs fixes
prisis dee7c14
Merge branch 'develop' into issue-16-switch_to_RapidRoute
prisis 1d8abad
added all tests for parser
prisis 10c51d6
Cs fixes
prisis 16bfc95
remove need for str class
prisis db9c7b5
Support command aliases
prisis 781aca4
update dispatcher
prisis 8695267
improve Console
prisis 12015b1
Scrutinizer Auto-Fixes (#342)
scrutinizer-auto-fixer e246d32
Scrutinizer Auto-Fixes (#343)
scrutinizer-auto-fixer e6d6baa
cs fixes
prisis 3371e87
Scrutinizer Auto-Fixes (#344)
scrutinizer-auto-fixer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php", | ||
"path": "benchmarks", | ||
"progress": "dots" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...io/Support/Traits/ContainerAwareTrait.php → .../Container/Traits/ContainerAwareTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/Viserio/Contracts/Http/Exceptions/ByteCountingStreamException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/Viserio/Contracts/Routing/Exceptions/InvalidRouteDataException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Viserio/Contracts/Routing/Exceptions/InvalidRoutePatternException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Viserio/Contracts/Routing/Exceptions/UrlGenerationException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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