Skip to content

Commit ab038d1

Browse files
committed
Merge branch 'release/0.6.30'
2 parents e6c9e49 + da417cb commit ab038d1

24 files changed

+154
-170
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: php:8.4 # This forces the job to run in a Docker container
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Install System Dependencies (Git, Zip, Unzip)
16+
run: |
17+
apt-get update
18+
apt-get install -y unzip git zip
19+
20+
- name: Install and Enable extensions
21+
run: |
22+
docker-php-ext-install sockets calendar
23+
docker-php-ext-enable sockets calendar
24+
25+
- name: Install Composer
26+
run: |
27+
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
28+
composer --version
29+
30+
- name: Install Dependencies
31+
run: composer install --prefer-dist --no-progress
32+
33+
- name: Run PHPUnit
34+
run: vendor/bin/phpunit tests

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
}
1111
],
1212
"require": {
13-
"ext-curl": "*",
14-
"ext-json": "*",
15-
"neuron-php/core": "0.6.*",
16-
"neuron-php/routing": "0.6.*",
17-
"symfony/yaml": "^6.4",
18-
"league/commonmark": "^2.6"
13+
"php": "^8.4",
14+
"ext-curl": "*",
15+
"ext-json": "*",
16+
"neuron-php/application": "0.6.*",
17+
"neuron-php/routing": "0.6.*",
18+
"symfony/yaml": "^6.4",
19+
"league/commonmark": "^2.6"
1920
},
2021
"require-dev": {
2122
"phpunit/phpunit": "9.*",

src/Mvc/Application.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
namespace Neuron\Mvc;
33

4-
use Neuron\Data\Setting\Source\ISettingSource;
54
use Exception;
6-
use Neuron\Core\Application\Base;
7-
use Neuron\Core\CrossCutting\Event;
5+
use Neuron\Application\Base;
6+
use Neuron\Application\CrossCutting\Event;
7+
use Neuron\Core\Exceptions\BadRequestMethod;
8+
use Neuron\Core\Exceptions\MissingMethod;
9+
use Neuron\Core\Exceptions\NotFound;
10+
use Neuron\Data\Setting\Source\ISettingSource;
811
use Neuron\Log\Log;
9-
use Neuron\Mvc\Controllers\BadRequestMethodException;
1012
use Neuron\Mvc\Controllers\Factory;
11-
use Neuron\Mvc\Controllers\MissingMethodException;
12-
use Neuron\Mvc\Controllers\NotFoundException;
1313
use Neuron\Mvc\Events\Http404;
1414
use Neuron\Mvc\Requests\Request;
1515
use Neuron\Patterns\Registry;
@@ -102,7 +102,7 @@ protected function loadRequests(): void
102102
* @param string $Request
103103
* @return Application
104104
*
105-
* @throws BadRequestMethodException
105+
* @throws BadRequestMethod
106106
* @throws Exception
107107
*/
108108
public function addRoute( string $Method, string $Route, string $ControllerMethod, string $Request = '' ) : Application
@@ -151,7 +151,7 @@ function( $Parameters ) use ( $Request )
151151
break;
152152

153153
case RequestMethod::UNKNOWN:
154-
throw new BadRequestMethodException();
154+
throw new BadRequestMethod();
155155
}
156156

