Skip to content

Commit

Permalink
Merge pull request #18 from TheDragonCode/5.x
Browse files Browse the repository at this point in the history
Bump `dragon-code/support` to 6.1
  • Loading branch information
Andrey Helldar authored Apr 21, 2022
2 parents fc63580 + f63ddbf commit 9a75c33
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 327 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/laravel-6.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/laravel-7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ "7.3", "7.4", "8.0" ]
php: [ "8.0" ]
laravel: [ "7.0" ]

name: PHP ${{ matrix.php }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/laravel-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ "7.3", "7.4", "8.0", "8.1" ]
php: [ "8.0", "8.1" ]
laravel: [ "8.0" ]

name: PHP ${{ matrix.php }}
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ The core of applications for working with routes:
[![Github Workflow Status][badge_build]][link_build]
[![License][badge_license]][link_license]

## Upgrade from `andrey-helldar/laravel-routes-core`

1. Replace `"andrey-helldar/laravel-routes-core": "^3.0"` with `"dragon-code/laravel-routes-core": "^4.0"` in the `composer.json` file;
2. Replace `Helldar\LaravelRoutesCore` with `DragonCode\LaravelRoutesCore`;
3. Run the `composer update` console command.

## License

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
"source": "https://github.com/TheDragonCode/laravel-routes-core"
},
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"dragon-code/contracts": "^2.6",
"dragon-code/laravel-support": "^3.2",
"dragon-code/support": "^5.6",
"illuminate/routing": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"dragon-code/support": "^6.1",
"illuminate/routing": "^7.0 || ^8.0 || ^9.0",
"illuminate/support": "^7.0 || ^8.0 || ^9.0",
"phpdocumentor/reflection-docblock": "^5.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0",
"phpunit/phpunit": "^8.0 || ^9.0"
"orchestra/testbench": "^5.0 || ^6.0 || ^7.0",
"phpunit/phpunit": "^9.0"
},
"conflict": {
"andrey-helldar/laravel-routes-core": "*"
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class Annotation extends Facade
{
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return Support::class;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class Routes extends Facade
{
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return Support::class;
}
Expand Down
71 changes: 16 additions & 55 deletions src/Models/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@

namespace DragonCode\LaravelRoutesCore\Models;

use DragonCode\LaravelRoutesCore\Traits\Makeable;
use Illuminate\Support\Str;
use DragonCode\Support\Concerns\Makeable;
use DragonCode\Support\Facades\Helpers\Str;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlockFactory;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use Reflector;

class Reader
{
use Makeable;

protected $controller;

protected $method;

public function __construct(string $controller, ?string $method = null)
{
$this->controller = $controller;
$this->method = $method;
public function __construct(
protected string $controller,
protected ?string $method = null
) {
}

/**
* @throws ReflectionException
*
* @return \phpDocumentor\Reflection\DocBlock|null
*/
public function forClass()
public function forClass(): ?DocBlock
{
[$controller, $method] = $this->parse();

Expand All @@ -39,12 +29,7 @@ public function forClass()
);
}

/**
* @throws ReflectionException
*
* @return \phpDocumentor\Reflection\DocBlock|null
*/
public function forMethod()
public function forMethod(): ?DocBlock
{
[$controller, $method] = $this->parse();

Expand All @@ -54,11 +39,6 @@ public function forMethod()
) : null;
}

/**
* @param Reflector|null $reflection
*
* @return \phpDocumentor\Reflection\DocBlock|null
*/
protected function get(?Reflector $reflection = null): ?DocBlock
{
if ($reflection && $comment = $reflection->getDocComment()) {
Expand All @@ -71,42 +51,23 @@ protected function get(?Reflector $reflection = null): ?DocBlock
protected function parse(): array
{
if (is_null($this->method)) {
return Str::contains($this->controller, '@')
? [Str::before($this->controller, '@'), Str::after($this->controller, '@')]
: [$this->controller, null];
if (Str::contains($this->controller, '@')) {
return [Str::before($this->controller, '@'), Str::after($this->controller, '@')];
}

return [$this->controller, null];
}

return [$this->controller, $this->method];
}

/**
* Getting class reflection instance.
*
* @param string $class
*
* @throws ReflectionException
*
* @return ReflectionClass
*/
protected function reflectionClass(string $class)
protected function reflectionClass(string $class): ReflectionClass
{
return new ReflectionClass($class);
}

/**
* Getting method reflection instance from reflection class.
*
* @param ReflectionClass $class
* @param string $method
*
* @throws ReflectionException
*
* @return ReflectionMethod|null
*/
protected function reflectionMethod(ReflectionClass $class, string $method)
protected function reflectionMethod(ReflectionClass $class, string $method): ?ReflectionMethod
{
return $class->hasMethod($method)
? $class->getMethod($method)
: null;
return $class->hasMethod($method) ? $class->getMethod($method) : null;
}
}
Loading

0 comments on commit 9a75c33

Please sign in to comment.