Skip to content

Commit b077ce1

Browse files
committed
actualizacion PHP 8
1 parent 943c4fe commit b077ce1

File tree

10 files changed

+42
-23
lines changed

10 files changed

+42
-23
lines changed

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"bin": ["bin/gl"],
2121
"require": {
2222
"twig/twig": "~1.0",
23-
"symfony/yaml": "^3.0",
23+
"symfony/yaml": "~6.1",
2424
"altorouter/altorouter": "2.0.1",
2525
"phpmailer/phpmailer": "~5.2",
2626
"wikimedia/composer-merge-plugin": "v2.0.0",
@@ -37,13 +37,18 @@
3737
"symfony/translation": "*"
3838
},
3939
"require-dev": {
40-
"phpunit/phpunit": "9.5.4"
40+
"phpunit/phpunit": "^9.5"
4141
},
4242
"extra": {
4343
"merge-plugin": {
4444
"include": [
4545
"modules/*/composer.json"
4646
]
4747
}
48+
},
49+
"config": {
50+
"allow-plugins": {
51+
"wikimedia/composer-merge-plugin": true
52+
}
4853
}
4954
}

modules/debugbar/src/Collectors/ControllerCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getVariables()
9292
} else if(is_string($value)) {
9393
$array[$item->name] = $value;
9494
} else {
95-
$array[$item->name] = (string) ($value);
95+
$array[$item->name] = (string) ('object');
9696
}
9797
}
9898
}

