Skip to content

Commit cf9b625

Browse files
committed
Revisión dummy de estilo y formato de código en directorio 'core'.
1 parent d534ca7 commit cf9b625

File tree

125 files changed

+1572
-2482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1572
-2482
lines changed

Doxyfile

Lines changed: 0 additions & 1792 deletions
This file was deleted.

config/layers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SowerPHP: Simple and Open Web Ecosystem Reimagined for PHP.
57
* Copyright (C) SowerPHP <https://www.sowerphp.org>

src/app/Module/Sistema/Module/Usuarios/Controller/Usuarios.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@
3535
*/
3636
class Controller_Usuarios extends \sowerphp\autoload\Controller_Model
3737
{
38-
39-
protected $columnsView = [
40-
'listar' => [
41-
'id',
42-
'nombre',
43-
'usuario',
44-
'email',
45-
'activo',
46-
'ultimo_ingreso_fecha_hora',
47-
],
48-
]; ///< Columnas que se deben mostrar en las vistas
4938
protected $deleteRecord = false; ///< Indica si se permite o no borrar registros
5039
protected $changeUsername = true; ///< Indica si se permite que se cambie el nombre de usuario
5140

src/app/Module/Sistema/Module/Usuarios/Model/Usuario.php

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*/
3535
class Model_Usuario extends Model implements Authenticatable
3636
{
37-
3837
/**
3938
* Metadatos del modelo.
4039
*
@@ -197,9 +196,19 @@ class Model_Usuario extends Model implements Authenticatable
197196
],
198197
];
199198

200-
// atributos para caché
201-
protected $groups = null; ///< Grupos a los que pertenece el usuario
202-
protected $auths = null; ///< Permisos que tiene el usuario
199+
/**
200+
* Grupos a los que pertenece el usuario.
201+
*
202+
* @var array
203+
*/
204+
protected $groups = null;
205+
206+
/**
207+
* Permisos que tiene el usuario.
208+
*
209+
* @var array
210+
*/
211+
protected $auths = null;
203212

204213
/**
205214
* Obtiene el usuario solicitado.
@@ -210,9 +219,11 @@ class Model_Usuario extends Model implements Authenticatable
210219
protected function retrieve(array $id, array $options = []): ?stdClass
211220
{
212221
$realId = $this->getPluralInstance()->getIdFromCredentials($id);
222+
213223
if ($realId === null) {
214224
return null;
215225
}
226+
216227
return parent::retrieve(['id' => $realId]);
217228
}
218229

@@ -242,7 +253,7 @@ protected function retrieve(array $id, array $options = []): ?stdClass
242253

243254
/**
244255
* Método que revisa si el nombre de usuario ya existe en la base de datos.
245-
* @return bool =true si el nombre de usuario ya existe.
256+
* @return bool `true` si el nombre de usuario ya existe.
246257
*/
247258
public function checkIfUserAlreadyExists(): bool
248259
{
@@ -269,7 +280,7 @@ public function checkIfUserAlreadyExists(): bool
269280
/**
270281
* Método que revisa si el email ya existe en la base de datos.
271282
*
272-
* @return bool =true si el correo ya existe.
283+
* @return bool `true` si el correo ya existe.
273284
*/
274285
public function checkIfEmailAlreadyExists(): bool
275286
{
@@ -295,7 +306,7 @@ public function checkIfEmailAlreadyExists(): bool
295306

296307
/**
297308
* Método que revisa si el hash del usuario ya existe en la base de datos.
298-
* @return bool =true si el hash ya existe.
309+
* @return bool `true` si el hash ya existe.
299310
*/
300311
public function checkIfHashAlreadyExists(): bool
301312
{
@@ -324,7 +335,7 @@ public function checkIfHashAlreadyExists(): bool
324335
*
325336
* @param string $new Contraseña nueva en texto plano.
326337
* @param string|null $old Contraseña actual en texto plano.
327-
* @return bool =true si la contraseña pudo ser cambiada.
338+
* @return bool `true` si la contraseña pudo ser cambiada.
328339
*/
329340
public function savePassword(string $new, string $old = null): bool
330341
{
@@ -335,7 +346,7 @@ public function savePassword(string $new, string $old = null): bool
335346
* Método que cambia la contraseña del usuario en la base de datos.
336347
*
337348
* @param string $new Contraseña nueva en texto plano.
338-
* @return bool =true si la contraseña pudo ser cambiada.
349+
* @return bool `true` si la contraseña pudo ser cambiada.
339350
*/
340351
private function savePasswordLocal(string $new): bool
341352
{
@@ -368,7 +379,7 @@ public function hashPassword(string $password): string
368379
* del usuario almacenada en la base de datos.
369380
*
370381
* @param string $password Contrasela que se desea verificar.
371-
* @return bool =true si la contraseña coincide con la de la base de datos.
382+
* @return bool `true` si la contraseña coincide con la de la base de datos.
372383
*/
373384
public function checkPassword(string $password): bool
374385
{
@@ -385,7 +396,7 @@ public function checkPassword(string $password): bool
385396
/**
386397
* Método que indica si el usuario está o no activo.
387398
*
388-
* @return bool =true si el usuario está activo.
399+
* @return bool `true` si el usuario está activo.
389400
*/
390401
public function isActive(): bool
391402
{
@@ -495,7 +506,7 @@ public function inGroup($grupos = []): int
495506
* que están en la consulta.
496507
*
497508
* @param array $grupos Arreglo con los grupos que se desean revisar.
498-
* @return bool =true si pertenece a todos los grupos que se solicitaron.
509+
* @return bool `true` si pertenece a todos los grupos que se solicitaron.
499510
*/
500511
public function inAllGroups(array $grupos = []): bool
501512
{
@@ -625,7 +636,7 @@ public function setAuths(array $auths = []): void
625636
* Método que verifica si el usuario tiene permiso para acceder a cierto
626637
* recurso.
627638
*
628-
* @return bool =true si tiene permiso.
639+
* @return bool `true` si tiene permiso.
629640
*/
630641
public function auth($recurso): bool
631642
{
@@ -709,7 +720,7 @@ public function getAuth2()
709720
* Método que crea el token para el usuario.
710721
*
711722
* @param array $data Datos que se usarán para crear el token.
712-
* @return bool =true si el token pudo ser creado.
723+
* @return bool `true` si el token pudo ser creado.
713724
*/
714725
public function createAuth2(array $data = []): bool
715726
{
@@ -722,7 +733,7 @@ public function createAuth2(array $data = []): bool
722733
/**
723734
* Método que destruye el token en la autorización secundaria.
724735
*
725-
* @return bool =true si el token pudo ser destruído.
736+
* @return bool `true` si el token pudo ser destruído.
726737
*/
727738
public function destroyAuth2(array $data = []): bool
728739
{
@@ -736,7 +747,7 @@ public function destroyAuth2(array $data = []): bool
736747
* Método que valida el estado de todas las autorizaciones secundarias
737748
* que el usuario pudiese tener habilitadas.
738749
*
739-
* @return bool =true si todo está ok o Exception con el error si falla.
750+
* @return bool `true` si todo está ok o Exception con el error si falla.
740751
*/
741752
public function checkAuth2($token): bool
742753
{

src/core/Adapter/CacheItemPool.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SowerPHP: Simple and Open Web Ecosystem Reimagined for PHP.
57
* Copyright (C) SowerPHP <https://www.sowerphp.org>
@@ -33,7 +35,6 @@
3335
*/
3436
class Adapter_CacheItemPool implements CacheItemPoolInterface
3537
{
36-
3738
/**
3839
* El repositorio de caché de Illuminate.
3940
*
@@ -60,6 +61,7 @@ public function __construct(CacheRepository $cache)
6061
public function getItem($key): CacheItemInterface
6162
{
6263
$value = $this->cache->get($key);
64+
6365
return new CacheItem($key, $value, $value !== null);
6466
}
6567

@@ -75,6 +77,7 @@ public function getItems(array $keys = array()): iterable
7577
foreach ($keys as $key) {
7678
$items[$key] = $this->getItem($key);
7779
}
80+
7881
return $items;
7982
}
8083

@@ -124,6 +127,7 @@ public function deleteItems(array $keys): bool
124127
foreach ($keys as $key) {
125128
$this->deleteItem($key);
126129
}
130+
127131
return true;
128132
}
129133

@@ -140,6 +144,7 @@ public function save(CacheItemInterface $item): bool
140144
? $item->getExpiresAt()->getTimestamp() - time()
141145
: null
142146
;
147+
143148
return $this->cache->put($item->getKey(), $item->get(), $expiration);
144149
}
145150

@@ -167,15 +172,13 @@ public function commit(): bool
167172
// Implementación de commit si es necesario.
168173
return true;
169174
}
170-
171175
}
172176

173177
/**
174178
* Representa un ítem de la caché.
175179
*/
176180
class CacheItem implements CacheItemInterface
177181
{
178-
179182
/**
180183
* La clave del ítem de la caché.
181184
*
@@ -303,5 +306,4 @@ public function getExpiresAt()
303306
{
304307
return $this->expiresAt;
305308
}
306-
307309
}

src/core/App.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
namespace sowerphp\core;
2525

2626
use Illuminate\Container\Container;
27-
use stdClass;
2827

2928
/**
3029
* Clase principal de la aplicación.
@@ -36,7 +35,6 @@
3635
*/
3736
class App
3837
{
39-
4038
/**
4139
* Instancia única de la clase App.
4240
*
@@ -86,8 +84,8 @@ class App
8684
];
8785

8886
/**
89-
* Servicios cuando la aplicación se ejecuta en modo HTTP que son
90-
* cargados por defecto.
87+
* Servicios cuando la aplicación se ejecuta en modo HTTP que son cargados
88+
* por defecto.
9189
*
9290
* @var array
9391
*/
@@ -147,6 +145,7 @@ public static function getInstance(?string $type = null, bool $fullBoot = true):
147145
return null;
148146
}
149147
}
148+
150149
return self::$instance;
151150
}
152151

@@ -162,6 +161,7 @@ protected function setType(?string $type = null): string
162161
} else {
163162
$this->type = php_sapi_name() === 'cli' ? 'console' : 'http';
164163
}
164+
165165
return $this->type;
166166
}
167167

@@ -188,6 +188,7 @@ public function run(): int
188188
} catch (\Throwable $throwable) {
189189
$result = $kernel->handleThrowable($throwable);
190190
}
191+
191192
return $result;
192193
}
193194

@@ -225,6 +226,7 @@ public function getService(string $key, array $parameters = [])
225226
$key
226227
));
227228
}
229+
228230
return $this->container->make($key, $parameters);
229231
}
230232

@@ -249,6 +251,7 @@ protected function handleThrowable(\Throwable $throwable): int
249251
$file = $throwable->getFile();
250252
$line = $throwable->getLine();
251253
$trace = $throwable->getTraceAsString();
254+
252255
// Armar mensaje con el detalle del error o excepción.
253256
$error = sprintf(
254257
'Se capturó %s (%s de nivel %s):' . "\n\n"
@@ -258,6 +261,7 @@ protected function handleThrowable(\Throwable $throwable): int
258261
. '%s'
259262
, $class, $type, $severity, $message, $file, $line, $trace
260263
);
264+
261265
// Generar mensaje con el error o excepción.
262266
header('Content-Type: text/plain; charset=UTF-8');
263267
echo $error;
@@ -479,6 +483,7 @@ public function registerService($key, $service): void
479483
$this->container->instance(get_class($service), $service);
480484
}
481485
}
486+
482487
// Si $service es una clase, usar singleton para registrar.
483488
else if (is_string($service)) {
484489
// Verificar que la clase del servicio exista.
@@ -489,12 +494,14 @@ public function registerService($key, $service): void
489494
$key
490495
));
491496
}
497+
492498
// Registrar.
493499
$this->container->singleton($key, $service);
494500
if ($service != $key) {
495501
$this->container->singleton($service, $service);
496502
}
497503
}
504+
498505
// Si $service es otra cosa, lanzar una excepción.
499506
else {
500507
throw new \InvalidArgumentException(sprintf(
@@ -534,8 +541,8 @@ public function getStats(): array
534541
'cache' => cache()->getStats(),
535542
];
536543
}
544+
537545
// Entregar estadísticas.
538546
return $this->stats;
539547
}
540-
541548
}

0 commit comments

Comments
 (0)