Fix framework with phpstan
This commit is contained in:
parent
ee121f225b
commit
68cd097dec
|
@ -37,22 +37,28 @@
|
|||
---------------------------------------------------------*/ {
|
||||
|
||||
/* (1) Vérification existence fichier config */
|
||||
if( !file_exists($path) )
|
||||
return $this->error->set(Err::UnreachableResource);
|
||||
if( !file_exists($path) ) {
|
||||
$this->error->set(Err::UnreachableResource);
|
||||
return;
|
||||
}
|
||||
|
||||
/* (2) Lecture fichier config */
|
||||
$conf = @file_get_contents($path);
|
||||
|
||||
/* (3) Si erreur lecture */
|
||||
if( $conf === false )
|
||||
return $this->error->set(Err::UnreachableResource);
|
||||
if( $conf === false ) {
|
||||
$this->error->set(Err::UnreachableResource);
|
||||
return;
|
||||
}
|
||||
|
||||
/* (4) Parsage json */
|
||||
$this->raw = json_decode( $conf, true );
|
||||
|
||||
/* (5) Gestion de l'erreur de parsage */
|
||||
if( $this->raw == null )
|
||||
return $this->error->set(Err::ParsingFailed, 'json');
|
||||
if( $this->raw == null ) {
|
||||
$this->error->set(Err::ParsingFailed, 'json');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,7 +68,7 @@
|
|||
|
||||
/* (1) Initialisation */
|
||||
$this->index = [];
|
||||
$ref = [ '/' => array_merge($this->raw) ];
|
||||
$ref = [ '/' => $this->raw ];
|
||||
|
||||
|
||||
/* (2) Tant qu'il reste des @ref à traiter */
|
||||
|
@ -115,7 +121,7 @@
|
|||
* @return inst<Config> Configuration singleton
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function get(){
|
||||
public static function get() : Config{
|
||||
|
||||
/* (1) If @inst already exists -> return singleton */
|
||||
if( self::$inst instanceof Config )
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
/* (2) Builds the documentation
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public function generate(Request $rq=null){
|
||||
public static function generate(Request $rq=null){
|
||||
|
||||
if(is_null($rq)){
|
||||
return new Response(new Error(Err::NullRequest));
|
||||
}
|
||||
|
||||
/* (1) Get data from config
|
||||
---------------------------------------------------------*/
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
---------------------------------------------------------*/
|
||||
public function __construct($uri=null, $params=null, $forced_method=null){
|
||||
|
||||
return $this->buildRequestObject($uri, $params, $forced_method);
|
||||
$this->buildRequestObject($uri, $params, $forced_method);
|
||||
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@
|
|||
---------------------------------------------------------*/
|
||||
/* (1) S'il s'agit d'un téléchargement -> on dispatch */
|
||||
if( $this->options['download'] === true )
|
||||
return $this->download();
|
||||
return $this->download($returned);
|
||||
|
||||
/* (2) On construit la réponse avec l'erreur */
|
||||
$response = new Response($this->error);
|
||||
|
@ -506,7 +506,7 @@
|
|||
/* (8) Gestion d'un téléchargement HTTP
|
||||
*
|
||||
*/
|
||||
public function download(){
|
||||
public function download($returned){
|
||||
|
||||
/* (1) Vérification des erreurs et paramètres
|
||||
---------------------------------------------------------*/
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function get($args){
|
||||
$id_admin = 0;
|
||||
extract($args);
|
||||
|
||||
/* (1) If @id_admin is set -> get by id
|
||||
|
@ -54,6 +55,9 @@
|
|||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function post($args){
|
||||
$username = "";
|
||||
$mail = "";
|
||||
$password = "";
|
||||
extract($args);
|
||||
|
||||
/* (1) Création admin */
|
||||
|
@ -80,6 +84,10 @@
|
|||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function put($args){
|
||||
//helps the static analysis
|
||||
$mail = null;
|
||||
$password = null;
|
||||
$id_admin = 0;
|
||||
extract($args);
|
||||
|
||||
/* (1) If @mail given
|
||||
|
@ -123,6 +131,7 @@
|
|||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function delete($args){
|
||||
$id_admin = 0;
|
||||
extract($args);
|
||||
|
||||
/* (1) Dispatch du status */
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*
|
||||
*/
|
||||
public function get($args){
|
||||
$project = "";
|
||||
$step = null;
|
||||
extract($args);
|
||||
|
||||
/* (1) Load projects' configuration
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
// On signale que tout s'est bien passe
|
||||
$this->error = new Error(Err::Success);
|
||||
|
||||
}catch(Exception $e){
|
||||
}catch(\Exception $e){
|
||||
// On signale qu'il y a une erreur
|
||||
$this->error = new Error(Err::PDOConnection);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@
|
|||
is_null($label) && ($label = 'default');
|
||||
|
||||
/* (2) If no label, or unknown label */
|
||||
if( is_null($label) || !isset(self::$instance[$label]) ){
|
||||
if( !isset(self::$instance[$label]) ){
|
||||
|
||||
/* (2.1) Try to add the configuration if exists */
|
||||
if( isset($conf[$label]) ){
|
||||
|
|
|
@ -63,6 +63,17 @@
|
|||
const WrongParam = 17;
|
||||
/* (12) Erreur dans le traitement */
|
||||
const ModuleError = 18;
|
||||
/* (13) Erreur de format d'URI */
|
||||
const InvalidURI = 30;
|
||||
/* (14) Erreur de paramètre par défaut */
|
||||
const WrongDefaultParam = 31;
|
||||
/* (15) Erreur lorsque un download n'a pas de body */
|
||||
const MissingBody = 32;
|
||||
/* (16) Erreur lorsqu'un download n'a pas de headers */
|
||||
const MissingHeaders = 33;
|
||||
/* (17) Erreur lorsque la requete est null lors de la génération de documentation */
|
||||
const NullRequest = 34;
|
||||
|
||||
|
||||
|
||||
/* [5] Database
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
*
|
||||
*/
|
||||
public function __construct($const){
|
||||
//make the static analisis happy
|
||||
$tmp = $const;
|
||||
call_user_func_array([$this, 'set'], func_get_args());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
private $pagename;
|
||||
private $uri;
|
||||
|
||||
/* PRE-CALL
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
class redirect{
|
||||
|
||||
private $url;
|
||||
|
||||
/* PRE-CALL
|
||||
*
|
||||
|
@ -12,6 +13,7 @@
|
|||
*
|
||||
*/
|
||||
public function __construct($url){
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
* https://xdrm.io/ *
|
||||
**************************/
|
||||
|
||||
use router\core\ControllerFactory;
|
||||
|
||||
namespace router\core;
|
||||
|
||||
class Route{
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
* https://xdrm.io/ *
|
||||
**************************/
|
||||
|
||||
use \router\core\ControllerFactory;
|
||||
|
||||
namespace router\core;
|
||||
|
||||
class Router{
|
||||
|
|
Loading…
Reference in New Issue