Skip to content

Commit b5c063d

Browse files
committed
Merge branch 'cleanup'
2 parents 7a4662e + ef0b58c commit b5c063d

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

src/Console/ConsoleFormatter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ final class ConsoleFormatter
9292
# empty line by making the subsequent newline conditional on inblock
9393
(?<block> (?> (?<inblock> (?: (?! (?&endofblock) ) (?: \k<indent> | (?= (?&endofline) ) ) [^\n]* (?: (?= \n (?&endofblock) ) | \n | \z ) )+ )? ) )
9494
# Allow code fences to terminate at the end of the subject
95-
(?: (?(inblock) \n ) (?&endofblock) | \z )
95+
(?: (?(inblock) \n ) (?&endofblock) | \z ) | \z
9696
) ) |
9797
# CommonMark-compliant code spans
9898
(?<backtickstring> (?> `+ ) ) (?<span> (?> (?: [^`]+ | (?! (?&endofspan) ) `+ )* ) ) (?&endofspan) |
@@ -330,7 +330,11 @@ public function formatTags(
330330
$indent = (string) $match['indent'];
331331

332332
if ($match['breaks'] !== null) {
333-
$string .= $indent . $match['breaks'];
333+
$breaks = $match['breaks'];
334+
if ($unwrap && strpos($breaks, "\n") !== false) {
335+
$breaks = Convert::unwrap($breaks, "\n", false, true, true);
336+
}
337+
$string .= $indent . $breaks;
334338
continue;
335339
}
336340

src/Container/Application.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,15 @@ final public function getBasePath(): string
367367
/**
368368
* @inheritDoc
369369
*/
370-
public function restoreWorkingDirectory()
370+
final public function getWorkingDirectory(): string
371+
{
372+
return $this->WorkingDirectory;
373+
}
374+
375+
/**
376+
* @inheritDoc
377+
*/
378+
final public function restoreWorkingDirectory()
371379
{
372380
if (File::cwd() !== $this->WorkingDirectory) {
373381
File::chdir($this->WorkingDirectory);
@@ -379,7 +387,7 @@ public function restoreWorkingDirectory()
379387
/**
380388
* @inheritDoc
381389
*/
382-
public function setWorkingDirectory(?string $directory = null)
390+
final public function setWorkingDirectory(?string $directory = null)
383391
{
384392
$this->WorkingDirectory = $directory ?? File::cwd();
385393

src/Container/ApplicationInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,18 @@ public function syncNamespace(
167167
);
168168

169169
/**
170-
* Change to the application's working directory
170+
* Get the application's working directory
171171
*
172172
* The application's working directory is either:
173173
*
174174
* - the directory in which it was started, or
175175
* - the directory most recently set by calling
176176
* {@see ApplicationInterface::setWorkingDirectory()}
177+
*/
178+
public function getWorkingDirectory(): string;
179+
180+
/**
181+
* Change to the application's working directory
177182
*
178183
* @return $this
179184
*/

src/Utility/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function isIntValue($value): bool
5151
public static function isFloatValue($value): bool
5252
{
5353
return is_float($value) ||
54-
(is_string($value) && is_numeric($value) && !self::isIntValue($value));
54+
(is_string($value) && is_numeric(trim($value)) && !self::isIntValue($value));
5555
}
5656

5757
/**

tests/unit/Console/ConsoleFormatterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,22 @@ public static function formatProvider(): array
521521
false,
522522
"\n ",
523523
],
524+
[
525+
<<<EOF
526+
text without backticks at the end of the line
527+
528+
text with `backticks` at the end of the line
529+
EOF,
530+
$loopback,
531+
<<<EOF
532+
text without backticks
533+
at the end of the line
534+
535+
text with `backticks`
536+
at the end of the line
537+
EOF,
538+
true,
539+
],
524540
];
525541
}
526542

0 commit comments

Comments
 (0)