Issues (76)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Runners/PHPUnit/SuiteLoader.php (18 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ParaTest\Runners\PHPUnit;
6
7
use ParaTest\Parser\NoClassInFileException;
8
use ParaTest\Parser\ParsedClass;
9
use ParaTest\Parser\ParsedFunction;
10
use ParaTest\Parser\ParsedObject;
11
use ParaTest\Parser\Parser;
12
13
class SuiteLoader
14
{
15
    /**
16
     * The collection of loaded files.
17
     *
18
     * @var array
19
     */
20
    protected $files = [];
21
22
    /**
23
     * The collection of parsed test classes.
24
     *
25
     * @var array
26
     */
27
    protected $loadedSuites = [];
28
29
    /**
30
     * @var Options
31
     */
32
    public $options;
33
34 25
    public function __construct(Options $options = null)
35
    {
36 25
        $this->options = $options;
37 25
    }
38
39
    /**
40
     * Returns all parsed suite objects as ExecutableTest
41
     * instances.
42
     *
43
     * @return array
44
     */
45 2
    public function getSuites(): array
46
    {
47 2
        return $this->loadedSuites;
48
    }
49
50
    /**
51
     * Returns a collection of TestMethod objects
52
     * for all loaded ExecutableTest instances.
53
     *
54
     * @return array
55
     */
56 3
    public function getTestMethods(): array
57
    {
58 3
        $methods = [];
59 3
        foreach ($this->loadedSuites as $suite) {
60 2
            $methods = array_merge($methods, $suite->getFunctions());
61
        }
62
63 3
        return $methods;
64
    }
65
66
    /**
67
     * Populates the loaded suite collection. Will load suites
68
     * based off a phpunit xml configuration or a specified path.
69
     *
70
     * @param string $path
71
     *
72
     * @throws \RuntimeException
73
     */
74 23
    public function load(string $path = '')
75
    {
76 23
        if (is_object($this->options) && isset($this->options->filtered['configuration'])) {
0 ignored issues
show
The property $filtered is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
77 16
            $configuration = $this->options->filtered['configuration'];
0 ignored issues
show
The property $filtered is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
78
        } else {
79 7
            $configuration = new Configuration('');
80
        }
81
82 23
        if ($path) {
83 9
            $testFileLoader = new TestFileLoader($this->options);
84 9
            $this->files = array_merge($this->files, $testFileLoader->loadPath($path));
85 14
        } elseif (isset($this->options->testsuite) && $this->options->testsuite) {
0 ignored issues
show
The property $testsuite is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
86 10
            foreach ($configuration->getSuiteByName($this->options->testsuite) as $suite) {
0 ignored issues
show
The property $testsuite is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
87 10
                foreach ($suite as $suitePath) {
88 10
                    $testFileLoader = new TestFileLoader($this->options);
89 10
                    $this->files = array_merge($this->files, $testFileLoader->loadSuitePath($suitePath));
90
                }
91
            }
92 4
        } elseif ($suites = $configuration->getSuites()) {
93 2
            foreach ($suites as $suite) {
94 2
                foreach ($suite as $suitePath) {
95 2
                    $testFileLoader = new TestFileLoader($this->options);
96 2
                    $this->files = array_merge($this->files, $testFileLoader->loadSuitePath($suitePath));
97
                }
98
            }
99
        }
100
101 21
        if (!$this->files) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->files of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
102 1
            throw new \RuntimeException('No path or configuration provided (tests must end with Test.php)');
103
        }
104
105 20
        $this->files = array_unique($this->files); // remove duplicates
106
107 20
        $this->initSuites();
108 20
    }
109
110
    /**
111
     * Called after all files are loaded. Parses loaded files into
112
     * ExecutableTest objects - either Suite or TestMethod.
113
     */
114 20
    private function initSuites()
115
    {
116 20
        foreach ($this->files as $path) {
117
            try {
118 20
                $parser = new Parser($path);
119 19
                if ($class = $parser->getClass()) {
0 ignored issues
show
Are you sure the assignment to $class is correct as $parser->getClass() (which targets ParaTest\Parser\Parser::getClass()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
120 19
                    $this->loadedSuites[$path] = $this->createSuite($path, $class);
121
                }
122 1
            } catch (NoClassInFileException $e) {
123 20
                continue;
124
            }
125
        }
126 20
    }
127
128 19
    private function executableTests(string $path, ParsedClass $class)
129
    {
130 19
        $executableTests = [];
131 19
        $methodBatches = $this->getMethodBatches($class);
132 19
        foreach ($methodBatches as $methodBatch) {
133 19
            $executableTest = new TestMethod($path, $methodBatch);
134 19
            $executableTests[] = $executableTest;
135
        }
136
137 19
        return $executableTests;
138
    }
139
140
    /**
141
     * Get method batches.
142
     *
143
     * Identify method dependencies, and group dependents and dependees on a single methodBatch.
144
     * Use max batch size to fill batches.
145
     *
146
     * @param ParsedClass $class
147
     *
148
     * @return array of MethodBatches. Each MethodBatch has an array of method names
149
     */
150 19
    private function getMethodBatches(ParsedClass $class): array
151
    {
152 19
        $classMethods = $class->getMethods($this->options ? $this->options->annotations : []);
0 ignored issues
show
The property $annotations is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
153 19
        $maxBatchSize = $this->options && $this->options->functional ? $this->options->maxBatchSize : 0;
0 ignored issues
show
The property $functional is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property $maxBatchSize is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
154 19
        $batches = [];
155 19
        foreach ($classMethods as $method) {
156 19
            $tests = $this->getMethodTests($class, $method, $maxBatchSize !== 0);
157
            // if filter passed to paratest then method tests can be blank if not match to filter
158 19
            if (!$tests) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $tests of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
159
                continue;
160
            }
161
162 19
            if (($dependsOn = $this->methodDependency($method)) !== null) {
163 1
                $this->addDependentTestsToBatchSet($batches, $dependsOn, $tests);
164
            } else {
165 19
                $this->addTestsToBatchSet($batches, $tests, $maxBatchSize);
166
            }
167
        }
168
169 19
        return $batches;
170
    }
171
172 1
    private function addDependentTestsToBatchSet(array &$batches, string $dependsOn, array $tests)
173
    {
174 1
        foreach ($batches as $key => $batch) {
175 1
            foreach ($batch as $methodName) {
176 1
                if ($dependsOn === $methodName) {
177 1
                    $batches[$key] = array_merge($batches[$key], $tests);
178 1
                    continue;
179
                }
180
            }
181
        }
182 1
    }
183
184 19
    private function addTestsToBatchSet(array &$batches, array $tests, int $maxBatchSize)
185
    {
186 19
        foreach ($tests as $test) {
187 19
            $lastIndex = count($batches) - 1;
188 19
            if ($lastIndex !== -1
189 19
                && count($batches[$lastIndex]) < $maxBatchSize
190
            ) {
191
                $batches[$lastIndex][] = $test;
192
            } else {
193 19
                $batches[] = [$test];
194
            }
195
        }
196 19
    }
197
198
    /**
199
     * Get method all available tests.
200
     *
201
     * With empty filter this method returns single test if doesnt' have data provider or
202
     * data provider is not used and return all test if has data provider and data provider is used.
203
     *
204
     * @param ParsedClass  $class           parsed class
205
     * @param ParsedObject $method          parsed method
206
     * @param bool         $useDataProvider try to use data provider or not
207
     *
208
     * @return string[] array of test names
209
     */
210 19
    private function getMethodTests(ParsedClass $class, ParsedFunction $method, bool $useDataProvider = false): array
211
    {
212 19
        $result = [];
213
214 19
        $groups = $this->methodGroups($method);
215
216 19
        $dataProvider = $this->methodDataProvider($method);
217 19
        if ($useDataProvider && isset($dataProvider)) {
218
            $testFullClassName = '\\' . $class->getName();
219
            $testClass = new $testFullClassName();
220
            $result = [];
221
            $datasetKeys = array_keys($testClass->$dataProvider());
222
            foreach ($datasetKeys as $key) {
223
                $test = sprintf(
224
                    '%s with data set %s',
225
                    $method->getName(),
226
                    is_int($key) ? '#' . $key : '"' . $key . '"'
227
                );
228
                if ($this->testMatchOptions($class->getName(), $test, $groups)) {
229
                    $result[] = $test;
230
                }
231
            }
232 19
        } elseif ($this->testMatchOptions($class->getName(), $method->getName(), $groups)) {
233 19
            $result = [$method->getName()];
234
        }
235
236 19
        return $result;
237
    }
238
239 19
    private function testMatchGroupOptions(array $groups): bool
240
    {
241 19
        if (empty($groups)) {
242 17
            return true;
243
        }
244
245 15
        if (!empty($this->options->groups)
0 ignored issues
show
The property $groups is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
246 15
            && !array_intersect($groups, $this->options->groups)
0 ignored issues
show
The property $groups is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
247
        ) {
248
            return false;
249
        }
250
251 15
        if (!empty($this->options->excludeGroups)
0 ignored issues
show
The property $excludeGroups is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
252 15
            && array_intersect($groups, $this->options->excludeGroups)
0 ignored issues
show
The property $excludeGroups is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
253
        ) {
254
            return false;
255
        }
256
257 15
        return true;
258
    }
259
260 19
    private function testMatchFilterOptions(string $className, string $name): bool
261
    {
262 19
        if (empty($this->options->filter)) {
0 ignored issues
show
The property $filter is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
263 19
            return true;
264
        }
265
266
        $re = substr($this->options->filter, 0, 1) === '/'
0 ignored issues
show
The property $filter is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
267
            ? $this->options->filter
0 ignored issues
show
The property $filter is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
268
            : '/' . $this->options->filter . '/';
0 ignored issues
show
The property $filter is declared protected in ParaTest\Runners\PHPUnit\Options. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
269
        $fullName = $className . '::' . $name;
270
271
        return 1 === preg_match($re, $fullName);
272
    }
273
274 19
    private function testMatchOptions(string $className, string $name, array $group): bool
275
    {
276 19
        $result = $this->testMatchGroupOptions($group)
277 19
                && $this->testMatchFilterOptions($className, $name);
278
279 19
        return $result;
280
    }
281
282 19
    private function methodDataProvider(ParsedFunction $method)
283
    {
284 19
        if (preg_match("/@\bdataProvider\b \b(.*)\b/", $method->getDocBlock(), $matches)) {
285
            return $matches[1];
286
        }
287 19
    }
288
289 19
    private function methodDependency(ParsedFunction $method)
290
    {
291 19
        if (preg_match("/@\bdepends\b \b(.*)\b/", $method->getDocBlock(), $matches)) {
292 1
            return $matches[1];
293
        }
294 19
    }
295
296 19
    private function methodGroups(ParsedFunction $method)
297
    {
298 19
        if (preg_match_all("/@\bgroup\b \b(.*)\b/", $method->getDocBlock(), $matches)) {
299 15
            return $matches[1];
300
        }
301
302 17
        return [];
303
    }
304
305 19
    private function createSuite(string $path, ParsedClass $class): Suite
306
    {
307 19
        return new Suite(
308 19
            $path,
309 19
            $this->executableTests(
310 19
                $path,
311 19
                $class
312
            ),
313 19
            $class->getName()
314
        );
315
    }
316
}
317