Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable IntersectionType error #1327

Closed
puniserv opened this issue Dec 21, 2023 · 2 comments
Closed

Nullable IntersectionType error #1327

puniserv opened this issue Dec 21, 2023 · 2 comments

Comments

@puniserv
Copy link

puniserv commented Dec 21, 2023

<?php

declare(strict_types=1);


use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class FooTest extends TestCase
{
    private (MockObject&DateTime)|null $mock = null;

    public function test()
    {
        self::assertNotSame(1,$this->getDateTimeMock());
    }

    private function getDateTimeMock(): DateTime&MockObject
    {
        return $this->mock ??= $this->createMock(DateTime::class);
    }
}

Fatal error: Uncaught TypeError: Qossmic\Deptrac\Core\Ast\Parser\TypeResolver::Qossmic\Deptrac\Core\Ast\Parser\{closure}(): Argument #1 ($typeNode) must be of type _HumbugBoxd1ea71d4b9d8\PhpParser\Node\Identifier|_HumbugBoxd1ea71d4b9d8\PhpParser\Node\Name, _HumbugBoxd1ea71d4b9d8\PhpParser\Node\IntersectionType given in phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/TypeResolver.php:136
Stack trace:
#0 [internal function]: Qossmic\Deptrac\Core\Ast\Parser\TypeResolver->Qossmic\Deptrac\Core\Ast\Parser\{closure}(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\IntersectionType))
#1 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/TypeResolver.php(136): array_map(Object(Closure), Array)
#2 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/Extractors/PropertyExtractor.php(29): Qossmic\Deptrac\Core\Ast\Parser\TypeResolver->resolvePropertyType(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\UnionType))
#3 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php(137): Qossmic\Deptrac\Core\Ast\Parser\Extractors\PropertyExtractor->processNode(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\Stmt\Property), Object(Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeReferenceBuilder), Object(Qossmic\Deptrac\Core\Ast\Parser\TypeScope))
#4 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(202): Qossmic\Deptrac\Core\Ast\Parser\NikicPhpParser\FileReferenceVisitor->leaveNode(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\Stmt\Property))
#5 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverseArray(Array)
#6 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverseNode(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\Stmt\Class_))
#7 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverseArray(Array)
#8 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverseNode(Object(_HumbugBoxd1ea71d4b9d8\PhpParser\Node\Stmt\Namespace_))
#9 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverseArray(Array)
#10 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/NikicPhpParser/NikicPhpParser.php(49): _HumbugBoxd1ea71d4b9d8\PhpParser\NodeTraverser->traverse(Array)
#11 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/AstLoader.php(28): Qossmic\Deptrac\Core\Ast\Parser\NikicPhpParser\NikicPhpParser->parseFile('/Volumes/projec...')
#12 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/AstMapExtractor.php(17): Qossmic\Deptrac\Core\Ast\AstLoader->createAstMap(Array)
#13 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Analyser/DependencyLayersAnalyser.php(23): Qossmic\Deptrac\Core\Ast\AstMapExtractor->extract()
#14 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Analyser/LegacyDependencyLayersAnalyser.php(18): Qossmic\Deptrac\Core\Analyser\DependencyLayersAnalyser->process()
#15 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Supportive/Console/Command/AnalyseRunner.php(33): Qossmic\Deptrac\Core\Analyser\LegacyDependencyLayersAnalyser->analyse()
#16 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Supportive/Console/Command/AnalyseCommand.php(57): Qossmic\Deptrac\Supportive\Console\Command\AnalyseRunner->run(Object(Qossmic\Deptrac\Supportive\Console\Command\AnalyseOptions), Object(Qossmic\Deptrac\Supportive\Console\Symfony\SymfonyOutput))
#17 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/symfony/console/Command/Command.php(265): Qossmic\Deptrac\Supportive\Console\Command\AnalyseCommand->execute(Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Input\ArgvInput), NULL)
#18 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/symfony/console/Application.php(845): _HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Command\Command->run(Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Input\ArgvInput), Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Output\ConsoleOutput))
#19 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/symfony/console/Application.php(261): _HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Application->doRunCommand(Object(Qossmic\Deptrac\Supportive\Console\Command\AnalyseCommand), Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Input\ArgvInput), Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Output\ConsoleOutput))
#20 phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Supportive/Console/Application.php(68): _HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Application->doRun(Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Input\ArgvInput), Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Output\ConsoleOutput))
#21 phar:///app/vendor/qossmic/deptrac-shim/deptrac/vendor/symfony/console/Application.php(157): Qossmic\Deptrac\Supportive\Console\Application->doRun(Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Input\ArgvInput), Object(_HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Output\ConsoleOutput))
#22 phar:///app/vendor/qossmic/deptrac-shim/deptrac/deptrac.php(24): _HumbugBoxd1ea71d4b9d8\Symfony\Component\Console\Application->run()
#23 /app/vendor/qossmic/deptrac-shim/deptrac(14): require('phar:///Volumes...')
#24 /app/vendor/bin/deptrac(119): include('/Volumes/projec...')
#25 {main}
  thrown in phar:///app/vendor/qossmic/deptrac-shim/deptrac/src/Core/Ast/Parser/TypeResolver.php on line 136
@patrickkusebauch
Copy link
Collaborator

This is already fixed in main, just needing a realease.

@gennadigennadigennadi
Copy link
Member

@see #1243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants