Skip to content

Commit b555400

Browse files
committed
fix almost long lines phpcs warnings
1 parent ee00e5a commit b555400

19 files changed

Lines changed: 260 additions & 60 deletions

flight/Engine.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ public function handleException(Throwable $e): void
267267
/**
268268
* Registers the container handler
269269
*
270-
* @param ContainerInterface|callable(class-string<T> $id, array<int|string, mixed> $params): ?T $containerHandler Callback function or PSR-11 Container object that sets the container and how it will inject classes
270+
* @param ContainerInterface|callable(class-string<T> $id, array<int|string, mixed> $params): ?T $containerHandler
271+
* Callback function or PSR-11 Container object that sets the container and how it will inject classes
271272
*
272273
* @template T of object
273274
*/
@@ -488,7 +489,14 @@ protected function processMiddleware(Route $route, string $eventName): bool
488489
// Which loosely translates to $class->$method($params)
489490
$start = microtime(true);
490491
$middlewareResult = $middlewareObject($params);
491-
$this->triggerEvent('flight.middleware.executed', $route, $middleware, $eventName, microtime(true) - $start);
492+
493+
$this->triggerEvent(
494+
'flight.middleware.executed',
495+
$route,
496+
$middleware,
497+
$eventName,
498+
microtime(true) - $start
499+
);
492500

