-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent scanning interfaces and traits (#4)
Thanks a lot!
- Loading branch information
Showing
5 changed files
with
150 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* mapping (https://github.com/juliangut/mapping). | ||
* Mapping parsing base library. | ||
* | ||
* @license BSD-3-Clause | ||
* @link https://github.com/juliangut/mapping | ||
* @author Julián Gutiérrez <[email protected]> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jgut\Mapping\Tests\Driver; | ||
|
||
use Jgut\Mapping\Tests\Files\Classes\Valid\Attribute\ClassA; | ||
use Jgut\Mapping\Tests\Stubs\AbstractClassDriverStub; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class AbstractClassDriverTest extends TestCase | ||
{ | ||
public function testClassLoader(): void | ||
{ | ||
$driver = new AbstractClassDriverStub([__DIR__ . '/../Files/Classes/Valid/Attribute']); | ||
|
||
$className = $driver->loadClassFromFile(__DIR__ . '/../Files/Classes/Valid/Attribute/ClassA.php'); | ||
$traitName = $driver->loadClassFromFile(__DIR__ . '/../Files/Classes/Invalid/Attribute/Trait.php'); | ||
$interfaceName = $driver->loadClassFromFile(__DIR__ . '/../Files/Classes/Invalid/Attribute/Interface.php'); | ||
|
||
static::assertSame(ClassA::class, $className); | ||
static::assertNull($traitName); | ||
static::assertNull($interfaceName); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/Mapping/Files/Classes/Invalid/Attribute/Interface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* mapping (https://github.com/juliangut/mapping). | ||
* Mapping parsing base library. | ||
* | ||
* @license BSD-3-Clause | ||
* @link https://github.com/juliangut/mapping | ||
* @author Julián Gutiérrez <[email protected]> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jgut\Mapping\Tests\Files\Classes\Invalid\Attribute; | ||
|
||
interface InterfaceA | ||
{ | ||
public function methodA(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* mapping (https://github.com/juliangut/mapping). | ||
* Mapping parsing base library. | ||
* | ||
* @license BSD-3-Clause | ||
* @link https://github.com/juliangut/mapping | ||
* @author Julián Gutiérrez <[email protected]> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jgut\Mapping\Tests\Files\Classes\Invalid\Attribute; | ||
|
||
trait TraitA | ||
{ | ||
public function methodA(): void | ||
{ | ||
} | ||
|
||
public function methodB(): void | ||
{ | ||
$var = new class() {}; | ||
echo \get_class($var); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* mapping (https://github.com/juliangut/mapping). | ||
* Mapping parsing base library. | ||
* | ||
* @license BSD-3-Clause | ||
* @link https://github.com/juliangut/mapping | ||
* @author Julián Gutiérrez <[email protected]> | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jgut\Mapping\Tests\Stubs; | ||
|
||
use Jgut\Mapping\Driver\AbstractClassDriver; | ||
use Jgut\Mapping\Metadata\MetadataInterface; | ||
|
||
class AbstractClassDriverStub extends AbstractClassDriver | ||
{ | ||
/** | ||
* Get mapped metadata. | ||
* | ||
* @return array<MetadataInterface> | ||
*/ | ||
public function getMetadata(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function loadClassFromFile(string $mappingFile, bool $uselessVariable = true): ?string | ||
{ | ||
return parent::loadClassFromFile($mappingFile); | ||
} | ||
} |