-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on value objects for #519
- Loading branch information
1 parent
f7f0803
commit a877448
Showing
11 changed files
with
686 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class Class_ extends Target | ||
{ | ||
/** | ||
* @var class-string | ||
*/ | ||
private string $className; | ||
|
||
/** | ||
* @param class-string $className | ||
*/ | ||
protected function __construct(string $className) | ||
{ | ||
$this->className = $className; | ||
} | ||
|
||
public function isClass(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function className(): string | ||
{ | ||
return $this->className; | ||
} | ||
} |
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,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class ClassesThatExtendClass extends Target | ||
{ | ||
/** | ||
* @var class-string | ||
*/ | ||
private string $className; | ||
|
||
/** | ||
* @param class-string $className | ||
*/ | ||
protected function __construct(string $className) | ||
{ | ||
$this->className = $className; | ||
} | ||
|
||
public function isClassesThatExtendClass(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function className(): string | ||
{ | ||
return $this->className; | ||
} | ||
} |
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,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class ClassesThatImplementInterface extends Target | ||
{ | ||
/** | ||
* @var class-string | ||
*/ | ||
private string $interfaceName; | ||
|
||
/** | ||
* @param class-string $interfaceName | ||
*/ | ||
protected function __construct(string $interfaceName) | ||
{ | ||
$this->interfaceName = $interfaceName; | ||
} | ||
|
||
public function isClassesThatImplementInterface(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function interfaceName(): string | ||
{ | ||
return $this->interfaceName; | ||
} | ||
} |
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,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class Function_ extends Target | ||
{ | ||
/** | ||
* @var non-empty-string | ||
*/ | ||
private string $functionName; | ||
|
||
/** | ||
* @param non-empty-string $functionName | ||
*/ | ||
protected function __construct(string $functionName) | ||
{ | ||
$this->functionName = $functionName; | ||
} | ||
|
||
public function isFunction(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
*/ | ||
public function functionName(): string | ||
{ | ||
return $this->functionName; | ||
} | ||
} |
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,59 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class Method extends Target | ||
{ | ||
/** | ||
* @var class-string | ||
*/ | ||
private string $className; | ||
|
||
/** | ||
* @var non-empty-string | ||
*/ | ||
private string $methodName; | ||
|
||
/** | ||
* @param class-string $className | ||
* @param non-empty-string $methodName | ||
*/ | ||
protected function __construct(string $className, string $methodName) | ||
{ | ||
$this->className = $className; | ||
$this->methodName = $methodName; | ||
} | ||
|
||
public function isMethod(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function className(): string | ||
{ | ||
return $this->className; | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
*/ | ||
public function methodName(): string | ||
{ | ||
return $this->methodName; | ||
} | ||
} |
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,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
final class Namespace_ extends Target | ||
{ | ||
/** | ||
* @var non-empty-string | ||
*/ | ||
private string $namespace; | ||
|
||
/** | ||
* @param non-empty-string $namespace | ||
*/ | ||
protected function __construct(string $namespace) | ||
{ | ||
$this->namespace = $namespace; | ||
} | ||
|
||
public function isNamespace(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
*/ | ||
public function namespace(): string | ||
{ | ||
return $this->namespace; | ||
} | ||
} |
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,97 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of phpunit/php-code-coverage. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace SebastianBergmann\CodeCoverage\Test\Target; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage | ||
*/ | ||
abstract class Target | ||
{ | ||
/** | ||
* @param non-empty-string $namespace | ||
*/ | ||
public static function forNamespace(string $namespace): Namespace_ | ||
{ | ||
return new Namespace_($namespace); | ||
} | ||
|
||
/** | ||
* @param class-string $className | ||
*/ | ||
public static function forClass(string $className): Class_ | ||
{ | ||
return new Class_($className); | ||
} | ||
|
||
/** | ||
* @param class-string $className | ||
* @param non-empty-string $methodName | ||
*/ | ||
public static function forMethod(string $className, string $methodName): Method | ||
{ | ||
return new Method($className, $methodName); | ||
} | ||
|
||
/** | ||
* @param class-string $interfaceName | ||
*/ | ||
public static function forClassesThatImplementInterface(string $interfaceName): ClassesThatImplementInterface | ||
{ | ||
return new ClassesThatImplementInterface($interfaceName); | ||
} | ||
|
||
/** | ||
* @param class-string $className | ||
*/ | ||
public static function forClassesThatExtendClass(string $className): ClassesThatExtendClass | ||
{ | ||
return new ClassesThatExtendClass($className); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $functionName | ||
*/ | ||
public static function forFunction(string $functionName): Function_ | ||
{ | ||
return new Function_($functionName); | ||
} | ||
|
||
public function isNamespace(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function isClass(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function isMethod(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function isClassesThatImplementInterface(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function isClassesThatExtendClass(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function isFunction(): bool | ||
{ | ||
return false; | ||
} | ||
} |
Oops, something went wrong.