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

Syntax error, unexpected ')', expecting T_VARIABLE on line 2 #12

Closed
williamdes opened this issue Feb 28, 2022 · 6 comments
Closed

Syntax error, unexpected ')', expecting T_VARIABLE on line 2 #12

williamdes opened this issue Feb 28, 2022 · 6 comments

Comments

@williamdes
Copy link

Could be kinda related to #4

When I put your rules non commented phpstan outputs some PHP parse errors on files that have nothing to do with the extension

diff --git a/phpstan.neon b/phpstan.neon
index c8892207e..2ecac5269 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,6 +1,9 @@
 includes:
 	- ./vendor/nunomaduro/larastan/extension.neon
 	- ./phpstan-baseline.neon
+	- ./vendor/canvural/phpstan-blade-rule/config/extension.neon
+	- ./vendor/symplify/template-phpstan-compiler/config/services.neon
+	- ./vendor/symplify/astral/config/services.neon
 parameters:
 	level: max
 	paths:
@@ -9,3 +12,5 @@ parameters:
 		- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 		# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 		- xxxxxxxxxxxxxxxxxxxxxxxxxxx
+	templatePaths:
+		- resources/views

Using this container that runs PHP 8.1.3: https://hub.docker.com/r/lcde/laravel

@williamdes
Copy link
Author

When running phpstan with debug mode it does end up like that on a random near to empty trait file

/var/www/xxxxxxx/CacheQueryBuilderTrait.php
--- consumed 0 B, total 728 MB
Result cache was not saved because of non-ignorable exception: Syntax error, unexpected ')', expecting T_VARIABLE on line 3

And then the error table

@canvural
Copy link
Owner

Hi,

I'd really need more info to debug this. Can you at least try to reproduce this on one file, a controller for example? And then check which views that controller use. The issue can be in any of the included views, layouts that the view extends or the view file itself. So, if you can share those I can debug further. But if not, you'd need to debug it by removing some code from view, and re-checking.

Also do you have any custom directives registered?

Thanks

@williamdes
Copy link
Author

Hi,

It does not do the error on all controllers, I have pinned two that make it and here is one that I trimmed down to reproduce the error

<?php

namespace App\Http\v30\Controllers;

use Illuminate\Http\Request;

class TemplateMailController extends Controller
{
    public function renderFoo(Request $request)
    {
        return view('email.toFoo.barBaz', $dataMail)->render();
    }

}

The blade template barBaz is trimmed down to

@include('email.partials.head')

And if I empty the included file it does not change anything, anyway the included file is pure HTML

@williamdes
Copy link
Author

Hi @canvural
Did you manage to use the code I provided earlier this year ?

@williamdes williamdes closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2022
@williamdes
Copy link
Author

Closing it, I think the data I provided should allow to reproduce it
I lost track about this issue anyway, it's up to you to consider it

@williamdes
Copy link
Author

williamdes commented Apr 12, 2023

I am upgrading to Laravel 9 and now it throws:

  Call to a member function end() on null

  at phar://vendor/phpstan/phpstan/phpstan.phar/src/Parallel/Process.php:127
    123▕         }
    124foreach ($this->process->pipes as $pipe) {
    125$pipe->close();
    126▕         }
  ➜ 127$this->in->end();
    128▕     }
    129public function bindConnection(ReadableStreamInterface $out, WritableStreamInterface $in) : void
    130▕     {
    131$out->on('data', function (array $json) : void {
composer run phpstan -- -vvv --debug 
> ./vendor/bin/phpstan --memory-limit=1G '-vvv' '--debug'
Note: Using configuration file /var/www/phpstan.neon.
Result cache not used because of debug mode.
/var/www/app/xxxx.php
Uncaught Error: Cannot instantiate interface PHPStan\Rules\Registry in /var/www/vendor/canvural/phpstan-blade-rule/src/Rules/BladeRule.php:28
#0 /var/www/build/phpstan/cache/nette.configurator/Container_d59cc6f7ef.php(46810): Vural\PHPStanBladeRule\Rules\BladeRule->__construct(Array, Object(Vural\PHPStanBladeRule\NodeAnalyzer\BladeViewMethodsMatcher), Object(Vural\PHPStanBladeRule\NodeAnalyzer\LaravelViewFunctionMatcher), Object(Vural\PHPStanBladeRule\Rules\ViewRuleHelper))
#1 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Container.php(162): Container_d59cc6f7ef->createService0466()
#2 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Container.php(95): _PHPStan_950705577\Nette\DI\Container->createService('0466')
#3 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Nette/NetteContainer.php(33): _PHPStan_950705577\Nette\DI\Container->getService('0466')
#4 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Nette/NetteContainer.php(88): PHPStan\DependencyInjection\Nette\NetteContainer->getService('0466')
#5 [internal function]: PHPStan\DependencyInjection\Nette\NetteContainer->PHPStan\DependencyInjection\Nette\{closure}('0466')
#6 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Nette/NetteContainer.php(89): array_map(Object(Closure), Array)
#7 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Nette/NetteContainer.php(58): PHPStan\DependencyInjection\Nette\NetteContainer->tagsToServices(Array)
#8 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/MemoizingContainer.php(42): PHPStan\DependencyInjection\Nette\NetteContainer->getServicesByTag('phpstan.rules.r...')
#9 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Rules/LazyRegistry.php(61): PHPStan\DependencyInjection\MemoizingContainer->getServicesByTag('phpstan.rules.r...')
#10 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Rules/LazyRegistry.php(37): PHPStan\Rules\LazyRegistry->getRulesFromContainer()
#11 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(104): PHPStan\Rules\LazyRegistry->getRules('PHPStan\\Node\\Fi...')
#12 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(174): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PHPStan\Node\FileNode), Object(PHPStan\Analyser\MutatingScope))
#13 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(72): PHPStan\Analyser\FileAnalyser->analyseFile('/var/www/app/Jo...', Array, Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)
#14 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(62): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), Object(Closure), true, Array)
#15 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(209): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), Object(Closure), true, true, '/var/www/phpsta...', Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput))
#16 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(102): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/var/www/phpsta...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput))
#17 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(190): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/var/www/phpsta...', Array, Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput))
#18 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_950705577\Symfony\Component\Console\Output\ConsoleOutput))
#19 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_950705577\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_950705577\Symfony\Component\Console\Output\ConsoleOutput))
#20 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_950705577\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_950705577\Symfony\Component\Console\Output\ConsoleOutput))
#21 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_950705577\Symfony\Component\Console\Application->doRun(Object(_PHPStan_950705577\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_950705577\Symfony\Component\Console\Output\ConsoleOutput))
#22 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_950705577\Symfony\Component\Console\Application->run()
#23 phar:///var/www/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_950705577\{closure}()
#24 /var/www/vendor/phpstan/phpstan/phpstan(8): require('phar:///var/www...')
#25 /var/www/vendor/bin/phpstan(120): include('/var/www/vendor...')
#26 {main}
Script ./vendor/bin/phpstan --memory-limit=1G handling the phpstan event returned with error code 1

Will be upgrading to 10 soon

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

2 participants