src/Bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public function log($message, $level = 1, $nl = true)
550550
/**
551551
* TODO
552552
*/
553-
function fatal_handler($errno, $errstr, $errfile, $errline, $errorContext)
553+
function fatal_handler($errno, $errstr = null, $errfile = null, $errline = null, $errorContext = null)
554554
{
555555

556556
if(!$errno) {
@@ -570,7 +570,7 @@ function fatal_handler($errno, $errstr, $errfile, $errline, $errorContext)
570570
}
571571
}
572572
if ($errno) {
573-
573+
error_log(("$errno $errstr at $errfile:$errline"));
574574
if ($errno === E_ERROR) {
575575
Log::getInstance()->error($errstr . " " . $errfile . " " . $errline);
576576
if (isset($this->config['app']['ignore_errors'])) {
@@ -581,7 +581,7 @@ function fatal_handler($errno, $errstr, $errfile, $errline, $errorContext)
581581

582582
if (isset($this->config['app']['debug']) && $this->config['app']['debug']) {
583583
error_log(("ERROR: $errstr at $errfile:$errfile ($errno)"));
584-
($this->format_error($errno, $errstr, $errfile, $errline));
584+
echo ($this->format_error($errno, $errstr, $errfile, $errline));
585585
}
586586
}
587587
}

src/Log.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
namespace GLFramework;
2828

2929
use Psr\Log\AbstractLogger;
30+
use Stringable;
3031

3132
/**
3233
* Class Log
@@ -71,7 +72,7 @@ public static function getInstance()
7172
* @param $message
7273
* @param array $context
7374
*/
74-
public static function em($message, array $context = array())
75+
public static function em($message, $context = array())
7576
{
7677
// TODO: Change the autogenerated stub
7778
self::getInstance()->emergency($message, $context);
@@ -83,7 +84,7 @@ public static function em($message, array $context = array())
8384
* @param $message
8485
* @param array $context
8586
*/
86-
public static function a($message, array $context = array())
87+
public static function a($message, $context = array())
8788
{
8889
// TODO: Change the autogenerated stub
8990
self::getInstance()->alert($message, $context);
@@ -95,7 +96,7 @@ public static function a($message, array $context = array())
9596
* @param $message
9697
* @param array $context
9798
*/
98-
public static function c($message, array $context = array())
99+
public static function c($message, $context = array())
99100
{
100101
// TODO: Change the autogenerated stub
101102
self::getInstance()->critical($message, $context);
@@ -107,7 +108,7 @@ public static function c($message, array $context = array())
107108
* @param $message
108109
* @param array $context
109110
*/
110-
public static function e($message, array $context = array())
111+
public static function e($message, $context = array())
111112
{
112113
// TODO: Change the autogenerated stub
113114
self::getInstance()->error($message, $context);
@@ -119,7 +120,7 @@ public static function e($message, array $context = array())
119120
* @param $message
120121
* @param array $context
121122
*/
122-
public static function w($message, array $context = array())
123+
public static function w($message, $context = array())
123124
{
124125
// TODO: Change the autogenerated stub
125126
self::getInstance()->warning($message, $context);
@@ -131,7 +132,7 @@ public static function w($message, array $context = array())
131132
* @param $message
132133
* @param array $context
133134
*/
134-
public static function n($message, array $context = array())
135+
public static function n($message, $context = array())
135136
{
136137
// TODO: Change the autogenerated stub
137138
self::getInstance()->notice($message, $context);
@@ -143,7 +144,7 @@ public static function n($message, array $context = array())
143144
* @param $message
144145
* @param array $context
145146
*/
146-
public static function i($message, array $context = array())
147+
public static function i($message, $context = array())
147148
{
148149
// TODO: Change the autogenerated stub
149150
self::getInstance()->info($message, $context);
@@ -155,7 +156,7 @@ public static function i($message, array $context = array())
155156
* @param $message
156157
* @param array $context
157158
*/
158-
public static function d($message, array $context = array())
159+
public static function d($message, $context = array())
159160
{
160161
// TODO: Change the autogenerated stub
161162
self::getInstance()->debug($message, $context);
@@ -169,7 +170,7 @@ public static function d($message, array $context = array())
169170
* @param array $context
170171
* @return null
171172
*/
172-
public function log($level, $message, array $context = array())
173+
public function log($level, Stringable|string $message, array $context = []): void
173174
{
174175
if($this->debugMode)
175176
{

src/Middleware/ControllerMiddleware.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function next(Request $request, Response $response, $next)
6767
// TODO: Implement next() method.
6868

6969
Events::dispatch('beforeControllerRun', array($this->controller));
70-
$data = call_user_func_array(array($this->controller, 'run'), $request->params);
70+
$data = $this->controller->run();
71+
// $data = call_user_func_array(array($this->controller, 'run'), $request->params);
7172
$next($request, $response);
7273
Events::dispatch('afterControllerRun', array($this->controller, $this->controller->response));
7374
Events::dispatch('beforeViewDisplay', array($this->controller));

src/Model.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public function setData($data, $allowEmpty = true, $allowUnset = false)
595595
$fileds = $this->getFields();
596596
foreach ($fileds as $field) {
597597
if (isset($data[$field]) && ($allowEmpty || $data[$field] !== '')) {
598-
if (strpos($this->getFieldType($field), 'varchar') !== false || $this->getFieldType($field) === 'text') {
598+
if ($this->isFieldType($field, 'varchar') || $this->getFieldType($field) === 'text') {
599599
$encoding = mb_detect_encoding($data[$field]);
600600
if ($encoding !== 'utf8') {
601601
$this->{$field} = mb_convert_encoding($data[$field], 'utf8', $encoding);
@@ -623,6 +623,13 @@ public function setData($data, $allowEmpty = true, $allowUnset = false)
623623
return $this;
624624
}
625625

626+
public function isFieldType($field, $type) {
627+
$fieldType = $this->getFieldType($field);
628+
if($fieldType !== null) {
629+
return strpos($fieldType, $type) !== false;
630+
}
631+
return false;
632+
}
626633
/**
627634
* Devuelve la definicion original del modelo
628635
*

src/Yaml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function parse($file)
3939
if($line && substr($line, 0, 1) === '#') return false;
4040
return true;
4141
}));
42-
$res = yaml_parse($data);
42+
$res = \yaml_parse($data);
4343
}
4444
else
4545
{

src/functions.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
*/
3232
function print_debug($info)
3333
{
34-
forward_static_call_array(array('Kint', 'dump'), func_get_args());
34+
dump($info);
35+
// forward_static_call_array(array('Kint', 'dump'), func_get_args());
3536

3637
die();
3738
}
@@ -332,8 +333,11 @@ function instance_method($name, &$cache = array(), $instanceParams = array())
332333
\GLFramework\Log::d('Class ' . $split[0] . ' not found! While try to instance ' . $name);
333334
}
334335
}
335-
$instance = $cache[$split[0]];
336-
return array($instance, $split[1]);
336+
if(isset($cache[$split[0]])) {
337+
$instance = $cache[$split[0]];
338+
return array($instance, $split[1]);
339+
}
340+
return null;
337341
}
338342
if (strpos($name, '::') !== false) {
339343
$split = explode('::', $name);

tests/BootstrapTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function testConfig($bootstrap)
4949
$this->assertArrayNotHasKey('modules', $config);
5050
$this->assertEquals('home', $config['app']['index']);
5151
$this->assertEquals('127.0.0.1', $config['database']['hostname']);
52+
5253
}
5354

5455
/**

tests/data/config.modules.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ modules:
77
test
88

99
database:
10-
database: dummy
10+
database: uned
1111
hostname: 'localhost'
1212
username: 'root'
13-
password: ''
13+
password: 'root'
1414
cache:
1515
connector: GLFramework\Cache\MemoryCache

0 commit comments

Comments
 (0)