-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LinksRule for checking validity of links
- Loading branch information
1 parent
6ec9016
commit e01ed37
Showing
38 changed files
with
1,718 additions
and
0 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
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
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,25 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
use Throwable; | ||
use function sprintf; | ||
|
||
class InvalidLinkDestinationException extends InvalidLinkException | ||
{ | ||
|
||
/** @var string */ | ||
private $destination; | ||
|
||
public function __construct(string $destination, int $code = 0, ?Throwable $previous = null) | ||
{ | ||
parent::__construct(sprintf("Invalid link destination '%s'", $destination), $code, $previous); | ||
$this->destination = $destination; | ||
} | ||
|
||
public function getDestination(): string | ||
{ | ||
return $this->destination; | ||
} | ||
|
||
} |
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,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
use RuntimeException; | ||
|
||
class InvalidLinkException extends RuntimeException | ||
{ | ||
|
||
} |
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,8 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
class InvalidLinkParamsException extends InvalidLinkException | ||
{ | ||
|
||
} |
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,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
use RuntimeException; | ||
|
||
class LinkCheckFailedException extends RuntimeException | ||
{ | ||
|
||
} |
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,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
use RuntimeException; | ||
|
||
class PresenterResolvingException extends RuntimeException | ||
{ | ||
|
||
} |
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,8 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Exceptions; | ||
|
||
class PresenterResolvingNotAvailableException extends PresenterResolvingException | ||
{ | ||
|
||
} |
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,66 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Nette; | ||
|
||
use Nette\DI\Container; | ||
use PHPStan\ShouldNotHappenException; | ||
use function is_file; | ||
use function is_readable; | ||
use function sprintf; | ||
|
||
class ContainerResolver | ||
{ | ||
|
||
/** @var string|null */ | ||
private $containerLoader; | ||
|
||
/** @var Container|false|null */ | ||
private $container; | ||
|
||
public function __construct(?string $containerLoader) | ||
{ | ||
$this->containerLoader = $containerLoader; | ||
} | ||
|
||
public function getContainer(): ?Container | ||
{ | ||
if ($this->container === false) { | ||
return null; | ||
} | ||
|
||
if ($this->container !== null) { | ||
return $this->container; | ||
} | ||
|
||
if ($this->containerLoader === null) { | ||
$this->container = false; | ||
|
||
return null; | ||
} | ||
|
||
$this->container = $this->loadContainer($this->containerLoader); | ||
|
||
return $this->container; | ||
} | ||
|
||
|
||
private function loadContainer(string $containerLoader): ?Container | ||
{ | ||
if (!is_file($containerLoader)) { | ||
throw new ShouldNotHappenException(sprintf( | ||
'Nette container could not be loaded: file "%s" does not exist', | ||
$containerLoader | ||
)); | ||
} | ||
|
||
if (!is_readable($containerLoader)) { | ||
throw new ShouldNotHappenException(sprintf( | ||
'Nette container could not be loaded: file "%s" is not readable', | ||
$containerLoader | ||
)); | ||
} | ||
|
||
return require $containerLoader; | ||
} | ||
|
||
} |
Oops, something went wrong.