493501
if ($useV3OutputBuffering === true) {
494502
$this->response()->write(ob_get_clean());
@@ -860,7 +868,12 @@ public function _notFound(): void
860868
public function _methodNotFound(Route $route): void
861869
{
862870
$this->response()->setHeader('Allow', implode(', ', $route->methods));
863-
$this->halt(405, 'Method Not Allowed. Allowed Methods are: ' . implode(', ', $route->methods), empty(getenv('PHPUNIT_TEST')));
871+
872+
$this->halt(
873+
405,
874+
'Method Not Allowed. Allowed Methods are: ' . implode(', ', $route->methods),
875+
empty(getenv('PHPUNIT_TEST'))
876+
);
864877
}
865878

866879
/**

flight/Flight.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
* @phpstan-method static void jsonHalt(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0)
8181
* @phpstan-method static void jsonp(mixed $data, string $param = 'jsonp', int $code = 200, bool $encode = true, string $charset = "utf8", int $encodeOption = 0, int $encodeDepth = 512)
8282
*
83-
* Note: IDEs will use standard @method tags for autocompletion, while PHPStan will use @phpstan-* tags for advanced type checking.
83+
* Note: IDEs will use standard @method tags for autocompletion,
84+
* while PHPStan will use @phpstan-* tags for advanced type checking.
8485
*/
8586
class Flight
8687
{

flight/commands/AiGenerateInstructionsCommand.php

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ class AiGenerateInstructionsCommand extends AbstractBaseCommand
2020
public function __construct(array $config)
2121
{
2222
parent::__construct('ai:generate-instructions', 'Generate project-specific AI coding instructions', $config);
23-
$this->option('--config-file', 'Path to .runway-config.json file (deprecated, use config.php instead)', null, '');
23+
24+
$this->option(
25+
'--config-file',
26+
'Path to .runway-config.json file (deprecated, use config.php instead)',
27+
null,
28+
''
29+
);
2430
}
2531

2632
/**
@@ -40,7 +46,12 @@ public function execute(): int
4046
if (empty($this->config['runway'])) {
4147
$configFile = $this->configFile;
4248
$io = $this->app()->io();
43-
$io->warn('The --config-file option is deprecated. Move your config values to the \'runway\' key in the config.php file for configuration.', true);
49+
50+
$io->warn(
51+
'The --config-file option is deprecated. '
52+
. 'Move your config values to the \'runway\' key in the config.php file for configuration.',
53+
true
54+
);
4455
$runwayConfig = json_decode(file_get_contents($configFile), true) ?? [];
4556
} else {
4657
$runwayConfig = $this->config['runway'];
@@ -56,12 +67,30 @@ public function execute(): int
5667

5768
// Ask questions
5869
$projectDesc = $io->prompt('Please describe what your project is for?');
59-
$database = $io->prompt('What database are you planning on using? (e.g. MySQL, SQLite, PostgreSQL, none)', 'none');
60-
$templating = $io->prompt('What HTML templating engine will you plan on using (if any)? (recommend latte)', 'latte');
70+
71+
$database = $io->prompt(
72+
'What database are you planning on using? (e.g. MySQL, SQLite, PostgreSQL, none)',
73+
'none'
74+
);
75+
76+
$templating = $io->prompt(
77+
'What HTML templating engine will you plan on using (if any)? (recommend latte)',
78+
'latte'
79+
);
80+
6181
$security = $io->confirm('Is security an important element of this project?', 'y');
6282
$performance = $io->confirm('Is performance and speed an important part of this project?', 'y');
63-
$composerLibs = $io->prompt('What major composer libraries will you be using if you know them right now?', 'none');
64-
$envSetup = $io->prompt('How will you set up your development environment? (e.g. Docker, Vagrant, PHP dev server, other)', 'Docker');
83+
84+
$composerLibs = $io->prompt(
85+
'What major composer libraries will you be using if you know them right now?',
86+
'none'
87+
);
88+
89+
$envSetup = $io->prompt(
90+
'How will you set up your development environment? (e.g. Docker, Vagrant, PHP dev server, other)',
91+
'Docker'
92+
);
93+
6594
$teamSize = $io->prompt('How many developers will be working on this project?', '1');
6695
$api = $io->confirm('Will this project expose an API?', 'n');
6796
$other = $io->prompt('Any other important requirements or context? (optional)', 'no');
@@ -107,7 +136,13 @@ public function execute(): int
107136
$data = [
108137
'model' => $model,
109138
'messages' => [
110-
['role' => 'system', 'content' => 'You are a helpful AI coding assistant focused on the Flight Framework for PHP. You are up to date with all your knowledge from https://docs.flightphp.com. As an expert into the programming language PHP, you are top notch at architecting out proper instructions for FlightPHP projects.'],
139+
[
140+
'role' => 'system',
141+
'content' => 'You are a helpful AI coding assistant focused on the Flight Framework for PHP. '
142+
. 'You are up to date with all your knowledge from https://docs.flightphp.com. '
143+
. 'As an expert into the programming language PHP, '
144+
. 'you are top notch at architecting out proper instructions for FlightPHP projects.'
145+
],
111146
['role' => 'user', 'content' => $prompt],
112147
],
113148
'temperature' => 0.2,
@@ -129,7 +164,11 @@ public function execute(): int
129164
}
130165

131166
// Write to files
132-
$io->info('Updating .github/copilot-instructions.md, .cursor/rules/project-overview.mdc, .gemini/GEMINI.md and .windsurfrules...', true);
167+
$io->info(
168+
'Updating .github/copilot-instructions.md, .cursor/rules/project-overview.mdc, .gemini/GEMINI.md and .windsurfrules...',
169+
true
170+
);
171+
133172
if (!is_dir($this->projectRoot . '.github')) {
134173
mkdir($this->projectRoot . '.github', 0755, true);
135174
}

flight/commands/AiInitCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ public function execute(): int
7979
$defaultModel = 'claude-sonnet-4-5';
8080
break;
8181
}
82-
$model = trim($io->prompt('Enter the model name you want to use (e.g. gpt-5, claude-sonnet-4-5, etc)', $defaultModel));
82+
83+
$model = trim($io->prompt(
84+
'Enter the model name you want to use (e.g. gpt-5, claude-sonnet-4-5, etc)',
85+
$defaultModel
86+
));
8387

8488
$runwayAiConfig = [
8589
'provider' => $api,

flight/commands/ControllerCommand.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@ public function execute(string $controller): void
3131
$io = $this->app()->io();
3232

3333
if (empty($this->config['runway'])) {
34-
$io->warn('Using a .runway-config.json file is deprecated. Move your config values to app/config/config.php with `php runway config:migrate`.', true); // @codeCoverageIgnore
35-
$runwayConfig = json_decode(file_get_contents($this->projectRoot . '/.runway-config.json'), true); // @codeCoverageIgnore
34+
$io->warn(
35+
'Using a .runway-config.json file is deprecated. '
36+
. 'Move your config values to app/config/config.php with `php runway config:migrate`.',
37+
true
38+
); // @codeCoverageIgnore
39+
40+
$runwayConfig = json_decode(
41+
file_get_contents($this->projectRoot . '/.runway-config.json'),
42+
true
43+
); // @codeCoverageIgnore
3644
} else {
3745
$runwayConfig = $this->config['runway'];
3846
}
@@ -95,6 +103,9 @@ public function execute(string $controller): void
95103
protected function persistClass(string $controllerName, PhpFile $file, string $appRoot)
96104
{
97105
$printer = new \Nette\PhpGenerator\PsrPrinter();
98-
file_put_contents($this->projectRoot . '/' . $appRoot . 'controllers/' . $controllerName . '.php', $printer->printFile($file));
106+
file_put_contents(
107+
$this->projectRoot . '/' . $appRoot . 'controllers/' . $controllerName . '.php',
108+
$printer->printFile($file)
109+
);
99110
}
100111
}

flight/core/Dispatcher.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class Dispatcher
5858
*
5959
* @template T of object
6060
*
61-
* @throws InvalidArgumentException If $containerHandler is not a `callable` or instance of `Psr\Container\ContainerInterface`.
61+
* @throws InvalidArgumentException
62+
* If $containerHandler is not a `callable` or instance of `Psr\Container\ContainerInterface`.
6263
*/
6364
public function setContainerHandler($containerHandler): void
6465
{
@@ -413,7 +414,10 @@ protected function verifyValidClassCallable($class, $method, $resolvedClass): vo
413414

414415
// Final check to make sure it's actually a class and a method, or throw an error
415416
if (is_object($class) === false && class_exists($class) === false) {
416-
$exception = new Exception("Class '$class' not found. Is it being correctly autoloaded with Flight::path()?");
417+
$exception = new Exception(
418+
"Class '$class' not found. "
419+
. "Is it being correctly autoloaded with Flight::path()?"
420+
);
417421

418422
// If this tried to resolve a class in a container and failed somehow, throw the exception
419423
} elseif (!$resolvedClass && $this->containerException !== null) {

flight/net/Request.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,13 @@ public static function parseQuery(string $url): array
439439
*/
440440
public static function getScheme(): string
441441
{
442-
if ((strtolower(self::getVar('HTTPS')) === 'on') || (self::getVar('HTTP_X_FORWARDED_PROTO') === 'https') || (self::getVar('HTTP_FRONT_END_HTTPS') === 'on') || (self::getVar('REQUEST_SCHEME') === 'https')) {
442+
if (strtolower(self::getVar('HTTPS')) === 'on') {
443+
return 'https';
444+
} elseif (self::getVar('HTTP_X_FORWARDED_PROTO') === 'https') {
445+
return 'https';
446+
} elseif (self::getVar('HTTP_FRONT_END_HTTPS') === 'on') {
447+
return 'https';
448+
} elseif (self::getVar('REQUEST_SCHEME') === 'https') {
443449
return 'https';
444450
}
445451

@@ -470,7 +476,8 @@ public function negotiateContentType(array $supported): ?string
470476
/**
471477
* Retrieves the array of uploaded files.
472478
*
473-
* @return array<string, UploadedFile|array<int, UploadedFile>> Key is field name; value is either a single UploadedFile or an array of UploadedFile when multiple were uploaded.
479+
* @return array<string, UploadedFile|array<int, UploadedFile>>
480+
* Key is field name; value is either a single UploadedFile or an array of UploadedFile when multiple were uploaded.
474481
*/
475482
public function getUploadedFiles(): array
476483
{

flight/net/Response.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ protected function processResponseCallbacks(): void
484484
* Downloads a file.
485485
*
486486
* @param string $filePath The path to the file to be downloaded.
487-
* @param string $fileName The name the downloaded file should have. If not provided or is an empty string, the name of the file on disk will be used.
487+
* @param string $fileName The name the downloaded file should have.
488+
* If not provided or is an empty string, the name of the file on disk will be used.
488489
*
489490
* @throws Exception If the file cannot be found.
490491
*

flight/net/UploadedFile.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ class UploadedFile
4848
* @param int $error The error code associated with the uploaded file.
4949
* @param bool|null $isPostUploadedFile Indicates if the file was uploaded via POST method.
5050
*/
51-
public function __construct(string $name, string $mimeType, int $size, string $tmpName, int $error, ?bool $isPostUploadedFile = null)
52-
{
51+
public function __construct(
52+
string $name,
53+
string $mimeType,
54+
int $size,
55+
string $tmpName,
56+
int $error,
57+
?bool $isPostUploadedFile = null
58+
) {
5359
$this->name = $name;
5460
$this->mimeType = $mimeType;
5561
$this->size = $size;

tests/DispatcherTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ public function testBeforeAndAfterWithShortAfterFilterSyntax(): void
152152
public function testInvalidCallback(): void
153153
{
154154
$this->expectException(Exception::class);
155-
$this->expectExceptionMessage("Class 'NonExistentClass' not found. Is it being correctly autoloaded with Flight::path()?");
155+
156+
$this->expectExceptionMessage(
157+
"Class 'NonExistentClass' not found. "
158+
. "Is it being correctly autoloaded with Flight::path()?"
159+
);
156160

157161
$this->dispatcher->execute(['NonExistentClass', 'nonExistentMethod']);
158162
}
@@ -279,7 +283,12 @@ public function testInvokeMethod(): void
279283
public function testExecuteStringClassBadConstructParams(): void
280284
{
281285
$this->expectException(ArgumentCountError::class);
282-
$this->expectExceptionMessageMatches('#Too few arguments to function tests\\\\classes\\\\TesterClass::__construct\(\), 1 passed .+ and exactly 6 expected#');
286+
287+
$this->expectExceptionMessageMatches(
288+
'#Too few arguments to function tests\\\\classes\\\\TesterClass::__construct\(\), 1 passed'
289+
. ' .+ and exactly 6 expected#'
290+
);
291+
283292
$this->dispatcher->execute(TesterClass::class . '->instanceMethod');
284293
}
285294

@@ -331,7 +340,11 @@ public function testExecuteStringClassDefaultContainerArraySyntax(): void
331340
public function testExecuteStringClassDefaultContainerButForgotInjectingEngine(): void
332341
{
333342
$this->expectException(TypeError::class);
334-
$this->expectExceptionMessageMatches('#tests\\\\classes\\\\ContainerDefault::__construct\(\).+flight\\\\Engine, null given#');
343+
344+
$this->expectExceptionMessageMatches(
345+
'#tests\\\\classes\\\\ContainerDefault::__construct\(\).+flight\\\\Engine, null given#'
346+
);
347+
335348
$this->dispatcher->execute([ContainerDefault::class, 'testTheContainer']);
336349
}
337350

0 commit comments

Comments
 (0)