Skip to content

Fatal Error when introducing Union Type in SVC 12.0.0 #71

Open
@danmooney2

Description

Preconditions:

  • SVC 12.0.0
  • Create before/app/code/test.php:
<?php

class Test
{
    public function get(string $value)
    {

    }
}
  • Create after/app/code/test.php:
<?php

class Test
{
    public function get(bool|string $value)
    {

    }
}
  • Run bin/svc compare [absolute path to before directory] [absolute path to after directory]

Expected:
SVC successfully runs to completion

Actual:

Fatal error: Uncaught Error: Call to undefined method PhpParser\Node\UnionType::toString() in /Users/dmooney/Code/magento-semver/vendor/tomzx/php-semver-checker/src/PHPSemVerChecker/Comparator/Type.php:35
Stack trace:
#0 /Users/dmooney/Code/magento-semver/vendor/tomzx/php-semver-checker/src/PHPSemVerChecker/Comparator/Signature.php(42): PHPSemVerChecker\Comparator\Type::get(Object(PhpParser\Node\UnionType))
#1 /Users/dmooney/Code/magento-semver/src/Comparator/Signature.php(77): PHPSemVerChecker\Comparator\Signature::analyze(Array, Array)
#2 /Users/dmooney/Code/magento-semver/src/Analyzer/ClassMethodAnalyzer.php(217): Magento\SemanticVersionChecker\Comparator\Signature::analyze(Array, Array)
#3 /Users/dmooney/Code/magento-semver/src/Analyzer/AbstractCodeAnalyzer.php(74): Magento\SemanticVersionChecker\Analyzer\ClassMethodAnalyzer->reportChanged(Object(PHPSemVerChecker\Report\Report), Object(PhpParser\Node\Stmt\Class_), Object(PhpParser\Node\Stmt\Class_), Array)
#4 /Users/dmooney/Code/magento-semver/src/Analyzer/ClassAnalyzer.php(114): Magento\SemanticVersionChecker\Analyzer\AbstractCodeAnalyzer->analyze(Object(PhpParser\Node\Stmt\Class_), Object(PhpParser\Node\Stmt\Class_))
#5 /Users/dmooney/Code/magento-semver/src/Analyzer/AbstractCodeAnalyzer.php(74): Magento\SemanticVersionChecker\Analyzer\ClassAnalyzer->reportChanged(Object(PHPSemVerChecker\Report\Report), Object(PHPSemVerChecker\Registry\Registry), Object(PHPSemVerChecker\Registry\Registry), Array)
#6 /Users/dmooney/Code/magento-semver/src/Analyzer/Analyzer.php(45): Magento\SemanticVersionChecker\Analyzer\AbstractCodeAnalyzer->analyze(Object(PHPSemVerChecker\Registry\Registry), Object(PHPSemVerChecker\Registry\Registry))
#7 /Users/dmooney/Code/magento-semver/src/Analyzer/NonApiAnalyzer.php(31): Magento\SemanticVersionChecker\Analyzer\Analyzer->analyze(Object(PHPSemVerChecker\Registry\Registry), Object(PHPSemVerChecker\Registry\Registry))
#8 /Users/dmooney/Code/magento-semver/src/ReportBuilder.php(221): Magento\SemanticVersionChecker\Analyzer\NonApiAnalyzer->analyze(Object(PHPSemVerChecker\Registry\Registry), Object(PHPSemVerChecker\Registry\Registry))
#9 /Users/dmooney/Code/magento-semver/src/ReportBuilder.php(146): Magento\SemanticVersionChecker\ReportBuilder->buildReport()
#10 /Users/dmooney/Code/magento-semver/src/ReportBuilder.php(115): Magento\SemanticVersionChecker\ReportBuilder->makeVersionReport()
#11 /Users/dmooney/Code/magento-semver/src/SemanticVersionChecker.php(60): Magento\SemanticVersionChecker\ReportBuilder->makeCompleteVersionReport()
#12 /Users/dmooney/Code/magento-semver/src/SemanticVersionChecker.php(86): Magento\SemanticVersionChecker\SemanticVersionChecker->loadVersionReport()
#13 /Users/dmooney/Code/magento-semver/src/Console/Command/CompareSourceCommand.php(149): Magento\SemanticVersionChecker\SemanticVersionChecker->getVersionIncrease()
#14 /Users/dmooney/Code/magento-semver/vendor/symfony/console/Command/Command.php(298): Magento\SemanticVersionChecker\Console\Command\CompareSourceCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /Users/dmooney/Code/magento-semver/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /Users/dmooney/Code/magento-semver/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Magento\SemanticVersionChecker\Console\Command\CompareSourceCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /Users/dmooney/Code/magento-semver/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /Users/dmooney/Code/magento-semver/bin/svc(30): Symfony\Component\Console\Application->run()
#19 {main}
  thrown in /Users/dmooney/Code/magento-semver/vendor/tomzx/php-semver-checker/src/PHPSemVerChecker/Comparator/Type.php on line 35```

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions