1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Refactor and enhance type hinting across various classes in the Swagger-PHP library

- Updated error handling in TokenScanner to use more descriptive variable names.
- Added return type declarations for methods in Analysis, AbstractAnnotation, Components, Items, License, OpenApi, Operation, Parameter, Response, Schema, Context, Generator, and several processors to improve code clarity and type safety.
- Introduced new PipeOperatorEmulator and VoidCastEmulator classes to support PHP 8.5 features.
- Implemented Pipe binary operator and Void cast node classes to enhance the parser's capabilities.
- Improved array filtering and lambda function type hints for better readability and performance.
- Enhanced the handling of annotations and context in various processors to ensure consistent behavior and reduce potential errors.
This commit is contained in:
Daniel Neto 2025-08-12 11:19:47 -03:00
parent 4a540ee196
commit 7c9f95b33d
106 changed files with 4068 additions and 3509 deletions

View file

@ -59,9 +59,11 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter {
BinaryOp\Mod::class => [ 40, 41, 40],
BinaryOp\Plus::class => [ 50, 51, 50],
BinaryOp\Minus::class => [ 50, 51, 50],
// FIXME: This precedence is incorrect for PHP 8.
BinaryOp\Concat::class => [ 50, 51, 50],
BinaryOp\ShiftLeft::class => [ 60, 61, 60],
BinaryOp\ShiftRight::class => [ 60, 61, 60],
BinaryOp\Pipe::class => [ 65, 66, 65],
BinaryOp\Smaller::class => [ 70, 70, 70],
BinaryOp\SmallerOrEqual::class => [ 70, 70, 70],
BinaryOp\Greater::class => [ 70, 70, 70],
@ -102,6 +104,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter {
Expr\Include_::class => [220, -1, -1],
Expr\ArrowFunction::class => [230, -1, -1],
Expr\Throw_::class => [240, -1, -1],
Expr\Cast\Void_::class => [250, -1, -1],
];
/** @var int Current indentation level. */
@ -1372,7 +1375,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter {
BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class,
BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class,
BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class,
BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class,
BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class, BinaryOp\Pipe::class,
];
foreach ($binaryOps as $binaryOp) {
$this->fixupMap[$binaryOp] = [
@ -1634,6 +1637,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter {
Stmt\Trait_::class . '->attrGroups' => [null, '', "\n"],
Expr\ArrowFunction::class . '->attrGroups' => [null, '', ' '],
Expr\Closure::class . '->attrGroups' => [null, '', ' '],
Stmt\Const_::class . '->attrGroups' => [null, '', "\n"],
PrintableNewAnonClassNode::class . '->attrGroups' => [\T_NEW, ' ', ''],
/* These cannot be empty to start with: