Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php

namespace ClassPreloader;

use Parser\AbstractNodeVisitor;

/**
 * Class loader configuration object
 */
class Config implements \IteratorAggregate
{
    /**
     * @var array Array of AbstractNodeVisitor objects that visit nodes
     */
    protected $visitors = array();

    /**
     * @var array Array of file names
     */
    protected $filenames = array();

    /**
     * @var array Array of exclusive filters
     */
    protected $exclusiveFilters = array();

    /**
     * @var array Array of inclusive filters
     */
    protected $inclusiveFilters = array();

    /**
     * Add the filename owned by the config
     *
     * @param string $filename File name
     *
     * @return self
     */
    public function addFile($filename)
    {
        $this->filenames[] = $filename;

        return $this;
    }

    /**
     * Get an array of file names that satisfy any added filters
     *
     * @return array
     */
    public function getFilenames()
    {
        $filenames = array();
        foreach ($this->filenames as $f) {
            foreach ($this->inclusiveFilters as $filter) {
                if (!preg_match($filter, $f)) {
                    continue 2;
                }
            }
            foreach ($this->exclusiveFilters as $filter) {
                if (preg_match($filter, $f)) {
                    continue 2;
                }
            }
            $filenames[] = $f;
        }

        return $filenames;
    }

    /**
     * Get an iterator for the filenames
     *
     * @return \ArrayIterator
     */
    public function getIterator()
    {
        return new \ArrayIterator($this->getFilenames());
    }

    /**
     * Add a filter used to filter out classes matching a specific pattern
     *
     * @param string $pattern Regular expression pattern
     *
     * @return self
     */
    public function addExclusiveFilter($pattern)
    {
        $this->exclusiveFilters[] = $pattern;

        return $this;
    }

    /**
     * Add a filter used to grab only file names matching the pattern
     *
     * @param string $pattern Regular expression pattern
     *
     * @return self
     */
    public function addInclusiveFilter($pattern)
    {
        $this->inclusiveFilters[] = $pattern;

        return $this;
    }

    /**
     * Add a visitor that will visit each node when traversing the node list
     * of each file.
     *
     * @param AbstractNodeVisitor $visitor Node visitor
     *
     * @return self
     */
    public function addVisitor(AbstractNodeVisitor $visitor)
    {
        $this->visitors[] = $visitor;

        return $this;
    }

    /**
     * Get an array of node visitors
     *
     * @return array
     */
    public function getVisitors()
    {
        return $this->visitors;
    }
}

Commits for Nextrek/Aiba_backup/vendor/classpreloader/classpreloader/src/ClassPreloader/Config.php

Diff revisions: vs.
Revision Author Commited Message
1464 MOliva picture MOliva Tue 13 Oct, 2020 11:16:56 +0000