You've already forked Php-Template
static test
This commit is contained in:
@@ -40,3 +40,17 @@ Run Code Lint:
|
|||||||
image: siteworxpro/composer
|
image: siteworxpro/composer
|
||||||
script:
|
script:
|
||||||
- composer run tests:lint
|
- composer run tests:lint
|
||||||
|
|
||||||
|
Run Code Sniffer:
|
||||||
|
stage: tests
|
||||||
|
needs:
|
||||||
|
- Install Composer Libraries
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_TAG'
|
||||||
|
when: never
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||||
|
when: on_success
|
||||||
|
- when: never
|
||||||
|
image: siteworxpro/composer
|
||||||
|
script:
|
||||||
|
- composer run tests:phpstan
|
||||||
@@ -21,7 +21,8 @@
|
|||||||
"phpunit/phpunit": "^12.1",
|
"phpunit/phpunit": "^12.1",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
"squizlabs/php_codesniffer": "^3.12",
|
"squizlabs/php_codesniffer": "^3.12",
|
||||||
"lendable/composer-license-checker": "^1.2"
|
"lendable/composer-license-checker": "^1.2",
|
||||||
|
"phpstan/phpstan": "^2.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tests:unit": [
|
"tests:unit": [
|
||||||
@@ -37,6 +38,9 @@
|
|||||||
],
|
],
|
||||||
"tests:license": [
|
"tests:license": [
|
||||||
"composer-license-checker"
|
"composer-license-checker"
|
||||||
|
],
|
||||||
|
"tests:phpstan": [
|
||||||
|
"phpstan analyse --level 4 ./src/ -c phpstan.neon"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repositories": {
|
"repositories": {
|
||||||
|
|||||||
60
composer.lock
generated
60
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "8e6be626529d82f7cdc7631ba7f92165",
|
"content-hash": "597f3c330fcbd311310b6c23e67f82ad",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@@ -2949,6 +2949,64 @@
|
|||||||
},
|
},
|
||||||
"time": "2022-02-21T01:04:05+00:00"
|
"time": "2022-02-21T01:04:05+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "2.1.12",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "96dde49e967c0c22812bcfa7bda4ff82c09f3b0c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/96dde49e967c0c22812bcfa7bda4ff82c09f3b0c",
|
||||||
|
"reference": "96dde49e967c0c22812bcfa7bda4ff82c09f3b0c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4|^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan-shim": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"phpstan",
|
||||||
|
"phpstan.phar"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"docs": "https://phpstan.org/user-guide/getting-started",
|
||||||
|
"forum": "https://github.com/phpstan/phpstan/discussions",
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"security": "https://github.com/phpstan/phpstan/security/policy",
|
||||||
|
"source": "https://github.com/phpstan/phpstan-src"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/ondrejmirtes",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/phpstan",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-04-16T13:19:18+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "12.1.2",
|
"version": "12.1.2",
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ return [
|
|||||||
* The server configuration.
|
* The server configuration.
|
||||||
*/
|
*/
|
||||||
'server' => [
|
'server' => [
|
||||||
'port' => Env::get('HTTP_PORT', 9501),
|
'port' => Env::get('HTTP_PORT', 9501, 'int'),
|
||||||
|
'dev_mode' => Env::get('DEV_MODE', false, 'bool'),
|
||||||
],
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,5 +21,11 @@ return [
|
|||||||
'database' => Env::get('DB_DATABASE', 'siteworxpro'),
|
'database' => Env::get('DB_DATABASE', 'siteworxpro'),
|
||||||
'username' => Env::get('DB_USERNAME', 'siteworxpro'),
|
'username' => Env::get('DB_USERNAME', 'siteworxpro'),
|
||||||
'password' => Env::get('DB_PASSWORD', 'password'),
|
'password' => Env::get('DB_PASSWORD', 'password'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cors' => [
|
||||||
|
'allowed_origins' => Env::get('CORS_ALLOWED_ORIGINS', 'http://localhost:3000'),
|
||||||
|
'allow_credentials' => Env::get('CORS_ALLOW_CREDENTIALS', true, 'bool'),
|
||||||
|
'max_age' => Env::get('CORS_MAX_AGE', 3600, 'int'),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
5
phpstan.neon
Normal file
5
phpstan.neon
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
parameters:
|
||||||
|
tips:
|
||||||
|
treatPhpDocTypesAsCertain: false
|
||||||
|
ignoreErrors:
|
||||||
|
- '#Static call to instance method#'
|
||||||
@@ -15,7 +15,7 @@ use Siteworx\Config\Exception\UnsupportedFormatException;
|
|||||||
* This class serves as a facade for the configuration settings of the application.
|
* This class serves as a facade for the configuration settings of the application.
|
||||||
* It extends the Facade class from the Illuminate\Support\Facades namespace.
|
* It extends the Facade class from the Illuminate\Support\Facades namespace.
|
||||||
*
|
*
|
||||||
* @method static string|int|bool|float get(string $key) Retrieve the configuration value for the given key.
|
* @method static bool | string | int get(string $key) Retrieve the configuration value for the given key.
|
||||||
*
|
*
|
||||||
* @package Siteworx\App\Facades
|
* @package Siteworx\App\Facades
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class JsonResponseFactory
|
|||||||
/**
|
/**
|
||||||
* Create a JSON response with the given data and status code.
|
* Create a JSON response with the given data and status code.
|
||||||
*
|
*
|
||||||
* @param mixed $data The data to include in the response.
|
* @param array $data The data to include in the response.
|
||||||
* @param int $statusCode The HTTP status code for the response.
|
* @param int $statusCode The HTTP status code for the response.
|
||||||
* @return Response The JSON response.
|
* @return Response The JSON response.
|
||||||
* @throws \JsonException
|
* @throws \JsonException
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CorsMiddleware implements MiddlewareInterface
|
|||||||
'trim',
|
'trim',
|
||||||
explode(
|
explode(
|
||||||
',',
|
',',
|
||||||
Config::get('CORS_ALLOWED_ORIGINS', 'https://example.com,https://another.com')
|
Config::get('cors.allowed_origins')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -57,11 +57,11 @@ class CorsMiddleware implements MiddlewareInterface
|
|||||||
?: 'Content-Type, Authorization'
|
?: 'Content-Type, Authorization'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Config::get('CORS_ALLOW_CREDENTIALS', 'bool')) {
|
if (Config::get('cors.allow_credentials') === true) {
|
||||||
$response = $response->withHeader('Access-Control-Allow-Credentials', 'true');
|
$response = $response->withHeader('Access-Control-Allow-Credentials', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
$maxAge = Config::get('CORS_MAX_AGE') ?: '86400';
|
$maxAge = Config::get('CORS_MAX_AGE') !== 3600 ? Config::get('CORS_MAX_AGE') : 3600;
|
||||||
|
|
||||||
return $response->withHeader('Access-Control-Max-Age', $maxAge);
|
return $response->withHeader('Access-Control-Max-Age', $maxAge);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ use Spiral\RoadRunner\Http\PSR7Worker;
|
|||||||
use Spiral\RoadRunner\Worker;
|
use Spiral\RoadRunner\Worker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class Server
|
* Class Server
|
||||||
*
|
*
|
||||||
* This abstract class serves as a base for creating server instances.
|
* This class represents the main server application.
|
||||||
* It initializes the PSR-7 worker and router, and provides an abstract method
|
* It handles incoming HTTP requests, routes them to the appropriate handlers,
|
||||||
* for registering routes. It also includes a method to start the server and handle
|
* and manages the server lifecycle.
|
||||||
* incoming requests.
|
*
|
||||||
|
* @package Siteworxpro\App
|
||||||
*/
|
*/
|
||||||
class Server
|
class Server
|
||||||
{
|
{
|
||||||
@@ -153,7 +154,7 @@ class Server
|
|||||||
Logger::error($e->getTraceAsString());
|
Logger::error($e->getTraceAsString());
|
||||||
|
|
||||||
$json = ['status_code' => 500, 'reason_phrase' => 'Server Error'];
|
$json = ['status_code' => 500, 'reason_phrase' => 'Server Error'];
|
||||||
if (Config::get("DEV_MODE", 'bool')) {
|
if (Config::get("server.dev_mode")) {
|
||||||
$json = [
|
$json = [
|
||||||
'status_code' => 500,
|
'status_code' => 500,
|
||||||
'reason_phrase' => 'Server Error',
|
'reason_phrase' => 'Server Error',
|
||||||
|
|||||||
Reference in New Issue
Block a user