157157
$Route->Payload = [ "Controller" => $ControllerMethod ];
@@ -185,9 +185,9 @@ protected function onStart(): bool
185185
/**
186186
* @return void
187187
* @throws Exception
188-
* @throws MissingMethodException
189-
* @throws BadRequestMethodException
190-
* @throws NotFoundException
188+
* @throws MissingMethod
189+
* @throws BadRequestMethod
190+
* @throws NotFound
191191
*/
192192
protected function onRun() : void
193193
{
@@ -201,8 +201,8 @@ protected function onRun() : void
201201
* @param array $Parameters
202202
* @param string $RequestName
203203
* @return mixed
204-
* @throws MissingMethodException
205-
* @throws NotFoundException
204+
* @throws MissingMethod
205+
* @throws NotFound
206206
*/
207207
public function executeController( array $Parameters, string $RequestName = '' ): mixed
208208
{
@@ -215,7 +215,7 @@ public function executeController( array $Parameters, string $RequestName = '' )
215215

216216
if( !method_exists( $Controller, $Method ) )
217217
{
218-
throw new MissingMethodException( "Method '$Method'' not found." );
218+
throw new MissingMethod( "Method '$Method'' not found." );
219219
}
220220

221221
$Request = null;

src/Mvc/Controllers/BadRequestMethodException.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Mvc/Controllers/Base.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use League\CommonMark\Exception\CommonMarkException;
66
use Neuron\Mvc\Application;
7+
use Neuron\Mvc\Responses\HttpResponseStatus;
78
use Neuron\Mvc\Views\Html;
89
use Neuron\Mvc\Views\Json;
910
use Neuron\Mvc\Views\Markdown;
10-
use Neuron\Mvc\Views\NotFoundException;
11+
use Neuron\Mvc\Views\NotFound;
1112
use Neuron\Mvc\Views\Xml;
1213
use Neuron\Routing\Router;
1314

@@ -21,12 +22,12 @@ public function __construct( Router $Router )
2122
}
2223

2324
/**
24-
* @throws NotFoundException
25+
* @throws \Neuron\Core\Exceptions\NotFound
2526
* @throws CommonMarkException
2627
*/
27-
public function renderMarkdown( int $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string
28+
public function renderMarkdown( HttpResponseStatus $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string
2829
{
29-
http_response_code( $ResponseCode );
30+
@http_response_code( $ResponseCode->value );
3031

3132
$View = ( new Markdown() )
3233
->setController( (new \ReflectionClass( static::class ))->getShortName() )
@@ -37,11 +38,11 @@ public function renderMarkdown( int $ResponseCode, array $Data = [], string $Pag
3738
}
3839

3940
/**
40-
* @throws NotFoundException
41+
* @throws \Neuron\Core\Exceptions\NotFound
4142
*/
42-
public function renderHtml( int $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string
43+
public function renderHtml( HttpResponseStatus $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string
4344
{
44-
http_response_code( $ResponseCode );
45+
@http_response_code( $ResponseCode->value );
4546

4647
$View = ( new Html() )
4748
->setController( (new \ReflectionClass( static::class ))->getShortName() )
@@ -51,18 +52,18 @@ public function renderHtml( int $ResponseCode, array $Data = [], string $Page =
5152
return $View->render( $Data );
5253
}
5354

54-
public function renderJson( int $ResponseCode, array $Data = [] ): string
55+
public function renderJson( HttpResponseStatus $ResponseCode, array $Data = [] ): string
5556
{
56-
http_response_code( $ResponseCode );
57+
@http_response_code( $ResponseCode->value );
5758

5859
$View = new Json();
5960

6061
return $View->render( $Data );
6162
}
6263

63-
public function renderXml( int $ResponseCode, array $Data = [] ): string
64+
public function renderXml( HttpResponseStatus $ResponseCode, array $Data = [] ): string
6465
{
65-
http_response_code( $ResponseCode );
66+
@http_response_code( $ResponseCode->value );
6667

6768
$View = new Xml();
6869

src/Mvc/Controllers/Factory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Neuron\Mvc\Controllers;
44

5+
use Neuron\Core\Exceptions\NotFound;
56
use Neuron\Mvc\Application;
67

78
/**
@@ -13,20 +14,20 @@ class Factory
1314
* @param Application $App
1415
* @param string $Class
1516
* @return IController
16-
* @throws NotFoundException
17+
* @throws NotFound
1718
*/
1819
static function create( Application $App, string $Class ) : IController
1920
{
2021
if( !class_exists( $Class ) )
2122
{
22-
throw new NotFoundException( "Controller $Class not found.");
23+
throw new NotFound( "Controller $Class not found.");
2324
}
2425

2526
$Implements = class_implements( $Class );
2627

2728
if( !in_array(IController::class, $Implements ) )
2829
{
29-
throw new NotFoundException( "$Class does not implement IController.");
30+
throw new NotFound( "$Class does not implement IController.");
3031
}
3132

3233
return new $Class( $App->getRouter() );

src/Mvc/Controllers/HttpCodes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Neuron\Mvc\Controllers;
44

5+
use Neuron\Mvc\Responses\HttpResponseStatus;
6+
57
class HttpCodes extends Base
68
{
79
public function code404( array $Parameters ) : string
810
{
911
return $this->renderHtml(
10-
404,
12+
HttpResponseStatus::NOT_FOUND,
1113
array_merge(
1214
$Parameters,
1315
[

src/Mvc/Controllers/IController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace Neuron\Mvc\Controllers;
44

5+
use Neuron\Mvc\Responses\HttpResponseStatus;
56
use Neuron\Routing\Router;
67

78
interface IController
89
{
910
public function __construct( Router $Router );
1011

11-
public function renderHtml( int $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string;
12-
public function renderJson( int $ResponseCode, array $Data = [] ) : string;
13-
public function renderXml( int $ResponseCode, array $Data = [] ) : string;
12+
public function renderHtml( HttpResponseStatus $ResponseCode, array $Data = [], string $Page = "index", string $Layout = "default" ) : string;
13+
public function renderJson( HttpResponseStatus $ResponseCode, array $Data = [] ) : string;
14+
public function renderXml( HttpResponseStatus $ResponseCode, array $Data = [] ) : string;
1415
}

src/Mvc/Controllers/MissingMethodException.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Mvc/Controllers/NotFoundException.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)