Skip to content

Commit

Permalink
Couple phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Oct 29, 2023
1 parent 24b084b commit b818658
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/ApacheModRewriteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public function generateRewrite( string $from, string $to, int $type ) : string
}

private function escapeSubstitution( string $input ) : string {
return preg_replace('/[-\s%$\\\\]/', '\\\\$0', $input);
$result = preg_replace('/[-\s%$\\\\]/', '\\\\$0', $input);
if( $result === null ) {
throw new \RuntimeException('preg_replace failed - ' . preg_last_error());
}

return $result;
}

}
10 changes: 5 additions & 5 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

class Engine {

/**
* @var \donatj\RewriteGenerator\GeneratorInterface
*/
private $generator;
private GeneratorInterface $generator;

private $lastErrorCount = 0;
private int $lastErrorCount = 0;

public function __construct( GeneratorInterface $generator ) {
$this->generator = $generator;
Expand All @@ -22,6 +19,9 @@ public function generate( string $input, int $type, bool $comments ) : string {
$output = '';

$input = preg_replace('/\h+/', "\t", $input); // Spacing Cleanup
if( $input === null ) {
throw new \RuntimeException('preg_replace failed - ' . preg_last_error());
}

$lines = explode(PHP_EOL, $input);

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/ApacheIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ApacheIntegrationTest extends TestCase {
/**
* @dataProvider exampleProvider
*/
public function test_examples( string $input, string $output301, string $outputRewrite ) {
public function test_examples( string $input, string $output301, string $outputRewrite ) : void {
$engine = new Engine(new ApacheModRewriteGenerator);

$given = $engine->generate($input, RewriteTypes::PERMANENT_REDIRECT, true);
Expand Down Expand Up @@ -136,7 +136,7 @@ public function exampleProvider() : Generator {
/**
* @dataProvider failureProvider
*/
public function test_failures( string $input, string $output, int $errorCount ) {
public function test_failures( string $input, string $output, int $errorCount ) : void {
$engine = new Engine(new ApacheModRewriteGenerator);

$given = $engine->generate($input, RewriteTypes::PERMANENT_REDIRECT, true);
Expand Down

0 comments on commit b818658

Please sign in to comment.