1 | <?php |
||
10 | class Signature extends Serializable implements SignatureInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var \GMP |
||
14 | */ |
||
15 | private $r; |
||
16 | |||
17 | /** |
||
18 | * @var \GMP |
||
19 | */ |
||
20 | private $s; |
||
21 | |||
22 | /** |
||
23 | * @var EcAdapter |
||
24 | */ |
||
25 | private $ecAdapter; |
||
26 | |||
27 | /** |
||
28 | * @param EcAdapter $ecAdapter |
||
29 | * @param \GMP $r |
||
30 | * @param \GMP $s |
||
31 | */ |
||
32 | 112 | public function __construct(EcAdapter $ecAdapter, \GMP $r, \GMP $s) |
|
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | 105 | public function getR() |
|
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | */ |
||
50 | 105 | public function getS() |
|
54 | |||
55 | /** |
||
56 | * @param Signature $signature |
||
57 | * @return bool |
||
58 | */ |
||
59 | 25 | public function doEquals(Signature $signature) |
|
60 | { |
||
61 | 25 | $math = $this->ecAdapter->getMath(); |
|
62 | 25 | return $math->equals($this->getR(), $signature->getR()) |
|
63 | 25 | && $math->equals($this->getS(), $signature->getS()); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param SignatureInterface $signature |
||
68 | * @return bool |
||
69 | */ |
||
70 | 25 | public function equals(SignatureInterface $signature) |
|
71 | { |
||
72 | /** @var Signature $signature */ |
||
73 | 25 | return $this->doEquals($signature); |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * @return \BitWasp\Buffertools\BufferInterface |
||
78 | */ |
||
79 | 2 | public function getBuffer() |
|
83 | } |
||
84 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: