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

class PhpParser\Node\Expr\PropertyFetch could not be converted to string #345

Closed
remicollet opened this issue Feb 24, 2022 · 5 comments
Closed
Assignees
Labels
Projects

Comments

@remicollet
Copy link
Contributor

Trying to analyse laminas-mail 2.16.0 sources tree


$ phpci laminas-mail-1ee1a384b96c8af29ecad9b3a7adc27a150ebc49/src/

                                                                                                                        
 [ERROR] Handling "Bartlett\CompatInfo\Application\Query\Analyser\Compatibility\GetCompatibilityQuery" failed: Object of
         class PhpParser\Node\Expr\PropertyFetch could not be converted to string                                       
  
@llaville
Copy link
Owner

I've provided a screenshot in report 346 to see what it look like if you apply following patch.

diff --git a/src/Presentation/Console/Command/AnalyserCommand.php b/src/Presentation/Console/Command/AnalyserCommand.php
index 0c9e12c0..3ad51a6e 100644
--- a/src/Presentation/Console/Command/AnalyserCommand.php
+++ b/src/Presentation/Console/Command/AnalyserCommand.php
@@ -17,6 +17,8 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Messenger\Exception\HandlerFailedException;

+use function sprintf;
+
 /**
  * Analyse a data source to find out requirements.
  *
@@ -65,8 +67,29 @@ final class AnalyserCommand extends AbstractCommand implements CommandInterface
         try {
             $this->queryBus->query($compatibilityQuery);
         } catch (HandlerFailedException $e) {
+            $exceptions = [];
+            foreach($e->getNestedExceptions() as $exception) {
+                $exceptions[] = $exception->getMessage()
+                    . sprintf(' from file "%s" at line %d', $exception->getFile(), $exception->getLine());
+            }
             $io = new Style($input, $output);
-            $io->error($e->getMessage());
+            $io->error(
+                sprintf(
+                    'Cannot analyse data source "%s" for following reason(s)',
+                    $compatibilityQuery->getSource()
+                )
+            );
+            $io->listing($exceptions);
+            /** @var ApplicationInterface $app */
+            $app = $this->getApplication();
+            $io->note(
+                sprintf(
+                    'Issue found by %s version %s with DB version %s',
+                    $app->getName(),
+                    $app->getInstalledVersion(),
+                    $app->getInstalledVersion(true, 'bartlett/php-compatinfo-db')
+                )
+            );
             return self::FAILURE;
         }

@llaville
Copy link
Owner

And to fix error, patch to apply is :

diff --git a/src/Application/Sniffs/Fibers/FiberSniff.php b/src/Application/Sniffs/Fibers/FiberSniff.php
index b45a91a7..426f96bd 100644
--- a/src/Application/Sniffs/Fibers/FiberSniff.php
+++ b/src/Application/Sniffs/Fibers/FiberSniff.php
@@ -55,6 +55,10 @@ final class FiberSniff extends SniffAbstract
             return null;
         }

+        if (!$node->class instanceof Node\Name) {
+            return null;
+        }
+
         if ('Fiber' === (string) $node->class) {
             $this->updateNodeElementVersion($node, $this->attributeKeyStore, ['php.min' => '8.1.0alpha1']);
             $this->updateNodeElementRule($node, $this->attributeKeyStore, self::CA81);

Even if CompatibilityAnalyser, after that, display a report, I'm not yet sure about the minimum PHP value found ;-) But it's another problem !

@llaville llaville added this to To do in v6.3 Feb 24, 2022
@llaville llaville moved this from To do to In progress in v6.3 Feb 24, 2022
llaville added a commit that referenced this issue Feb 24, 2022
@llaville
Copy link
Owner

Patches were applied on branch 6.3

@llaville llaville moved this from In progress to Done in v6.3 Feb 24, 2022
@llaville
Copy link
Owner

llaville commented Mar 6, 2022

@remicollet FYI when I said

Even if CompatibilityAnalyser, after that, display a report, I'm not yet sure about the minimum PHP value found ;-) But it's another problem !

I finally found origin of detection issue. Fix will follow !

@llaville
Copy link
Owner

llaville commented Mar 6, 2022

After applying fix of issue 348, analysis of laminas mail 2.16.0 give me acceptable results.

laminas-mail-2160

llaville added a commit that referenced this issue Mar 6, 2022
* add a text manifest in PHAR distrib

* fix issue #345

* implement feature #346

* implement feature request #347

* clean-up old box manifest resources

* fix issue #348

* add experimental RuleReporter (use '--output rule' format)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
v6.3
Done
Development

No branches or pull requests

2 participants