This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from rodnaph/remove-safe
Remove Safe
- Loading branch information
Showing
10 changed files
with
110 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: "Continuous Integration" | ||
|
||
on: | ||
pull_request: | ||
pull_request_target: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
ci: | ||
name: "Run Build" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v2 | ||
|
||
- name: "Run Lint" | ||
run: make lint | ||
|
||
- name: "Run Tests" | ||
run: make test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
includes: | ||
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon | ||
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon | ||
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TheCodingMachine\Gotenberg; | ||
|
||
use ErrorException; | ||
use RuntimeException; | ||
use function error_get_last; | ||
|
||
class FilesystemException extends ErrorException | ||
{ | ||
public static function createFromPhpError(): self | ||
{ | ||
$error = error_get_last(); | ||
|
||
if ($error === null) { | ||
throw new RuntimeException('No error information available'); | ||
} | ||
|
||
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TheCodingMachine\Gotenberg; | ||
|
||
use ErrorException; | ||
use PHPUnit\Framework\TestCase; | ||
use RuntimeException; | ||
use function error_clear_last; | ||
use function fclose; | ||
use function fopen; | ||
|
||
class FilesystemExceptionTest extends TestCase | ||
{ | ||
public function testExceptionCanBeCreated(): void | ||
{ | ||
$fp = fopen('php://memory', 'r'); | ||
fclose($fp); | ||
@fclose($fp); | ||
|
||
$exception = FilesystemException::createFromPhpError(); | ||
|
||
$this->assertInstanceOf(ErrorException::class, $exception); | ||
$this->assertSame('fclose(): supplied resource is not a valid stream resource', $exception->getMessage()); | ||
$this->assertSame(0, $exception->getCode()); | ||
$this->assertSame(2, $exception->getSeverity()); | ||
} | ||
|
||
public function testExceptionThrownWhenNoError(): void | ||
{ | ||
error_clear_last(); | ||
|
||
$this->expectException(RuntimeException::class); | ||
$this->expectExceptionMessage('No error information available'); | ||
|
||
FilesystemException::createFromPhpError(); | ||
} | ||
} |