Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | 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\MockObject;
11
 
12
use SebastianBergmann\Type\Type;
13
 
14
/**
15
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
16
 */
17
final class ConfigurableMethod
18
{
19
    /**
20
     * @var string
21
     */
22
    private $name;
23
 
24
    /**
25
     * @var Type
26
     */
27
    private $returnType;
28
 
29
    public function __construct(string $name, Type $returnType)
30
    {
31
        $this->name       = $name;
32
        $this->returnType = $returnType;
33
    }
34
 
35
    public function getName(): string
36
    {
37
        return $this->name;
38
    }
39
 
40
    public function mayReturn($value): bool
41
    {
42
        if ($value === null && $this->returnType->allowsNull()) {
43
            return true;
44
        }
45
 
46
        return $this->returnType->isAssignable(Type::fromValue($value, false));
47
    }
48
 
49
    public function getReturnTypeDeclaration(): string
50
    {
51
        return $this->returnType->asString();
52
    }
53
}