Файловый менеджер - Редактировать - /home/avadvi5/calendar.aeronextgen.com/sebastian.zip
Ðазад
PK ,_�\��= = lines-of-code/README.mdnu �[��� [](https://packagist.org/packages/sebastian/lines-of-code) [](https://github.com/sebastianbergmann/lines-of-code/actions) [](https://shepherd.dev/github/sebastianbergmann/lines-of-code) [](https://codecov.io/gh/sebastianbergmann/lines-of-code) # sebastian/lines-of-code Library for counting the lines of code in PHP source code. ## Installation You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): ``` composer require sebastian/lines-of-code ``` If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency: ``` composer require --dev sebastian/lines-of-code ``` PK ,_�\�P@� � lines-of-code/LICENSEnu �[��� BSD 3-Clause License Copyright (c) 2020-2023, Sebastian Bergmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK ,_�\D�� � lines-of-code/ChangeLog.mdnu �[��� # ChangeLog All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. ## [2.0.2] - 2023-12-21 ### Changed * This component is now compatible with `nikic/php-parser` 5.0 ## [2.0.1] - 2023-08-31 ### Changed * Improved type information ## [2.0.0] - 2023-02-03 ### Removed * This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0 ## [1.0.3] - 2020-11-28 ### Fixed * Files that do not contain a newline were not handled correctly ### Changed * A line of code is no longer considered to be a Logical Line of Code if it does not contain an `Expr` node ## [1.0.2] - 2020-10-26 ### Fixed * `SebastianBergmann\LinesOfCode\Exception` now correctly extends `\Throwable` ## [1.0.1] - 2020-09-28 ### Changed * Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3` ## [1.0.0] - 2020-07-22 * Initial release [2.0.2]: https://github.com/sebastianbergmann/lines-of-code/compare/2.0.1...2.0.2 [2.0.1]: https://github.com/sebastianbergmann/lines-of-code/compare/2.0.0...2.0.1 [2.0.0]: https://github.com/sebastianbergmann/lines-of-code/compare/1.0.3...2.0.0 [1.0.3]: https://github.com/sebastianbergmann/lines-of-code/compare/1.0.2...1.0.3 [1.0.2]: https://github.com/sebastianbergmann/lines-of-code/compare/1.0.1...1.0.2 [1.0.1]: https://github.com/sebastianbergmann/lines-of-code/compare/1.0.0...1.0.1 [1.0.0]: https://github.com/sebastianbergmann/lines-of-code/compare/f959e71f00e591288acc024afe9cb966c6cf9bd6...1.0.0 PK ,_�\�V~ lines-of-code/src/error_lognu �[��� [10-Apr-2025 23:15:18 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [19-Apr-2025 17:10:34 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [22-Apr-2025 11:43:07 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [27-Apr-2025 15:52:11 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [30-Apr-2025 05:09:24 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [13-May-2025 06:44:52 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 [14-May-2025 00:22:41 UTC] PHP Fatal error: Uncaught Error: Class "PhpParser\NodeVisitorAbstract" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php:21 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/LineCountingVisitor.php on line 21 PK ,_�\,�b�� � % lines-of-code/src/Exception/error_lognu �[��� [13-Apr-2025 15:16:38 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [13-Apr-2025 20:14:14 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 [14-Apr-2025 01:16:38 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [21-Apr-2025 21:29:46 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [21-Apr-2025 21:53:56 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 [22-Apr-2025 03:26:25 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [24-Apr-2025 19:28:21 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [24-Apr-2025 19:47:46 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 [25-Apr-2025 05:54:16 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [30-Apr-2025 10:53:13 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 [30-Apr-2025 11:57:55 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 [30-Apr-2025 12:01:21 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [30-Apr-2025 12:06:35 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [30-Apr-2025 12:15:39 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [30-Apr-2025 17:45:11 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [13-May-2025 17:17:50 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/IllogicalValuesException.php on line 14 [13-May-2025 17:20:08 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/NegativeValueException.php on line 14 [13-May-2025 17:21:43 UTC] PHP Fatal error: Uncaught Error: Interface "SebastianBergmann\LinesOfCode\Exception" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/lines-of-code/src/Exception/RuntimeException.php on line 12 PK ,_�\�� � � 8 lines-of-code/src/Exception/IllogicalValuesException.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; use LogicException; final class IllogicalValuesException extends LogicException implements Exception { } PK ,_�\0�+q q ) lines-of-code/src/Exception/Exception.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; use Throwable; interface Exception extends Throwable { } PK ,_�\/� � � 0 lines-of-code/src/Exception/RuntimeException.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; final class RuntimeException extends \RuntimeException implements Exception { } PK ,_�\�y�<� � 6 lines-of-code/src/Exception/NegativeValueException.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; use InvalidArgumentException; final class NegativeValueException extends InvalidArgumentException implements Exception { } PK ,_�\�s��^ ^ ! lines-of-code/src/LinesOfCode.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; /** * @psalm-immutable */ final class LinesOfCode { /** * @psalm-var non-negative-int */ private readonly int $linesOfCode; /** * @psalm-var non-negative-int */ private readonly int $commentLinesOfCode; /** * @psalm-var non-negative-int */ private readonly int $nonCommentLinesOfCode; /** * @psalm-var non-negative-int */ private readonly int $logicalLinesOfCode; /** * @psalm-param non-negative-int $linesOfCode * @psalm-param non-negative-int $commentLinesOfCode * @psalm-param non-negative-int $nonCommentLinesOfCode * @psalm-param non-negative-int $logicalLinesOfCode * * @throws IllogicalValuesException * @throws NegativeValueException */ public function __construct(int $linesOfCode, int $commentLinesOfCode, int $nonCommentLinesOfCode, int $logicalLinesOfCode) { /** @psalm-suppress DocblockTypeContradiction */ if ($linesOfCode < 0) { throw new NegativeValueException('$linesOfCode must not be negative'); } /** @psalm-suppress DocblockTypeContradiction */ if ($commentLinesOfCode < 0) { throw new NegativeValueException('$commentLinesOfCode must not be negative'); } /** @psalm-suppress DocblockTypeContradiction */ if ($nonCommentLinesOfCode < 0) { throw new NegativeValueException('$nonCommentLinesOfCode must not be negative'); } /** @psalm-suppress DocblockTypeContradiction */ if ($logicalLinesOfCode < 0) { throw new NegativeValueException('$logicalLinesOfCode must not be negative'); } if ($linesOfCode - $commentLinesOfCode !== $nonCommentLinesOfCode) { throw new IllogicalValuesException('$linesOfCode !== $commentLinesOfCode + $nonCommentLinesOfCode'); } $this->linesOfCode = $linesOfCode; $this->commentLinesOfCode = $commentLinesOfCode; $this->nonCommentLinesOfCode = $nonCommentLinesOfCode; $this->logicalLinesOfCode = $logicalLinesOfCode; } /** * @psalm-return non-negative-int */ public function linesOfCode(): int { return $this->linesOfCode; } /** * @psalm-return non-negative-int */ public function commentLinesOfCode(): int { return $this->commentLinesOfCode; } /** * @psalm-return non-negative-int */ public function nonCommentLinesOfCode(): int { return $this->nonCommentLinesOfCode; } /** * @psalm-return non-negative-int */ public function logicalLinesOfCode(): int { return $this->logicalLinesOfCode; } public function plus(self $other): self { return new self( $this->linesOfCode() + $other->linesOfCode(), $this->commentLinesOfCode() + $other->commentLinesOfCode(), $this->nonCommentLinesOfCode() + $other->nonCommentLinesOfCode(), $this->logicalLinesOfCode() + $other->logicalLinesOfCode(), ); } } PK ,_�\kJM� ) lines-of-code/src/LineCountingVisitor.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; use function array_merge; use function array_unique; use function assert; use function count; use PhpParser\Comment; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\NodeVisitorAbstract; final class LineCountingVisitor extends NodeVisitorAbstract { /** * @psalm-var non-negative-int */ private readonly int $linesOfCode; /** * @var Comment[] */ private array $comments = []; /** * @var int[] */ private array $linesWithStatements = []; /** * @psalm-param non-negative-int $linesOfCode */ public function __construct(int $linesOfCode) { $this->linesOfCode = $linesOfCode; } public function enterNode(Node $node): void { $this->comments = array_merge($this->comments, $node->getComments()); if (!$node instanceof Expr) { return; } $this->linesWithStatements[] = $node->getStartLine(); } public function result(): LinesOfCode { $commentLinesOfCode = 0; foreach ($this->comments() as $comment) { $commentLinesOfCode += ($comment->getEndLine() - $comment->getStartLine() + 1); } $nonCommentLinesOfCode = $this->linesOfCode - $commentLinesOfCode; $logicalLinesOfCode = count(array_unique($this->linesWithStatements)); assert($commentLinesOfCode >= 0); assert($nonCommentLinesOfCode >= 0); assert($logicalLinesOfCode >= 0); return new LinesOfCode( $this->linesOfCode, $commentLinesOfCode, $nonCommentLinesOfCode, $logicalLinesOfCode, ); } /** * @return Comment[] */ private function comments(): array { $comments = []; foreach ($this->comments as $comment) { $comments[$comment->getStartLine() . '_' . $comment->getStartTokenPos() . '_' . $comment->getEndLine() . '_' . $comment->getEndTokenPos()] = $comment; } return $comments; } } PK ,_�\i辪 lines-of-code/src/Counter.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/lines-of-code. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\LinesOfCode; use function assert; use function file_get_contents; use function substr_count; use PhpParser\Error; use PhpParser\Node; use PhpParser\NodeTraverser; use PhpParser\ParserFactory; final class Counter { /** * @throws RuntimeException */ public function countInSourceFile(string $sourceFile): LinesOfCode { return $this->countInSourceString(file_get_contents($sourceFile)); } /** * @throws RuntimeException */ public function countInSourceString(string $source): LinesOfCode { $linesOfCode = substr_count($source, "\n"); if ($linesOfCode === 0 && !empty($source)) { $linesOfCode = 1; } assert($linesOfCode >= 0); try { $nodes = (new ParserFactory)->createForHostVersion()->parse($source); assert($nodes !== null); return $this->countInAbstractSyntaxTree($linesOfCode, $nodes); // @codeCoverageIgnoreStart } catch (Error $error) { throw new RuntimeException( $error->getMessage(), $error->getCode(), $error, ); } // @codeCoverageIgnoreEnd } /** * @psalm-param non-negative-int $linesOfCode * * @param Node[] $nodes * * @throws RuntimeException */ public function countInAbstractSyntaxTree(int $linesOfCode, array $nodes): LinesOfCode { $traverser = new NodeTraverser; $visitor = new LineCountingVisitor($linesOfCode); $traverser->addVisitor($visitor); try { /* @noinspection UnusedFunctionResultInspection */ $traverser->traverse($nodes); // @codeCoverageIgnoreStart } catch (Error $error) { throw new RuntimeException( $error->getMessage(), $error->getCode(), $error, ); } // @codeCoverageIgnoreEnd return $visitor->result(); } } PK ,_�\�w�F F lines-of-code/composer.jsonnu �[��� { "name": "sebastian/lines-of-code", "description": "Library for counting the lines of code in PHP source code", "type": "library", "homepage": "https://github.com/sebastianbergmann/lines-of-code", "license": "BSD-3-Clause", "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", "role": "lead" } ], "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy" }, "prefer-stable": true, "require": { "php": ">=8.1", "nikic/php-parser": "^4.18 || ^5.0" }, "require-dev": { "phpunit/phpunit": "^10.0" }, "config": { "platform": { "php": "8.1" }, "optimize-autoloader": true, "sort-packages": true }, "autoload": { "classmap": [ "src/" ] }, "extra": { "branch-alias": { "dev-main": "2.0-dev" } } } PK ,_�\KJ�u u lines-of-code/SECURITY.mdnu �[��� # Security Policy If you believe you have found a security vulnerability in the library that is developed in this repository, please report it to us through coordinated disclosure. **Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.** Instead, please email `sebastian@phpunit.de`. Please include as much of the information listed below as you can to help us better understand and resolve the issue: * The type of issue * Full paths of source file(s) related to the manifestation of the issue * The location of the affected source code (tag/branch/commit or direct URL) * Any special configuration required to reproduce the issue * Step-by-step instructions to reproduce the issue * Proof-of-concept or exploit code (if possible) * Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. ## Web Context The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit. The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in an HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes. If the library is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context. Vulnerabilities specific to the use outside a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes. PK ,_�\��� � � type/infection.jsonnu �[��� { "source": { "directories": [ "src" ] }, "mutators": { "@default": true }, "minMsi": 100, "minCoveredMsi": 100 } PK ,_�\M˳� � type/README.mdnu �[��� [](https://packagist.org/packages/sebastian/type) [](https://github.com/sebastianbergmann/type/actions) [](https://shepherd.dev/github/sebastianbergmann/type) [](https://codecov.io/gh/sebastianbergmann/type) # sebastian/type Collection of value objects that represent the types of the PHP type system. ## Installation You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): ``` composer require sebastian/type ``` If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency: ``` composer require --dev sebastian/type ``` PK ,_�\�� � type/LICENSEnu �[��� BSD 3-Clause License Copyright (c) 2019-2023, Sebastian Bergmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK ,_�\��y� � type/ChangeLog.mdnu �[��� # ChangeLog All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## [4.0.0] - 2023-02-03 ### Removed * This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0 ## [3.2.1] - 2023-02-03 ### Fixed * [#28](https://github.com/sebastianbergmann/type/pull/28): Potential undefined offset warning/notice ## [3.2.0] - 2022-09-12 ### Added * [#25](https://github.com/sebastianbergmann/type/issues/25): Support Disjunctive Normal Form types * Added `ReflectionMapper::fromParameterTypes()` * Added `IntersectionType::types()` and `UnionType::types()` * Added `UnionType::containsIntersectionTypes()` ## [3.1.0] - 2022-08-29 ### Added * [#21](https://github.com/sebastianbergmann/type/issues/21): Support `true` as stand-alone type ## [3.0.0] - 2022-03-15 ### Added * Support for intersection types introduced in PHP 8.1 * Support for the `never` return type introduced in PHP 8.1 * Added `Type::isCallable()`, `Type::isGenericObject()`, `Type::isIterable()`, `Type::isMixed()`, `Type::isNever()`, `Type::isNull()`, `Type::isObject()`, `Type::isSimple()`, `Type::isStatic()`, `Type::isUnion()`, `Type::isUnknown()`, and `Type::isVoid()` ### Changed * Renamed `ReflectionMapper::fromMethodReturnType(ReflectionMethod $method)` to `ReflectionMapper::fromReturnType(ReflectionFunctionAbstract $functionOrMethod)` ### Removed * Removed `Type::getReturnTypeDeclaration()` (use `Type::asString()` instead and prefix its result with `': '`) * Removed `TypeName::getNamespaceName()` (use `TypeName::namespaceName()` instead) * Removed `TypeName::getSimpleName()` (use `TypeName::simpleName()` instead) * Removed `TypeName::getQualifiedName()` (use `TypeName::qualifiedName()` instead) ## [2.3.4] - 2021-06-15 ### Fixed * Fixed regression introduced in 2.3.3 ## [2.3.3] - 2021-06-15 [YANKED] ### Fixed * [#15](https://github.com/sebastianbergmann/type/issues/15): "false" pseudo type is not handled properly ## [2.3.2] - 2021-06-04 ### Fixed * Fixed handling of tentatively declared return types ## [2.3.1] - 2020-10-26 ### Fixed * `SebastianBergmann\Type\Exception` now correctly extends `\Throwable` ## [2.3.0] - 2020-10-06 ### Added * [#14](https://github.com/sebastianbergmann/type/issues/14): Support for `static` return type that is introduced in PHP 8 ## [2.2.2] - 2020-09-28 ### Changed * Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3` ## [2.2.1] - 2020-07-05 ### Fixed * Fixed handling of `mixed` type in `ReflectionMapper::fromMethodReturnType()` ## [2.2.0] - 2020-07-05 ### Added * Added `MixedType` object for representing PHP 8's `mixed` type ## [2.1.1] - 2020-06-26 ### Added * This component is now supported on PHP 8 ## [2.1.0] - 2020-06-01 ### Added * Added `UnionType` object for representing PHP 8's Union Types * Added `ReflectionMapper::fromMethodReturnType()` for mapping `\ReflectionMethod::getReturnType()` to a `Type` object * Added `Type::name()` for retrieving the name of a type * Added `Type::asString()` for retrieving a textual representation of a type ### Changed * Deprecated `Type::getReturnTypeDeclaration()` (use `Type::asString()` instead and prefix its result with `': '`) * Deprecated `TypeName::getNamespaceName()` (use `TypeName::namespaceName()` instead) * Deprecated `TypeName::getSimpleName()` (use `TypeName::simpleName()` instead) * Deprecated `TypeName::getQualifiedName()` (use `TypeName::qualifiedName()` instead) ## [2.0.0] - 2020-02-07 ### Removed * This component is no longer supported on PHP 7.2 ## [1.1.3] - 2019-07-02 ### Fixed * Fixed class name comparison in `ObjectType` to be case-insensitive ## [1.1.2] - 2019-06-19 ### Fixed * Fixed handling of `object` type ## [1.1.1] - 2019-06-08 ### Fixed * Fixed autoloading of `callback_function.php` fixture file ## [1.1.0] - 2019-06-07 ### Added * Added support for `callable` type * Added support for `iterable` type ## [1.0.0] - 2019-06-06 * Initial release based on [code contributed by Michel Hartmann to PHPUnit](https://github.com/sebastianbergmann/phpunit/pull/3673) [4.0.0]: https://github.com/sebastianbergmann/type/compare/3.2.1...4.0.0 [3.2.1]: https://github.com/sebastianbergmann/type/compare/3.2.0...3.2.1 [3.2.0]: https://github.com/sebastianbergmann/type/compare/3.1.0...3.2.0 [3.1.0]: https://github.com/sebastianbergmann/type/compare/3.0.0...3.1.0 [3.0.0]: https://github.com/sebastianbergmann/type/compare/2.3.4...3.0.0 [2.3.4]: https://github.com/sebastianbergmann/type/compare/ca39369c41313ed12c071ed38ecda8fcdb248859...2.3.4 [2.3.3]: https://github.com/sebastianbergmann/type/compare/2.3.2...ca39369c41313ed12c071ed38ecda8fcdb248859 [2.3.2]: https://github.com/sebastianbergmann/type/compare/2.3.1...2.3.2 [2.3.1]: https://github.com/sebastianbergmann/type/compare/2.3.0...2.3.1 [2.3.0]: https://github.com/sebastianbergmann/type/compare/2.2.2...2.3.0 [2.2.2]: https://github.com/sebastianbergmann/type/compare/2.2.1...2.2.2 [2.2.1]: https://github.com/sebastianbergmann/type/compare/2.2.0...2.2.1 [2.2.0]: https://github.com/sebastianbergmann/type/compare/2.1.1...2.2.0 [2.1.1]: https://github.com/sebastianbergmann/type/compare/2.1.0...2.1.1 [2.1.0]: https://github.com/sebastianbergmann/type/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/sebastianbergmann/type/compare/1.1.3...2.0.0 [1.1.3]: https://github.com/sebastianbergmann/type/compare/1.1.2...1.1.3 [1.1.2]: https://github.com/sebastianbergmann/type/compare/1.1.1...1.1.2 [1.1.1]: https://github.com/sebastianbergmann/type/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/sebastianbergmann/type/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/sebastianbergmann/type/compare/ff74aa41746bd8d10e931843ebf37d42da513ede...1.0.0 PK ,_�\���� � type/src/type/VoidType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class VoidType extends Type { public function isAssignable(Type $other): bool { return $other instanceof self; } public function name(): string { return 'void'; } public function allowsNull(): bool { return false; } /** * @psalm-assert-if-true VoidType $this */ public function isVoid(): bool { return true; } } PK ,_�\��c type/src/type/error_lognu �[��� [13-May-2025 18:20:37 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/CallableType.php:25 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/CallableType.php on line 25 [13-May-2025 18:20:59 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/NeverType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/NeverType.php on line 12 [13-May-2025 18:21:10 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/MixedType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/MixedType.php on line 12 [13-May-2025 18:21:12 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/SimpleType.php:14 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/SimpleType.php on line 14 [13-May-2025 18:21:29 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/StaticType.php:15 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/StaticType.php on line 15 [13-May-2025 18:21:32 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/GenericObjectType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/GenericObjectType.php on line 12 [13-May-2025 18:21:33 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/TrueType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/TrueType.php on line 12 [13-May-2025 18:21:43 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/UnionType.php:16 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/UnionType.php on line 16 [13-May-2025 18:21:50 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/IterableType.php:17 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/IterableType.php on line 17 [13-May-2025 18:21:51 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/VoidType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/VoidType.php on line 12 [13-May-2025 18:21:55 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/FalseType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/FalseType.php on line 12 [13-May-2025 18:22:00 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/ObjectType.php:15 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/ObjectType.php on line 15 [13-May-2025 18:22:03 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/UnknownType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/UnknownType.php on line 12 [13-May-2025 18:22:15 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/IntersectionType.php:18 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/IntersectionType.php on line 18 [13-May-2025 18:22:19 UTC] PHP Fatal error: Uncaught Error: Class "SebastianBergmann\Type\Type" not found in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/NullType.php:12 Stack trace: #0 {main} thrown in /home/avadvi5/calendar.aeronextgen.com/davis/vendor/sebastian/type/src/type/NullType.php on line 12 PK ,_�\@��5 # type/src/type/GenericObjectType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class GenericObjectType extends Type { private bool $allowsNull; public function __construct(bool $nullable) { $this->allowsNull = $nullable; } public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if (!$other instanceof ObjectType) { return false; } return true; } public function name(): string { return 'object'; } public function allowsNull(): bool { return $this->allowsNull; } /** * @psalm-assert-if-true GenericObjectType $this */ public function isGenericObject(): bool { return true; } } PK ,_�\2A�� � type/src/type/IterableType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function assert; use function class_exists; use function is_iterable; use ReflectionClass; final class IterableType extends Type { private bool $allowsNull; public function __construct(bool $nullable) { $this->allowsNull = $nullable; } /** * @throws RuntimeException */ public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if ($other instanceof self) { return true; } if ($other instanceof SimpleType) { return is_iterable($other->value()); } if ($other instanceof ObjectType) { $className = $other->className()->qualifiedName(); assert(class_exists($className)); return (new ReflectionClass($className))->isIterable(); } return false; } public function name(): string { return 'iterable'; } public function allowsNull(): bool { return $this->allowsNull; } /** * @psalm-assert-if-true IterableType $this */ public function isIterable(): bool { return true; } } PK ,_�\����6 6 type/src/type/SimpleType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function strtolower; final class SimpleType extends Type { private string $name; private bool $allowsNull; private mixed $value; public function __construct(string $name, bool $nullable, mixed $value = null) { $this->name = $this->normalize($name); $this->allowsNull = $nullable; $this->value = $value; } public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if ($this->name === 'bool' && $other->name() === 'true') { return true; } if ($this->name === 'bool' && $other->name() === 'false') { return true; } if ($other instanceof self) { return $this->name === $other->name; } return false; } public function name(): string { return $this->name; } public function allowsNull(): bool { return $this->allowsNull; } public function value(): mixed { return $this->value; } /** * @psalm-assert-if-true SimpleType $this */ public function isSimple(): bool { return true; } private function normalize(string $name): string { $name = strtolower($name); return match ($name) { 'boolean' => 'bool', 'real', 'double' => 'float', 'integer' => 'int', '[]' => 'array', default => $name, }; } } PK ,_�\P�^+� � type/src/type/Type.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function gettype; use function strtolower; abstract class Type { public static function fromValue(mixed $value, bool $allowsNull): self { if ($allowsNull === false) { if ($value === true) { return new TrueType; } if ($value === false) { return new FalseType; } } $typeName = gettype($value); if ($typeName === 'object') { return new ObjectType(TypeName::fromQualifiedName($value::class), $allowsNull); } $type = self::fromName($typeName, $allowsNull); if ($type instanceof SimpleType) { $type = new SimpleType($typeName, $allowsNull, $value); } return $type; } public static function fromName(string $typeName, bool $allowsNull): self { return match (strtolower($typeName)) { 'callable' => new CallableType($allowsNull), 'true' => new TrueType, 'false' => new FalseType, 'iterable' => new IterableType($allowsNull), 'never' => new NeverType, 'null' => new NullType, 'object' => new GenericObjectType($allowsNull), 'unknown type' => new UnknownType, 'void' => new VoidType, 'array', 'bool', 'boolean', 'double', 'float', 'int', 'integer', 'real', 'resource', 'resource (closed)', 'string' => new SimpleType($typeName, $allowsNull), 'mixed' => new MixedType, default => new ObjectType(TypeName::fromQualifiedName($typeName), $allowsNull), }; } public function asString(): string { return ($this->allowsNull() ? '?' : '') . $this->name(); } /** * @psalm-assert-if-true CallableType $this */ public function isCallable(): bool { return false; } /** * @psalm-assert-if-true TrueType $this */ public function isTrue(): bool { return false; } /** * @psalm-assert-if-true FalseType $this */ public function isFalse(): bool { return false; } /** * @psalm-assert-if-true GenericObjectType $this */ public function isGenericObject(): bool { return false; } /** * @psalm-assert-if-true IntersectionType $this */ public function isIntersection(): bool { return false; } /** * @psalm-assert-if-true IterableType $this */ public function isIterable(): bool { return false; } /** * @psalm-assert-if-true MixedType $this */ public function isMixed(): bool { return false; } /** * @psalm-assert-if-true NeverType $this */ public function isNever(): bool { return false; } /** * @psalm-assert-if-true NullType $this */ public function isNull(): bool { return false; } /** * @psalm-assert-if-true ObjectType $this */ public function isObject(): bool { return false; } /** * @psalm-assert-if-true SimpleType $this */ public function isSimple(): bool { return false; } /** * @psalm-assert-if-true StaticType $this */ public function isStatic(): bool { return false; } /** * @psalm-assert-if-true UnionType $this */ public function isUnion(): bool { return false; } /** * @psalm-assert-if-true UnknownType $this */ public function isUnknown(): bool { return false; } /** * @psalm-assert-if-true VoidType $this */ public function isVoid(): bool { return false; } abstract public function isAssignable(self $other): bool; abstract public function name(): string; abstract public function allowsNull(): bool; } PK ,_�\-{� type/src/type/ObjectType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function is_subclass_of; use function strcasecmp; final class ObjectType extends Type { private TypeName $className; private bool $allowsNull; public function __construct(TypeName $className, bool $allowsNull) { $this->className = $className; $this->allowsNull = $allowsNull; } public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if ($other instanceof self) { if (0 === strcasecmp($this->className->qualifiedName(), $other->className->qualifiedName())) { return true; } if (is_subclass_of($other->className->qualifiedName(), $this->className->qualifiedName(), true)) { return true; } } return false; } public function name(): string { return $this->className->qualifiedName(); } public function allowsNull(): bool { return $this->allowsNull; } public function className(): TypeName { return $this->className; } /** * @psalm-assert-if-true ObjectType $this */ public function isObject(): bool { return true; } } PK ,_�\/�_�� � type/src/type/CallableType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function assert; use function class_exists; use function count; use function explode; use function function_exists; use function is_array; use function is_object; use function is_string; use function str_contains; use Closure; use ReflectionClass; use ReflectionObject; final class CallableType extends Type { private bool $allowsNull; public function __construct(bool $nullable) { $this->allowsNull = $nullable; } public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if ($other instanceof self) { return true; } if ($other instanceof ObjectType) { if ($this->isClosure($other)) { return true; } if ($this->hasInvokeMethod($other)) { return true; } } if ($other instanceof SimpleType) { if ($this->isFunction($other)) { return true; } if ($this->isClassCallback($other)) { return true; } if ($this->isObjectCallback($other)) { return true; } } return false; } public function name(): string { return 'callable'; } public function allowsNull(): bool { return $this->allowsNull; } /** * @psalm-assert-if-true CallableType $this */ public function isCallable(): bool { return true; } private function isClosure(ObjectType $type): bool { return $type->className()->qualifiedName() === Closure::class; } private function hasInvokeMethod(ObjectType $type): bool { $className = $type->className()->qualifiedName(); assert(class_exists($className)); return (new ReflectionClass($className))->hasMethod('__invoke'); } private function isFunction(SimpleType $type): bool { if (!is_string($type->value())) { return false; } return function_exists($type->value()); } private function isObjectCallback(SimpleType $type): bool { if (!is_array($type->value())) { return false; } if (count($type->value()) !== 2) { return false; } if (!isset($type->value()[0], $type->value()[1])) { return false; } if (!is_object($type->value()[0]) || !is_string($type->value()[1])) { return false; } [$object, $methodName] = $type->value(); return (new ReflectionObject($object))->hasMethod($methodName); } private function isClassCallback(SimpleType $type): bool { if (!is_string($type->value()) && !is_array($type->value())) { return false; } if (is_string($type->value())) { if (!str_contains($type->value(), '::')) { return false; } [$className, $methodName] = explode('::', $type->value()); } if (is_array($type->value())) { if (count($type->value()) !== 2) { return false; } if (!isset($type->value()[0], $type->value()[1])) { return false; } if (!is_string($type->value()[0]) || !is_string($type->value()[1])) { return false; } [$className, $methodName] = $type->value(); } assert(isset($className) && is_string($className)); assert(isset($methodName) && is_string($methodName)); if (!class_exists($className)) { return false; } $class = new ReflectionClass($className); if (!$class->hasMethod($methodName)) { return false; } $method = $class->getMethod($methodName); return $method->isPublic() && $method->isStatic(); } } PK ,_�\��� � � type/src/type/NeverType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class NeverType extends Type { public function isAssignable(Type $other): bool { return $other instanceof self; } public function name(): string { return 'never'; } public function allowsNull(): bool { return false; } /** * @psalm-assert-if-true NeverType $this */ public function isNever(): bool { return true; } } PK ,_�\�?�� type/src/type/UnknownType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class UnknownType extends Type { public function isAssignable(Type $other): bool { return true; } public function name(): string { return 'unknown type'; } public function asString(): string { return ''; } public function allowsNull(): bool { return true; } /** * @psalm-assert-if-true UnknownType $this */ public function isUnknown(): bool { return true; } } PK ,_�\L�/� type/src/type/MixedType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class MixedType extends Type { public function isAssignable(Type $other): bool { return !$other instanceof VoidType; } public function asString(): string { return 'mixed'; } public function name(): string { return 'mixed'; } public function allowsNull(): bool { return true; } /** * @psalm-assert-if-true MixedType $this */ public function isMixed(): bool { return true; } } PK ,_�\�V�!p p type/src/type/FalseType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class FalseType extends Type { public function isAssignable(Type $other): bool { if ($other instanceof self) { return true; } return $other instanceof SimpleType && $other->name() === 'bool' && $other->value() === false; } public function name(): string { return 'false'; } public function allowsNull(): bool { return false; } /** * @psalm-assert-if-true FalseType $this */ public function isFalse(): bool { return true; } } PK ,_�\���k k type/src/type/TrueType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class TrueType extends Type { public function isAssignable(Type $other): bool { if ($other instanceof self) { return true; } return $other instanceof SimpleType && $other->name() === 'bool' && $other->value() === true; } public function name(): string { return 'true'; } public function allowsNull(): bool { return false; } /** * @psalm-assert-if-true TrueType $this */ public function isTrue(): bool { return true; } } PK ,_�\ӆ�s� � type/src/type/StaticType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; use function is_subclass_of; use function strcasecmp; final class StaticType extends Type { private TypeName $className; private bool $allowsNull; public function __construct(TypeName $className, bool $allowsNull) { $this->className = $className; $this->allowsNull = $allowsNull; } public function isAssignable(Type $other): bool { if ($this->allowsNull && $other instanceof NullType) { return true; } if (!$other instanceof ObjectType) { return false; } if (0 === strcasecmp($this->className->qualifiedName(), $other->className()->qualifiedName())) { return true; } if (is_subclass_of($other->className()->qualifiedName(), $this->className->qualifiedName(), true)) { return true; } return false; } public function name(): string { return 'static'; } public function allowsNull(): bool { return $this->allowsNull; } /** * @psalm-assert-if-true StaticType $this */ public function isStatic(): bool { return true; } } PK ,_�\o|� type/src/type/NullType.phpnu �[��� <?php declare(strict_types=1); /* * This file is part of sebastian/type. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Type; final class NullType extends Type { public function isAssignable(Type $other): bool { return !($other instanceof VoidType); } public function name(): string { return 'null'; } public function asString(): string { return 'null'; } public function allowsNull(): bool { return true; } /** * @psalm-assert-if-true NullType $this */ public function isNull(): bool { return true; } } PK ,_�\�<�� � "