File tree Expand file tree Collapse file tree 6 files changed +131
-0
lines changed
Expand file tree Collapse file tree 6 files changed +131
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception \StreamFilter ;
4+
5+ use Okapi \CodeTransformer \Exception \StreamFilterException ;
6+
7+ /**
8+ * # Invalid Stream Exception
9+ *
10+ * This exception is thrown when the stream is invalid.
11+ *
12+ * @codeCoverageIgnore Not sure how to test this
13+ */
14+ class InvalidStreamException extends StreamFilterException
15+ {
16+ /**
17+ * InvalidStreamException constructor.
18+ */
19+ public function __construct ()
20+ {
21+ parent ::__construct (
22+ "The stream must be a valid resource. " ,
23+ );
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception ;
4+
5+ /**
6+ * # Stream Filter Exception
7+ *
8+ * Base exception for all `StreamFilter` exceptions.
9+ */
10+ abstract class StreamFilterException extends CodeTransformerException
11+ {
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception \Transformer ;
4+
5+ use Okapi \CodeTransformer \Exception \TransformerException ;
6+
7+ /**
8+ * # Invalid Transformer Class Exception
9+ *
10+ * This exception is thrown when a transformer class does not extend the
11+ * `Transformer` class.
12+ */
13+ class InvalidTransformerClassException extends TransformerException
14+ {
15+ /**
16+ * Create a new `TransformerMissingInterfaceException` instance.
17+ *
18+ * @param class-string $transformerClass
19+ */
20+ public function __construct (string $ transformerClass ) {
21+ parent ::__construct (
22+ message: "Transformer class ' $ transformerClass' does not extend the Transformer class. " ,
23+ );
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception \Transformer ;
4+
5+ use Microsoft \PhpParser \Diagnostic ;
6+ use Okapi \CodeTransformer \Exception \TransformerException ;
7+
8+ /**
9+ * # Syntax Error
10+ *
11+ * This exception is thrown when the transformed code contains a syntax error.
12+ */
13+ class SyntaxError extends TransformerException
14+ {
15+ /**
16+ * SyntaxError constructor.
17+ *
18+ * @param Diagnostic $diagnostic
19+ * @param string $code
20+ * @param SyntaxError|null $previous
21+ */
22+ public function __construct (
23+ Diagnostic $ diagnostic ,
24+ string $ code ,
25+ ?SyntaxError $ previous = null
26+ ) {
27+ parent ::__construct (
28+ "Syntax error in transformed code: $ diagnostic ->message \n\nFull code: \n$ code " ,
29+ previous: $ previous ,
30+ );
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception \Transformer ;
4+
5+ use Okapi \CodeTransformer \Exception \TransformerException ;
6+
7+ /**
8+ * # Transformer Not Found Exception
9+ *
10+ * This exception is thrown when an invalid transformer class is specified.
11+ */
12+ class TransformerNotFoundException extends TransformerException
13+ {
14+ /**
15+ * Create a new instance of the exception.
16+ *
17+ * @param class-string $transformerClass
18+ */
19+ public function __construct (string $ transformerClass )
20+ {
21+ parent ::__construct (
22+ message: "Transformer class ' $ transformerClass' does not exist. " ,
23+ );
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Okapi \CodeTransformer \Exception ;
4+
5+ /**
6+ * # Transformer Exception
7+ *
8+ * This exception is thrown when a transformer fails to transform the code.
9+ */
10+ abstract class TransformerException extends CodeTransformerException
11+ {
12+ }
You can’t perform that action at this time.
0 commit comments