Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Framework\Constraint;
11
 
12
use function sprintf;
13
use PHPUnit\Framework\Exception;
14
use ReflectionClass;
15
use ReflectionException;
16
 
17
/**
18
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
621 lars 19
 *
20
 * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
148 lars 21
 */
22
final class ClassHasStaticAttribute extends ClassHasAttribute
23
{
24
    /**
25
     * Returns a string representation of the constraint.
26
     */
27
    public function toString(): string
28
    {
29
        return sprintf(
30
            'has static attribute "%s"',
31
            $this->attributeName()
32
        );
33
    }
34
 
35
    /**
36
     * Evaluates the constraint for parameter $other. Returns true if the
37
     * constraint is met, false otherwise.
38
     *
39
     * @param mixed $other value or object to evaluate
40
     */
41
    protected function matches($other): bool
42
    {
43
        try {
44
            $class = new ReflectionClass($other);
45
 
46
            if ($class->hasProperty($this->attributeName())) {
47
                return $class->getProperty($this->attributeName())->isStatic();
48
            }
49
            // @codeCoverageIgnoreStart
50
        } catch (ReflectionException $e) {
51
            throw new Exception(
52
                $e->getMessage(),
53
                $e->getCode(),
54
                $e
55
            );
56
        }
57
        // @codeCoverageIgnoreEnd
58
 
59
        return false;
60
    }
61
}