Skip to content

Commit

Permalink
Merge pull request #236 from WebFiori/autoload-enhancement
Browse files Browse the repository at this point in the history
feat: Added Support for Loading Non-PSR-4 Compliant Classes
  • Loading branch information
usernane authored Oct 21, 2024
2 parents 2791223 + ca8e690 commit c456f48
Show file tree
Hide file tree
Showing 33 changed files with 513 additions and 451 deletions.
1 change: 0 additions & 1 deletion app/apis/RoutingTestClass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace app\apis;

use webfiori\http\Response;
Expand Down
14 changes: 7 additions & 7 deletions app/middleware/CoolMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* A middleware which is created using the command "create".
*
* The middleware will have the name 'Super Middleware' and
* The middleware will have the name 'Super Middleware' and
* Priority 100.
* In addition, the middleware is added to the following groups:
* <ul>
Expand All @@ -28,12 +28,6 @@ public function __construct() {
'two-group',
]);
}
/**
* Execute a set of instructions before accessing the application.
*/
public function before(Request $request, Response $response) {
//TODO: Implement the action to perform before processing the request.
}
/**
* Execute a set of instructions after processing the request and before sending back the response.
*/
Expand All @@ -46,4 +40,10 @@ public function after(Request $request, Response $response) {
public function afterSend(Request $request, Response $response) {
//TODO: Implement the action to perform after sending the request.
}
/**
* Execute a set of instructions before accessing the application.
*/
public function before(Request $request, Response $response) {
//TODO: Implement the action to perform before processing the request.
}
}
1 change: 1 addition & 0 deletions app/tasks/Fail1TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function afterExec() {
*/
public function execute() {
TasksManager::logInfo('Task '.$this->getTaskName().' Is executing...');

return false;
}
/**
Expand Down
1 change: 0 additions & 1 deletion php_cs.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ return $config->setRules([
],
'indentation_type' => true,
'method_chaining_indentation' => true,
'statement_indentation' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'blank_line_after_opening_tag' => true,
Expand Down
18 changes: 9 additions & 9 deletions webfiori/framework/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ private static function autoRegisterHelper($options) {
} catch (Error $ex) {
}
}
private static function call($func) {
try {
call_user_func($func);
} catch (Exception $ex) {
if (self::getRunner()->isCLI()) {
printf("WARNING: ".$ex->getMessage().' at '.$ex->getFile().':'.$ex->getLine()."\n");
}
}
}
private function checkAppDir() {
if (!defined('DS')) {
/**
Expand Down Expand Up @@ -577,15 +586,6 @@ private function initMiddleware() {
}
self::call(APP_DIR.'\ini\InitMiddleware::init');
}
private static function call($func) {
try {
call_user_func($func);
} catch (Exception $ex) {
if (self::getRunner()->isCLI()) {
printf("WARNING: ".$ex->getMessage().' at '.$ex->getFile().':'.$ex->getLine()."\n");
}
}
}
/**
* @throws FileException
*/
Expand Down
6 changes: 3 additions & 3 deletions webfiori/framework/ThemeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
*/
namespace webfiori\framework;

use const DS;
use Error;
use Exception;
use const ROOT_PATH;
use const THEMES_PATH;
use webfiori\file\File;
use webfiori\framework\exceptions\InitializationException;
use webfiori\framework\exceptions\NoSuchThemeException;
use webfiori\framework\router\Router;
use webfiori\http\Response;
use const DS;
use const ROOT_PATH;
use const THEMES_PATH;


/**
Expand Down
9 changes: 5 additions & 4 deletions webfiori/framework/autoload/ClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
*
*/
namespace webfiori\framework\autoload;

/**
* A class that contains the names of indices that are used by loaded class info array.
*
*/
class ClassInfo {
/**
* A constant that represents the value 'cached' of class.
*/
const CACHED = 'loaded-from-cache';
/**
* A constant that represents the value 'name' of class.
*/
Expand All @@ -26,8 +31,4 @@ class ClassInfo {
* A constant that represents the value 'path' of class.
*/
const PATH = 'path';
/**
* A constant that represents the value 'cached' of class.
*/
const CACHED = 'loaded-from-cache';
}
Loading

0 comments on commit c456f48

Please sign in to comment.