From 037900720b5935fb729f5249c8a0b5e34e2504e2 Mon Sep 17 00:00:00 2001 From: Claudecio Martins Date: Wed, 22 Oct 2025 16:03:18 +0200 Subject: [PATCH] =?UTF-8?q?feat(funcionario):=20adicionar=20m=C3=B3dulo=20?= =?UTF-8?q?de=20gerenciamento=20de=20funcion=C3=A1rios=20com=20rotas=20e?= =?UTF-8?q?=20controle=20de=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Module/Funcionario/bootstrap.php | 73 +++++++++++++++++++ app/Module/Funcionario/manifest.json | 16 ++++ .../v0/Controllers/FuncionarioController.php | 16 ++++ .../v0/Routes/FuncionarioRoutes.php | 33 +++++++++ app/Module/Funcionario/v0/Routes/Routes.php | 2 + composer.json | 4 +- composer.lock | 12 +-- public/index.php | 15 ++++ vendor/composer/autoload_psr4.php | 4 +- vendor/composer/autoload_static.php | 16 ++-- vendor/composer/installed.json | 14 ++-- vendor/composer/installed.php | 18 ++--- .../lib/PhpParser/Node/Expr/ArrayItem.php | 6 +- .../lib/PhpParser/Node/Expr/ClosureUse.php | 6 +- .../php-parser/lib/PhpParser/Node/Param.php | 4 + .../lib/PhpParser/Node/Scalar/DNumber.php | 6 +- .../lib/PhpParser/Node/Scalar/Encapsed.php | 6 +- .../Node/Scalar/EncapsedStringPart.php | 6 +- .../lib/PhpParser/Node/Scalar/LNumber.php | 6 +- .../lib/PhpParser/Node/Scalar/String_.php | 2 +- .../PhpParser/Node/Stmt/DeclareDeclare.php | 6 +- .../PhpParser/Node/Stmt/PropertyProperty.php | 6 +- .../lib/PhpParser/Node/Stmt/StaticVar.php | 6 +- .../lib/PhpParser/Node/Stmt/UseUse.php | 6 +- .../lib/PhpParser/PrettyPrinterAbstract.php | 4 +- 25 files changed, 247 insertions(+), 46 deletions(-) create mode 100644 app/Module/Funcionario/bootstrap.php create mode 100644 app/Module/Funcionario/manifest.json create mode 100644 app/Module/Funcionario/v0/Controllers/FuncionarioController.php create mode 100644 app/Module/Funcionario/v0/Routes/FuncionarioRoutes.php create mode 100644 app/Module/Funcionario/v0/Routes/Routes.php diff --git a/app/Module/Funcionario/bootstrap.php b/app/Module/Funcionario/bootstrap.php new file mode 100644 index 0000000..dff4b33 --- /dev/null +++ b/app/Module/Funcionario/bootstrap.php @@ -0,0 +1,73 @@ +format(format: 'Y-m-d'); + $newApis = []; + $updated = false; + + // Checa se tem versão esperando que começa hoje + foreach ($manifest['apis'] as $api) { + if ($api['status'] === 'planned' && $api['start_date'] === $now) { + // Promote a nova + $api['status'] = 'active'; + $newApis[] = $api; + $updated = true; + } elseif ($api['status'] === 'active' && $api['start_date'] !== $now) { + // Ignora versão antiga ativa + continue; + } else { + $newApis[] = $api; + } + } + + // Atualiza manifest se tiver mudança + if ($updated) { + $manifest['apis'] = $newApis; + file_put_contents(filename: $manifestPath, data: json_encode(value: $manifest, flags: JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + } + + // Carrega a versão ativa + $loaded = false; + foreach ($manifest['apis'] as $api) { + $startDate = new DateTime(datetime: $api['start_date']); + if ($api['status'] === 'active' && $startDate <= new DateTime()) { + $routeFile = MODULE_PATH . "/{$manifest['dirName']}/{$api['version']}/Routes/Routes.php"; + if (file_exists(filename: $routeFile)) { + Router::group( + prefix: "/{$manifest['slug']}", + callback: function() use ($routeFile) { + require_once realpath(path: $routeFile); + }, + middlewares: [] + ); + $loaded = true; + break; + } else { + throw new Exception(message: "Arquivo de rotas não encontrado para a versão '{$api['version']}'."); + } + } + } + + // Verifica se carregou + if (!$loaded) { + throw new Exception(message: "Nenhuma versão ativa da API foi carregada."); + } \ No newline at end of file diff --git a/app/Module/Funcionario/manifest.json b/app/Module/Funcionario/manifest.json new file mode 100644 index 0000000..0351157 --- /dev/null +++ b/app/Module/Funcionario/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "Funcionários", + "dirName": "Funcionario", + "slug": "funcionario", + "description": "Gerencia dados e operações relacionadas aos funcionários.", + "uuid": "019a0bfa-fc2f-7955-94d3-5f5273f07b3b", + "version": "1.0", + "dependencies": [], + "apis": [ + { + "version": "v0", + "status": "active", + "start_date": "2025-10-22" + } + ] +} \ No newline at end of file diff --git a/app/Module/Funcionario/v0/Controllers/FuncionarioController.php b/app/Module/Funcionario/v0/Controllers/FuncionarioController.php new file mode 100644 index 0000000..d0e5dc7 --- /dev/null +++ b/app/Module/Funcionario/v0/Controllers/FuncionarioController.php @@ -0,0 +1,16 @@ + array($baseDir . '/app/Module'), + 'Workbloom\\Component\\' => array($baseDir . '/app/Common/Component'), 'Workbloom\\' => array($baseDir . '/app/Common'), - 'WorkbloomModule\\' => array($baseDir . '/app/Module'), - 'WorkbloomComponent\\' => array($baseDir . '/app/Common/Component'), 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 21c3508..b2d9010 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -19,9 +19,9 @@ class ComposerStaticInit8166d455774ce82597f7c8b1884b0ce8 public static $prefixLengthsPsr4 = array ( 'W' => array ( + 'Workbloom\\Module\\' => 17, + 'Workbloom\\Component\\' => 20, 'Workbloom\\' => 10, - 'WorkbloomModule\\' => 16, - 'WorkbloomComponent\\' => 19, ), 'S' => array ( @@ -55,18 +55,18 @@ class ComposerStaticInit8166d455774ce82597f7c8b1884b0ce8 ); public static $prefixDirsPsr4 = array ( - 'Workbloom\\' => - array ( - 0 => __DIR__ . '/../..' . '/app/Common', - ), - 'WorkbloomModule\\' => + 'Workbloom\\Module\\' => array ( 0 => __DIR__ . '/../..' . '/app/Module', ), - 'WorkbloomComponent\\' => + 'Workbloom\\Component\\' => array ( 0 => __DIR__ . '/../..' . '/app/Common/Component', ), + 'Workbloom\\' => + array ( + 0 => __DIR__ . '/../..' . '/app/Common', + ), 'Symfony\\Polyfill\\Php80\\' => array ( 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c3297ca..070700a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -233,17 +233,17 @@ }, { "name": "nikic/php-parser", - "version": "v5.6.1", - "version_normalized": "5.6.1.0", + "version": "v5.6.2", + "version_normalized": "5.6.2.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2" + "reference": "3a454ca033b9e06b63282ce19562e892747449bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", - "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", + "reference": "3a454ca033b9e06b63282ce19562e892747449bb", "shasum": "" }, "require": { @@ -256,7 +256,7 @@ "ircmaxell/php-yacc": "^0.0.7", "phpunit/phpunit": "^9.0" }, - "time": "2025-08-13T20:13:15+00:00", + "time": "2025-10-21T19:32:17+00:00", "bin": [ "bin/php-parse" ], @@ -288,7 +288,7 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" }, "install-path": "../nikic/php-parser" }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 8121691..212c194 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'cybercore/workbloom', - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => null, + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => '311cadc1d12a6f269a473c6861dfc268a201ef6f', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -20,9 +20,9 @@ 'dev_requirement' => false, ), 'cybercore/workbloom' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => null, + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => '311cadc1d12a6f269a473c6861dfc268a201ef6f', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -56,9 +56,9 @@ 'dev_requirement' => true, ), 'nikic/php-parser' => array( - 'pretty_version' => 'v5.6.1', - 'version' => '5.6.1.0', - 'reference' => 'f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2', + 'pretty_version' => 'v5.6.2', + 'version' => '5.6.2.0', + 'reference' => '3a454ca033b9e06b63282ce19562e892747449bb', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php index be9d070..55ef163 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Expr; require __DIR__ . '/../ArrayItem.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\ArrayItem instead. + */ class ArrayItem extends \PhpParser\Node\ArrayItem { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php index b395617..279aa26 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Expr; require __DIR__ . '/../ClosureUse.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\ClosureUse instead. + */ class ClosureUse extends \PhpParser\Node\ClosureUse { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php index 6634930..6cbb84c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php @@ -71,6 +71,10 @@ class Param extends NodeAbstract { return $this->flags !== 0 || $this->hooks !== []; } + public function isFinal(): bool { + return (bool) ($this->flags & Modifiers::FINAL); + } + public function isPublic(): bool { $public = (bool) ($this->flags & Modifiers::PUBLIC); if ($public) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php index aaafc5f..5b5e410 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Scalar; require __DIR__ . '/Float_.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\Scalar\Float_ instead. + */ class DNumber extends Float_ { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php index a97545e..57fcceb 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Scalar; require __DIR__ . '/InterpolatedString.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\Scalar\InterpolatedString instead. + */ class Encapsed extends InterpolatedString { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php index 7ef5fb0..d67011a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php @@ -7,7 +7,11 @@ use PhpParser\Node\InterpolatedStringPart; require __DIR__ . '/../InterpolatedStringPart.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\InterpolatedStringPart instead. + */ class EncapsedStringPart extends InterpolatedStringPart { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php index 0d12871..868d78f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Scalar; require __DIR__ . '/Int_.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\Scalar\Int_ instead. + */ class LNumber extends Int_ { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php index c965366..b8d1693 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php @@ -124,7 +124,7 @@ class String_ extends Scalar { // If it overflowed to float, treat as INT_MAX, it will throw an error anyway. return self::codePointToUtf8(\is_int($dec) ? $dec : \PHP_INT_MAX); } else { - return chr(octdec($str)); + return chr(octdec($str) & 255); } }, $str diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php index 1a3c361..c186134 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php @@ -7,7 +7,11 @@ use PhpParser\Node\DeclareItem; require __DIR__ . '/../DeclareItem.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\DeclareItem instead. + */ class DeclareDeclare extends DeclareItem { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php index fe7c997..62556e7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php @@ -7,7 +7,11 @@ use PhpParser\Node\PropertyItem; require __DIR__ . '/../PropertyItem.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\PropertyItem instead. + */ class PropertyProperty extends PropertyItem { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php index 6775b95..a3c5fa6 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php @@ -5,7 +5,11 @@ namespace PhpParser\Node\Stmt; require __DIR__ . '/../StaticVar.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\StaticVar instead. + */ class StaticVar extends \PhpParser\Node\StaticVar { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php index b14fbd6..9e504f8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php @@ -7,7 +7,11 @@ use PhpParser\Node\UseItem; require __DIR__ . '/../UseItem.php'; if (false) { - // For classmap-authoritative support. + /** + * For classmap-authoritative support. + * + * @deprecated use \PhpParser\Node\UseItem instead. + */ class UseUse extends UseItem { } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php index ac8bda2..fdb0fb7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +++ b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php @@ -678,8 +678,10 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { } [$printFn, $findToken] = $this->modifierChangeMap[$key]; + $skipWSPos = $this->origTokens->skipRightWhitespace($pos); + $result .= $this->origTokens->getTokenCode($pos, $skipWSPos, $indentAdjustment); $result .= $this->$printFn($subNode); - $pos = $this->origTokens->findRight($pos, $findToken); + $pos = $this->origTokens->findRight($skipWSPos, $findToken); continue; }