Issues (46)

src/HandlerStackInterface.php (1 issue)

1
<?php
2
/**
3
 * Copyright (c) 2017–2019 Ryan Parman <http://ryanparman.com>.
4
 * Copyright (c) 2017–2019 Contributors.
5
 *
6
 * http://opensource.org/licenses/Apache2.0
7
 */
8
9
declare(strict_types=1);
10
11
namespace SimplePie;
12
13
use DOMXPath;
14
use SimplePie\Configuration as C;
15
use SimplePie\Enum\FeedType;
16
use SimplePie\Exception\MiddlewareException;
17
use SimplePie\Util\Ns;
18
use Skyzyx\UtilityPack\Types;
0 ignored issues
show
The type Skyzyx\UtilityPack\Types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use stdClass;
20
21
/**
22
 * Provides an interface for `SimplePie\HandlerStack` to implement.
23
 */
24
interface HandlerStackInterface extends C\SetLoggerInterface
25
{
26
    /**
27
     * Appends a new middleware class onto the end of the stack.
28
     *
29
     * @param callable    $middleware   The middleware to add to the stack.
30
     * @param string|null $name         A name for the middleware. Can be used with `pushBefore()` and `pushAfter()`.
31
     * @param string|null $overrideType Override our best guess for which stack to apply the middleware to. By default
32
     *                                  the appropriate stack will be determined by which
33
     *                                  `SimplePie\Middleware\*\*Interface` the middleware extends from. If the
34
     *                                  middleware is a closure, this parameter is required. If the appropriate stack
35
     *                                  cannot be determined, a `SimplePie\Exception\MiddlewareException` exception
36
     *                                  will be thrown.
37
     *
38
     * @throws MiddlewareException
39
     */
40
    public function append(callable $middleware, ?string $name = null, ?string $overrideType = null): self;
41
42
    /**
43
     * Appends a new middleware closure onto the end of the stack.
44
     *
45
     * @param string|null $overrideType Override our best guess for which stack to apply the middleware to. By default
46
     *                                  the appropriate stack will be determined by which
47
     *                                  `SimplePie\Middleware\*\*Interface` the middleware extends from. If the
48
     *                                  middleware is a closure, this parameter is required. If the appropriate stack
49
     *                                  cannot be determined, a `SimplePie\Exception\MiddlewareException` exception
50
     *                                  will be thrown.
51
     * @param callable    $middleware   The middleware to add to the stack.
52
     * @param string|null $name         A name for the middleware. Can be used with `pushBefore()` and `pushAfter()`.
53
     *
54
     * @throws MiddlewareException
55
     */
56
    public function appendClosure(string $overrideType, callable $middleware, ?string $name = null): self;
57
58
    /**
59
     * Prepends a new middleware class onto the beginning of the stack.
60
     *
61
     * @param callable    $middleware   The middleware to add to the stack.
62
     * @param string|null $name         A name for the middleware. Can be used with `pushBefore()` and `pushAfter()`.
63
     * @param string|null $overrideType Override our best guess for which stack to apply the middleware to. By default
64
     *                                  the appropriate stack will be determined by which
65
     *                                  `SimplePie\Middleware\*\*Interface` the middleware extends from. If the
66
     *                                  middleware is a closure, this parameter is required. If the appropriate stack
67
     *                                  cannot be determined, a `SimplePie\Exception\MiddlewareException` exception
68
     *                                  will be thrown.
69
     *
70
     * @throws MiddlewareException
71
     */
72
    public function prepend(callable $middleware, ?string $name = null, ?string $overrideType = null): self;
73
74
    /**
75
     * Prepends a new middleware closure onto the beginning of the stack.
76
     *
77
     * @param string|null $overrideType Override our best guess for which stack to apply the middleware to. By default
78
     *                                  the appropriate stack will be determined by which
79
     *                                  `SimplePie\Middleware\*\*Interface` the middleware extends from. If the
80
     *                                  middleware is a closure, this parameter is required. If the appropriate stack
81
     *                                  cannot be determined, a `SimplePie\Exception\MiddlewareException` exception
82
     *                                  will be thrown.
83
     * @param callable    $middleware   The middleware to add to the stack.
84
     * @param string|null $name         A name for the middleware. Can be used with `pushBefore()` and `pushAfter()`.
85
     *
86
     * @throws MiddlewareException
87
     */
88
    public function prependClosure(string $overrideType, callable $middleware, ?string $name = null): self;
89
90
    /**
91
     * Invokes the stack of middleware.
92
     *
93
     * @param string   $feedType       A valid _single_ feed type from `SimplePie\Enum\FeedType`. Since `FeedType::ALL`
94
     *                                 represents _multiple_ feed types, an exception will be thrown if it is used.
95
     * @param stdClass $feedRoot       The root of the feed. This will be written-to when the parsing middleware runs.
96
     * @param string   $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result
97
     *                                 of a call to `SimplePie\Util\Ns`.
98
     * @param DOMXPath $xpath          The `DOMXPath` object with this middleware's namespace alias applied.
99
     */
100
    public function invoke(string $feedType, stdClass $feedRoot, ?string $namespaceAlias, DOMXPath $xpath): void;
101
102
    /**
103
     * Collects all of the supported namespaces from the registered middleware.
104
     *
105
     * **NOTE:** Only significant for XML-based feed types.
106
     *
107
     * @param Ns $ns The XML namespace handler.
108
     */
109
    public function registerNamespaces(Ns $ns): void;
110
}
111