Skip to content

Commit 033b86f

Browse files
committed
Update
PHP ^8.2 | PSR
1 parent faa00c5 commit 033b86f

File tree

8 files changed

+68
-72
lines changed

8 files changed

+68
-72
lines changed

bin/floatphp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : CLI Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -15,8 +15,8 @@ declare(strict_types=1);
1515

1616
namespace App;
1717

18-
if (php_sapi_name() !== 'cli') exit();
18+
if ( php_sapi_name() !== 'cli' ) exit();
1919

20-
require( __DIR__ . '/App/App.php');
20+
require __DIR__ . '/App/App.php';
2121
new App();
2222
new \FloatPHP\Cli\App();

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "floatphp/cli",
3-
"version" : "1.2.0",
3+
"version" : "1.3.0",
44
"type": "library",
55
"description": "FloatPHP CLI Components",
66
"keywords": ["floatphp","micro-framework","framework","PSR","ORM","jakiboy"],
@@ -15,10 +15,8 @@
1515
],
1616
"require": {
1717
"php": ">=8.2",
18-
"floatphp/classes": "^1.2.0",
19-
"floatphp/helpers": "^1.2.0",
20-
"floatphp/interfaces": "^1.2.0",
21-
"floatphp/exceptions": "^1.2.0"
18+
"floatphp/classes": "^1.3.0",
19+
"floatphp/helpers": "^1.3.0"
2220
},
2321
"autoload": {
2422
"psr-4" : {

src/App.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : CLI Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -24,10 +24,10 @@ public function __construct()
2424
{
2525
global $argv;
2626
$console = new Console();
27-
$console->registerCommand('help', function($argv) use($console) {
27+
$console->registerCommand('help', function ($argv) use ($console) {
2828
$console->help();
2929
});
30-
$console->registerCommand('add-page', function($argv) use($console) {
30+
$console->registerCommand('add-page', function ($argv) use ($console) {
3131
$console->addPage($argv);
3232
});
3333
$console->run($argv);

src/BuiltIn.php

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : CLI Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -15,17 +15,15 @@
1515

1616
namespace FloatPHP\Cli;
1717

18-
use FloatPHP\Classes\Filesystem\{
19-
File, Stringify
20-
};
18+
use FloatPHP\Classes\Filesystem\{File, Stringify};
2119

2220
class BuiltIn
2321
{
2422
/**
2523
* @access public
2624
* @return string
2725
*/
28-
public function help()
26+
public function help() : never
2927
{
3028
$this->getOutput()->display('add-page [name] [route] [action] [params] [parent] [method]');
3129
$this->getOutput()->display('add-model [name]');
@@ -38,7 +36,7 @@ public function help()
3836
* @param array $args
3937
* @return string
4038
*/
41-
public function addPage($args)
39+
public function addPage($args) : void
4240
{
4341
// Parse name parameter
4442
if ( !($name = $this->parseVars($args)) ) {
@@ -73,7 +71,7 @@ public function addPage($args)
7371
// Parse method parameter
7472
$method = $this->parseVars($args, 7) ? $this->parseVars($args, 7) : 'GET';
7573
$method = Stringify::uppercase($method);
76-
$methods = ['GET','HEAD','POST','PUT','DELETE','CONNECT','OPTIONS','TRACE','PATCH'];
74+
$methods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'];
7775
if ( !in_array($method, $methods) && !Stringify::contains($method, '|') ) {
7876
$this->getOutput()->display("FloatPHP : Command 'add-page' require valid 'method' parameter");
7977
$this->getOutput()->display("Use : (GET, POST, PATCH, DELETE, GET|POST)");
@@ -82,10 +80,10 @@ public function addPage($args)
8280

8381
$vars = [
8482
'name' => $name,
85-
'route' => $route,
83+
'route' => $route,
8684
'action' => $action,
8785
'params' => $params,
88-
'parent' => $parent,
86+
'parent' => $parent,
8987
'method' => $method
9088
];
9189

@@ -100,7 +98,7 @@ public function addPage($args)
10098
* @param array $args
10199
* @return string
102100
*/
103-
public function addModel($args)
101+
public function addModel($args) : void
104102
{
105103
// Parse name parameter
106104
if ( !($name = $this->parseVars($args)) ) {
@@ -117,17 +115,17 @@ public function addModel($args)
117115
* @param array $args
118116
* @return void
119117
*/
120-
private function generateController($args)
118+
private function generateController($args) : void
121119
{
122-
$content = File::r(dirname(__FILE__).'/bin/controller');
120+
$content = File::r(dirname(__FILE__) . '/bin/controller');
123121
$content = Stringify::replaceArray([
124-
'{slug}' => $args['slug'],
125-
'{name}' => $args['name'],
126-
'{routeName}' => $args['routeName'],
127-
'{route}' => $args['route'],
128-
'{method}' => $args['method'],
129-
'{action}' => $args['action'],
130-
'{parent}' => $args['parent'],
122+
'{slug}' => $args['slug'],
123+
'{name}' => $args['name'],
124+
'{routeName}' => $args['routeName'],
125+
'{route}' => $args['route'],
126+
'{method}' => $args['method'],
127+
'{action}' => $args['action'],
128+
'{parent}' => $args['parent'],
131129
'{params}' => $args['params']
132130
], $content);
133131

@@ -139,7 +137,7 @@ private function generateController($args)
139137
* @param array $args
140138
* @return void
141139
*/
142-
private function generateRoute($args)
140+
private function generateRoute($args) : void
143141
{
144142
$this->addRoute([
145143
'method' => $args['method'],
@@ -157,26 +155,26 @@ private function generateRoute($args)
157155
private function generateModel($name)
158156
{
159157
$file = "{$this->getAppRoot()}/{$this->getViewPath()}{$name}{$this->getViewExtension()}";
160-
File::w($file,"{$name} template");
158+
File::w($file, "{$name} template");
161159
}
162160

163161
/**
164162
* @access private
165163
* @param array $args
166164
* @return void
167165
*/
168-
private function generateView($name)
166+
private function generateView($name) : void
169167
{
170168
$file = "{$this->getAppRoot()}/{$this->getViewPath()}{$name}{$this->getViewExtension()}";
171-
File::w($file,"{$name} template");
169+
File::w($file, "{$name} template");
172170
}
173171

174172
/**
175173
* @access private
176174
* @param array $args
177175
* @return array
178176
*/
179-
private function buildVars($args)
177+
private function buildVars($args) : array
180178
{
181179
$args['slug'] = Stringify::lowercase(Stringify::numberStrip($args['name']));
182180
$args['name'] = Stringify::capitalize($args['slug']);
@@ -186,7 +184,7 @@ private function buildVars($args)
186184
$args['action'] = Stringify::lowercase($args['action']);
187185
$args['parent'] = Stringify::capitalize($args['parent']);
188186
$args['method'] = Stringify::uppercase($args['method']);
189-
if ($args['params']) {
187+
if ( $args['params'] ) {
190188
$args['params'] = '$' . $args['params'];
191189
$args['params'] = Stringify::replace(',', ',$', $args['params']);
192190
}
@@ -199,7 +197,7 @@ private function buildVars($args)
199197
* @param int $pos
200198
* @return mixed
201199
*/
202-
private function parseVars($args, $pos = 2)
200+
private function parseVars($args, $pos = 2) : mixed
203201
{
204202
return $args[$pos] ?? false;
205203
}

src/Console.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : CLI Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -22,60 +22,60 @@ class Console extends BuiltIn
2222
* @var object $output
2323
* @var array $registry
2424
*/
25-
protected $output;
26-
protected $registry = [];
25+
protected $output;
26+
protected $registry = [];
2727

2828
/**
2929
* @return void
3030
*/
31-
public function __construct()
32-
{
33-
$this->output = new Output();
34-
}
31+
public function __construct()
32+
{
33+
$this->output = new Output();
34+
}
3535

3636
/**
3737
* @access public
3838
* @return object
3939
*/
40-
public function getOutput()
41-
{
42-
return $this->output;
43-
}
40+
public function getOutput() : object
41+
{
42+
return $this->output;
43+
}
4444

4545
/**
4646
* @access public
4747
* @param string $command
4848
* @param callable $callable
4949
* @return void
5050
*/
51-
public function registerCommand($command, $callable)
52-
{
53-
$this->registry[$command] = $callable;
54-
}
51+
public function registerCommand($command, $callable) : void
52+
{
53+
$this->registry[$command] = $callable;
54+
}
5555

5656
/**
5757
* @access public
5858
* @param string $command
5959
* @return mixed
6060
*/
61-
public function getCommand($command)
62-
{
63-
return $this->registry[$command] ?? null;
64-
}
61+
public function getCommand($command) : mixed
62+
{
63+
return $this->registry[$command] ?? null;
64+
}
6565

6666
/**
6767
* @access public
6868
* @param array $argv
6969
* @return void
7070
*/
71-
public function run($argv = [])
72-
{
73-
$name = isset($argv[1]) ? $argv[1] : false;
74-
if ( ($command = $this->getCommand($name)) ) {
75-
call_user_func($command, $argv);
76-
77-
} else {
78-
$this->getOutput()->display("FloatPHP : Command '{$name}' not found.");
79-
}
80-
}
71+
public function run($argv = []) : void
72+
{
73+
$name = isset($argv[1]) ? $argv[1] : false;
74+
if ( ($command = $this->getCommand($name)) ) {
75+
call_user_func($command, $argv);
76+
77+
} else {
78+
$this->getOutput()->display("FloatPHP : Command '{$name}' not found.");
79+
}
80+
}
8181
}

src/Output.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : CLI Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -22,7 +22,7 @@ class Output
2222
* @param string $message
2323
* @return string
2424
*/
25-
public function out($message)
25+
public function out($message) : void
2626
{
2727
echo $message;
2828
}
@@ -31,7 +31,7 @@ public function out($message)
3131
* @access public
3232
* @return string
3333
*/
34-
public function newline()
34+
public function newline() : void
3535
{
3636
$this->out("\n");
3737
}
@@ -41,7 +41,7 @@ public function newline()
4141
* @param string $message
4242
* @return void
4343
*/
44-
public function display($message)
44+
public function display($message) : void
4545
{
4646
$this->out($message);
4747
$this->newline();

src/bin/controller

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Skeleton Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/bin/model

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Skeleton Component
6-
* @version : 1.2.x
6+
* @version : 1.3.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

0 commit comments

Comments
 (0)