Git Product home page Git Product logo

Comments (41)

kenchilada avatar kenchilada commented on August 24, 2024 5

I ran into this problem and nothing seemed to work. I was using Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install'} to install.

Instead I followed the directions here and now it works:
https://phpactor.github.io/phpactor/vim-plugin.html#installation

Specifically, I had to manually do this for it to work:
$ cd ~/.vim/plugged/phpactor && composer install

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

Just a guess, but which version of PHP are yih using? 7.0 is no longer supported.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024
>> php --version
PHP 7.3.0 (cli) (built: Dec  7 2018 11:00:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

I tries restarting neovim and opened the same file and went to insert mode in the same place and the error was thrown

"~/Projects/PHP/knights/app/Http/Controllers/BalanceController.php" 207L, 6770C
[LC] Project root: /Users/juju/Projects/PHP/knights
[ncm2_phpactor@yarp] error caught in notification handler 'on_complete [{'filepath': '/Users/juju/Projects/PHP/knights/app/Http/Controllers/BalanceController.php', 'typed': '        dd($request->input', 'scope_match': 'php', 'startccol': 22, 'scope_level': 1, 'word_pattern': '[\\$\\w][\\w]*', 'time': 1544894434.405078, 'lnum': 71, 'bufnr': 3, 'changedtick': 2, 'manual': 0, 'base': 'input', 'ccol': 27, 'filetype': 'php', 'curpos': [0, 71, 27, 0, 27], 'tick': [[0, 71, 27], 0], 'early_cache': False, 'context_id': 29, 'scope': 'php', 'matcher': {'name': 'abbrfuzzy'}, 'source': {'on_complete': 'ncm2_phpactor#on_complete', 'subscope_enable': 1, 'early_cache': 0, 'name': 'phpactor', 'scope': ['php'], 'mark': 'b', 'on_warmup': 'ncm2_phpactor#on_warmup', 'ready': 1, 'enable': 1, 'auto_popup': 1, 'priority': 9, 'complete_pattern': ['\\$', '-\\>', '::'], 'word_pattern': '[\\$\\w][\\w]*'}, 'bcol': 27, 'match_end': 21}, ['<?php', '', 'namespace App\\Http\\Controllers;', '', 'use App\\Http\\Controllers\\Controller;', 'use Illuminate\\Http\\Request;', 'use Spatie\\QueryBuilder\\QueryBuilder;', '', 'use App\\Balance;', 'use App\\Office;', 'use App\\Merchant;', 'use App\\Product;', '', 'use App\\Http\\Requests\\Balances\\StoreBalance;', 'use App\\Http\\Requests\\Balances\\UpdateBalance;', 'use App\\Http\\Requests\\Balances\\RemoveBalance;', '', 'class BalanceController extends Controller', '{', '    /**', '     * Create a new controller instance.', '     *', '     * @return void', '     */', '    public function __construct()', '    {', "        $this->middleware(['auth', 'user.id']);", "        $this->middleware('permission:view_balance', ['only' => ['index', 'list']]);", "        $this->middleware('permission:create_balance|create_transaction', ['only' => ['create']]);", "        $this->middleware('permission:update_balance', ['only' => ['update']]);", "        $this->middleware('permission:destroy_balance', ['only' => ['destroy']]);", '    }', '', '    public function index()', '    {', "        return view('balances.index');", '    }', '', '    public function list(Request $request)', '    {', '        return QueryBuilder::for(Balance::class)', "            ->LeftJoin('products', 'balances.product_id', 'products.id')", "            ->LeftJoin('merchants', 'balances.merchant_id', 'merchants.id')", "            ->LeftJoin('offices', 'balances.office_id', 'offices.id')", "            ->selectRaw('balances.*, merchants.name as merchant_name, offices.name as office_name, offices.phone as office_phone, merchants.phone as merchant_phone, products.name as product_name, products.amount_limit as amount_limit')", '            ->allowedFilters(', "                'balance',", "                'balances.id',", "                'expiry_date',", "                'products.amount_limit',", "                'balances.car_limit',", "                'products.name',", "                'balances.note',", "                'products.name',", "                'merchants.name',", "                'offices.name'", '            )', "            ->orderBy('id', 'desc')", '            ->jsonPaginate();', '    }', '', '', '    /**', '     * Create a new _balance instance after a valid registration.', '     *', '     * @param  array  $data', '     * @return \\App\\Balance', '     */', '    protected function create(StoreBalance $request)', '    {', '        dd($request->input);', "        $product = Product::where(['name' =>$request->product_name])->firstOrFail();", '', "        $merchant_id = merchant::where(['name' =>$request->merchant_name])->firstOrFail()->id;", '', "        $office_id = office::where(['name' =>$request->office_name])->firstOrFail()->id;", '', "        if($product->requiresCarBalance() && !$request->filled('car_limit'))", "            return ezReturnErrorMessage('Number of cars is required!');", '', '        $balance = Balance::create(array_merge($request->input(), [', "            'product_id' => $product->id,", "            'office_id' => $office_id,", "            'merchant_id' => $merchant_id", '        ]));', '', "        return ezReturnSuccessMessage('Balance created successfully!', $balance);", '    }', '', '    public function update(UpdateBalance $request)', '    {', '        $Balance = Balance::findOrFail($request->id);', '', '        $Balance->update($request->input());', '', "        return ezReturnSuccessMessage('Balance updated successfully!');", '    }', '', '    public function destroy(Request $request)', '    {', '', '        $Balance = Balance::findOrFail($request->id);', '', '        $Balance->delete();', '', "        return ezReturnSuccessMessage('Balance removed successfully!');", '', '    }', '', '    public function productBalance(Request $request){', '', "        if(!$request->filled('product_name'))", '            return;', '', '        $balanceInfo = [', "            'product_requires_balance' =>null,", "            'rows' => []", '        ];', '', '        //Data template', "        //[{name:'n11',value:'v12',editor:'text',group:'Product Information'}]", '', "        $product = Product::where(['name' =>$request->product_name])->first();", '', '        if($product == null)', '            return $balanceInfo;', '', "        $balanceInfo['product_requires_balance'] = $product->requiresBalance();", '', '        $this->setProductInformation($product, $balanceInfo);', '        $this->setCheckTypeInformation($product, $balanceInfo);', '        return $balanceInfo;', '', '    }', '', '    function setProductInformation($product, &$balanceInfo)', '    {', '        if($product->requiresBalance())', '        {', "            $balanceInfo['product'] = $product;", "            $balanceInfo['merchant'] = $product->requiresBalance();", "            array_push($balanceInfo['rows'], ['name'=>'Name','value'=>$product->name,'group'=>'Product Information']);", '            array_push($balanceInfo[\'rows\'], [\'name\'=>\'Requires Balance\',\'value\'=>\'<span style="color:red; font-weight:bold;">Yes</span>\',\'group\'=>\'Product Information\']);', '', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Has Amount Limit',", "                    'value'=> $product->requiresAmountBalance() ? 'Yes' : 'No',", "                    'group'=>'Product Information'", '                ]);', '', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Has Car Limit',", "                    'value'=> $product->requiresCarBalance() ? 'Yes' : 'No',", "                    'group'=>'Product Information'", '                ]);', '', '            if($product->amount_limit != null){', "                array_push($balanceInfo['rows'],", '                    [', "                        'name'=>'Amount Limit',", "                        'value'=>$product->amount_limit . ' ' . $product->amount_limit_unit . '(s)',", "                        'group'=>'Product Information'", '                    ]);', '            }', '', '            if($product->date_limit != null){', "                array_push($balanceInfo['rows'],", '                    [', "                        'name'=>'Day Limit',", "                        'value'=>'Expires in '.$product->date_limit. ' days',", "                        'group'=>'Product Information'", '                    ]);', '            }', '        }', '        else {', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Requires Balance',", "                    'value'=>'No',", "                    'group'=>'Product Information'", '                ]);', '            return $balanceInfo;', '        }', '    }', '', '    function setCheckTypeInformation($product, &$balanceInfo)', '    {', "        $checkTypes = \\App\\CheckType:: LeftJoin('product_check_type', 'product_check_type.check_type_id', 'check_types.id')", "            ->selectRaw('id,category,subcategory,price')", "            ->where('product_id', $product->id)->get();", '', '        foreach($checkTypes as $checkType)', '        {', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>$checkType->category,", "                    
[ncm2_phpactor@yarp] 'value'=>$checkType->price,", "                    'group'=>'Test Information'", '                ]);', '        }', '', '    }', '', '', '}'], '/Users/juju/Projects/PHP/knights/app/Http/Controllers', ['php', '/Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/plugin/../bin/phpactor', 'complete', '-d', '/Users/juju/Development/Applications/neovim-qt/neovim-qt/build/bin', '--format=json', '--', 'stdin', '2235']]'
[ncm2_phpactor@yarp] Traceback (most recent call last):
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/yarp.py", line 30, in on_notification
[ncm2_phpactor@yarp]     getattr(module_obj, method)(*args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2.py", line 206, in on_complete
[ncm2_phpactor@yarp]     on_complete_impl(context, *args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2_phpactor.py", line 55, in on_complete
[ncm2_phpactor@yarp]     for e in result['suggestions']:
[ncm2_phpactor@yarp] KeyError: 'suggestions'
The only match
The only match
[LC] [Warning] Could not compute cache key for barryvdh/laravel-ide-helper
[LC] [Warning] Could not compute cache key for spatie/laravel-json-api-paginate

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

strange, the next thing would be to invoke Phpactor directly and get a stack trace and identify the issue:

echo '<?php array_key_exists' | ~/.vim/<plugged>/phpactor/bin/phpactor complete stdin 17 --format=json

(where <plugged> is the plugin directory used by your plugin manager).

It could be related to this issue

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

this is what I get:

echo '<?php array_key_exists' | ./phpactor complete stdin 17 --format=json
{"suggestions":[{"type":"function","name":"array_key_exists","label":"array_key_exists","short_description":"array_key_exists($key, array|ArrayObject $search): bool","class_import":null,"info":"array_key_exists($key, array|ArrayObject $search): bool"}],"issues":[]}

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

@dantleech Is there any way to manually tell it to show completion for a cursor location in a file?

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

sure, just phpactor complete src/Path/To/File.php 1234 (where 1234 is the offset).

you may also be able to reproduce the error with omni complete. As this uses RPC for completion, you can enable rpc.store_replay and playback the problematic RPC call.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

When I try to launch it from command line I get the following list
Exception

Update: moved exception detail to a gist

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

Can you try omni complete as indicated above? If you can reproduce the issue there that would be great.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

This is what I get if I set the omnifun

Error detected while processing function phpactor#Complete:
line   36:
E714: List required

I changed the phpactor.vim Completefunction as follows:

    let result = phpactor#rpc("complete", { "offset": offset, "source": source, "type": &ft})
    echomsg 'result:' result
    let suggestions = result['suggestions']
    let issues = result['issues']

The content of the result variable is 0

Manually running phpactor returns the following:

>> /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/bin/phpactor complete ~/Projects/PHP/knights/app/Http/Controllers/BalanceController.php 2010
suggestions:
issues:

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

Yep, this would indicate an error. Now you can enable the rpc.store_replay option as per debugging and use the command line phpactor rpc --replay -v command to reply the command and get a precise error.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

This is what I get using <c-x><c-o>:

 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/bin/phpactor rpc --replay --pretty -v
[2018-12-16 10:07:27] phpactor.DEBUG: REQUEST {"action":"complete","parameters":{"source":"<?php\n\nnamespace App\\Http\\Controllers;\n\nuse App\\Http\\Controllers\\Controller;\nuse Illuminate\\Http\\Request;\nuse Spatie\\QueryBuilder\\QueryBuilder;\n\nuse App\\Balance;\nuse App\\Office;\nuse App\\Merchant;\nuse App\\Product;\n\nuse App\\Http\\Requests\\Balances\\StoreBalance;\nuse App\\Http\\Requests\\Balances\\UpdateBalance;\nuse App\\Http\\Requests\\Balances\\RemoveBalance;\n\nclass BalanceController extends Controller\n{\n    /**\n     * Create a new controller instance.\n     *\n     * @return void\n     */\n    public function __construct()\n    {\n        $this->middleware(['auth', 'user.id']);\n        $this->middleware('permission:view_balance', ['only' => ['index', 'list']]);\n        $this->middleware('permission:create_balance|create_transaction', ['only' => ['create']]);\n        $this->middleware('permission:update_balance', ['only' => ['update']]);\n        $this->middleware('permission:destroy_balance', ['only' => ['destroy']]);\n    }\n\n    public function index()\n    {\n        return view('balances.index');\n    }\n\n    public function list(Request $request)\n    {\n        return QueryBuilder::for(Balance::class)\n            ->LeftJoin('products', 'balances.product_id', 'products.id')\n            ->LeftJoin('merchants', 'balances.merchant_id', 'merchants.id')\n            ->LeftJoin('offices', 'balances.office_id', 'offices.id')\n            ->selectRaw('balances.*, merchants.name as merchant_name, offices.name as office_name, offices.phone as office_phone, merchants.phone as merchant_phone, products.name as product_name, products.amount_limit as amount_limit')\n            ->allowedFilters(\n                'balance',\n                'balances.id',\n                'expiry_date',\n                'products.amount_limit',\n                'balances.car_limit',\n                'products.name',\n                'balances.note',\n                'products.name',\n                'merchants.name',\n                'offices.name'\n            )\n            ->orderBy('id', 'desc')\n            ->jsonPaginate();\n    }\n\n\n    /**\n     * Create a new _balance instance after a valid registration.\n     *\n     * @param  array  $data\n     * @return \\App\\Balance\n     */\n    protected function create(StoreBalance $request)\n    {\n        dd($request->input\n        $product = Product::findOrFail($request->product_id);\n        if($product->requiresCarBalance() && !$request->filled('car_limit'))\n            return ezReturnErrorMessage('Car Limit is required!');\n\n        $balance = Balance::create($request->input());\n\n        return ezReturnSuccessMessage('Balance created successfully!', $balance);\n    }\n\n    public function update(UpdateBalance $request)\n    {\n        $Balance = Balance::findOrFail($request->id);\n\n        $Balance->update($request->input());\n\n        return ezReturnSuccessMessage('Balance updated successfully!');\n    }\n\n    public function destroy(Request $request)\n    {\n\n        $Balance = Balance::findOrFail($request->id);\n\n        $Balance->delete();\n\n        return ezReturnSuccessMessage('Balance removed successfully!');\n\n    }\n\n    public function productBalance(Request $request){\n\n        if(!$request->filled('product_name'))\n            return;\n\n        $balanceInfo = [\n            'product_requires_balance' =>null,\n            'rows' => []\n        ];\n\n        //Data template\n        //[{name:'n11',value:'v12',editor:'text',group:'Product Information'}]\n\n        $product = Product::where(['name' =>$request->product_name])->first();\n\n        if($product == null)\n            return $balanceInfo;\n\n        $balanceInfo['product_requires_balance'] = $product->requiresBalance();\n\n        $this->setProductInformation($product, $balanceInfo);\n        $this->setCheckTypeInformation($product, $balanceInfo);\n        return $balanceInfo;\n\n    }\n\n    function setProductInformation($product, &$balanceInfo)\n    {\n        if($product->requiresBalance())\n        {\n            $balanceInfo['product'] = $product;\n            $balanceInfo['merchant'] = $product->requiresBalance();\n            array_push($balanceInfo['rows'], ['name'=>'Name','value'=>$product->name,'group'=>'Product Information']);\n            array_push($balanceInfo['rows'], ['name'=>'Requires Balance','value'=>'<span style=\"color:red; font-weight:bold;\">Yes</span>','group'=>'Product Information']);\n\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Has Amount Limit',\n                    'value'=> $product->requiresAmountBalance() ? 'Yes' : 'No',\n                    'group'=>'Product Information'\n                ]);\n\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Has Car Limit',\n                    'value'=> $product->requiresCarBalance() ? 'Yes' : 'No',\n                    'group'=>'Product Information'\n                ]);\n\n            if($product->amount_limit != null){\n                array_push($balanceInfo['rows'],\n                    [\n                        'name'=>'Amount Limit',\n                        'value'=>$product->amount_limit . ' ' . $product->amount_limit_unit . '(s)',\n                        'group'=>'Product Information'\n                    ]);\n            }\n\n            if($product->date_limit != null){\n                array_push($balanceInfo['rows'],\n                    [\n                        'name'=>'Day Limit',\n                        'value'=>'Expires in '.$product->date_limit. ' days',\n                        'group'=>'Product Information'\n                    ]);\n            }\n        }\n        else {\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Requires Balance',\n                    'value'=>'No',\n                    'group'=>'Product Information'\n                ]);\n            return $balanceInfo;\n        }\n    }\n\n    function setCheckTypeInformation($product, &$balanceInfo)\n    {\n        $checkTypes = \\App\\CheckType:: LeftJoin('product_check_type', 'product_check_type.check_type_id', 'check_types.id')\n            ->selectRaw('id,category,subcategory,price')\n            ->where('product_id', $product->id)->get();\n\n        foreach($checkTypes as $checkType)\n        {\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>$checkType->category,\n                    'value'=>$checkType->price,\n                    'group'=>'Test Information'\n                ]);\n        }\n\n    }\n\n\n}","offset":2235,"type":"php"}} []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Statement\ClassDeclaration [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Parameter [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\Variable [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ArrayCreationExpression [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\StringLiteral [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\ReservedWord [] []
[2018-12-16 10:07:28] phpactor.DEBUG: RESPONSE {"action":"return","parameters":{"value":{"suggestions":[{"type":"method","name":"input","label":"input","short_description":"pub input(string|null $key = NULL, string|array|null $default = NULL): string|array|null","class_import":null,"info":"pub input(string|null $key = NULL, string|array|null $default = NULL): string|array|null"}],"issues":[]}}} []
{
    "version": "1.0.0",
    "action": "return",
    "parameters": {
        "value": {
            "suggestions": [
                {
                    "type": "method",
                    "name": "input",
                    "label": "input",
                    "short_description": "pub input(string|null $key = NULL, string|array|null $default = NULL): string|array|null",
                    "class_import": null,
                    "info": "pub input(string|null $key = NULL, string|array|null $default = NULL): string|array|null"
                }
            ],
            "issues": []
        }
    }
}%

Although I still get the error in vim

Error detected while processing function phpactor#Complete:
line   36:
E714: List required

Running from terminal I get:

/Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/bin/phpactor complete ~/Projects/PHP/knights/app/Http/Controllers/BalanceController.php 2235
suggestions:
  0:
    type:variable
    name:$request
    label:$request
    short_description:StoreBalance => param #1 $var
    class_import:
    info:StoreBalance => param #1 $var
  1:
    type:variable
    name:$this
    label:$this
    short_description:BalanceController => param #1 $var
    class_import:
    info:BalanceController => param #1 $var
issues:

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

hm, wondering how this related to the original error: [php] syntax error, unexpected ')', expecting variable (T_VARIABLE) or '{' or '$'

does downgrading Phpactor help? (just git checkout f.e. 0.10.0)

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

I just got this exception after downgrading to 0.10.0:

/Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/bin/phpactor rpc --replay --pretty -v
PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "ConfigLoader" from namespace "Phpactor\Config".
Did you forget a "use" statement for e.g. "Phpactor\ConfigLoader\Core\ConfigLoader" or "Phpactor\Config\ConfigLoader"? in /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Phpactor.php:41
Stack trace:
#0 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Application.php(106): Phpactor\Phpactor::boot(Object(Symfony\Component\Console\Input\ArgvInput), '/Users/juju/.co...')
#1 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Application.php(37): Phpactor\Application->initialize(Object(Symfony\Component\Console\Input\ArgvInput))
#2 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/vendor/symfony/console/Application.php(145): Phpactor\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/juju/.config/nvim/dein/repos/github.co in /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Phpactor.php on line 41

Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "ConfigLoader" from namespace "Phpactor\Config".
Did you forget a "use" statement for e.g. "Phpactor\ConfigLoader\Core\ConfigLoader" or "Phpactor\Config\ConfigLoader"? in /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Phpactor.php:41
Stack trace:
#0 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Application.php(106): Phpactor\Phpactor::boot(Object(Symfony\Component\Console\Input\ArgvInput), '/Users/juju/.co...')
#1 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Application.php(37): Phpactor\Application->initialize(Object(Symfony\Component\Console\Input\ArgvInput))
#2 /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/vendor/symfony/console/Application.php(145): Phpactor\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/juju/.config/nvim/dein/repos/github.co in /Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/lib/Phpactor.php on line 41

Forgot to run composer install after checking out :)

after composer install I get :

/Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/bin/phpactor rpc --replay --pretty -v
[2018-12-16 10:38:34] phpactor.DEBUG: REQUEST {"action":"complete","parameters":{"source":"<?php\n\nnamespace App\\Http\\Controllers;\n\nuse App\\Http\\Controllers\\Controller;\nuse Illuminate\\Http\\Request;\nuse Spatie\\QueryBuilder\\QueryBuilder;\n\nuse App\\Balance;\nuse App\\Office;\nuse App\\Merchant;\nuse App\\Product;\n\nuse App\\Http\\Requests\\Balances\\StoreBalance;\nuse App\\Http\\Requests\\Balances\\UpdateBalance;\nuse App\\Http\\Requests\\Balances\\RemoveBalance;\n\nclass BalanceController extends Controller\n{\n    /**\n     * Create a new controller instance.\n     *\n     * @return void\n     */\n    public function __construct()\n    {\n        $this->middleware(['auth', 'user.id']);\n        $this->middleware('permission:view_balance', ['only' => ['index', 'list']]);\n        $this->middleware('permission:create_balance|create_transaction', ['only' => ['create']]);\n        $this->middleware('permission:update_balance', ['only' => ['update']]);\n        $this->middleware('permission:destroy_balance', ['only' => ['destroy']]);\n    }\n\n    public function index()\n    {\n        return view('balances.index');\n    }\n\n    public function list(Request $request)\n    {\n        return QueryBuilder::for(Balance::class)\n            ->LeftJoin('products', 'balances.product_id', 'products.id')\n            ->LeftJoin('merchants', 'balances.merchant_id', 'merchants.id')\n            ->LeftJoin('offices', 'balances.office_id', 'offices.id')\n            ->selectRaw('balances.*, merchants.name as merchant_name, offices.name as office_name, offices.phone as office_phone, merchants.phone as merchant_phone, products.name as product_name, products.amount_limit as amount_limit')\n            ->allowedFilters(\n                'balance',\n                'balances.id',\n                'expiry_date',\n                'products.amount_limit',\n                'balances.car_limit',\n                'products.name',\n                'balances.note',\n                'products.name',\n                'merchants.name',\n                'offices.name'\n            )\n            ->orderBy('id', 'desc')\n            ->jsonPaginate();\n    }\n\n\n    /**\n     * Create a new _balance instance after a valid registration.\n     *\n     * @param  array  $data\n     * @return \\App\\Balance\n     */\n    protected function create(StoreBalance $request)\n    {\n        $\n        $product = Product::findOrFail($request->product_id);\n        if($product->requiresCarBalance() && !$request->filled('car_limit'))\n            return ezReturnErrorMessage('Car Limit is required!');\n\n        $balance = Balance::create($request->input());\n\n        return ezReturnSuccessMessage('Balance created successfully!', $balance);\n    }\n\n    public function update(UpdateBalance $request)\n    {\n        $Balance = Balance::findOrFail($request->id);\n\n        $Balance->update($request->input());\n\n        return ezReturnSuccessMessage('Balance updated successfully!');\n    }\n\n    public function destroy(Request $request)\n    {\n\n        $Balance = Balance::findOrFail($request->id);\n\n        $Balance->delete();\n\n        return ezReturnSuccessMessage('Balance removed successfully!');\n\n    }\n\n    public function productBalance(Request $request){\n\n        if(!$request->filled('product_name'))\n            return;\n\n        $balanceInfo = [\n            'product_requires_balance' =>null,\n            'rows' => []\n        ];\n\n        //Data template\n        //[{name:'n11',value:'v12',editor:'text',group:'Product Information'}]\n\n        $product = Product::where(['name' =>$request->product_name])->first();\n\n        if($product == null)\n            return $balanceInfo;\n\n        $balanceInfo['product_requires_balance'] = $product->requiresBalance();\n\n        $this->setProductInformation($product, $balanceInfo);\n        $this->setCheckTypeInformation($product, $balanceInfo);\n        return $balanceInfo;\n\n    }\n\n    function setProductInformation($product, &$balanceInfo)\n    {\n        if($product->requiresBalance())\n        {\n            $balanceInfo['product'] = $product;\n            $balanceInfo['merchant'] = $product->requiresBalance();\n            array_push($balanceInfo['rows'], ['name'=>'Name','value'=>$product->name,'group'=>'Product Information']);\n            array_push($balanceInfo['rows'], ['name'=>'Requires Balance','value'=>'<span style=\"color:red; font-weight:bold;\">Yes</span>','group'=>'Product Information']);\n\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Has Amount Limit',\n                    'value'=> $product->requiresAmountBalance() ? 'Yes' : 'No',\n                    'group'=>'Product Information'\n                ]);\n\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Has Car Limit',\n                    'value'=> $product->requiresCarBalance() ? 'Yes' : 'No',\n                    'group'=>'Product Information'\n                ]);\n\n            if($product->amount_limit != null){\n                array_push($balanceInfo['rows'],\n                    [\n                        'name'=>'Amount Limit',\n                        'value'=>$product->amount_limit . ' ' . $product->amount_limit_unit . '(s)',\n                        'group'=>'Product Information'\n                    ]);\n            }\n\n            if($product->date_limit != null){\n                array_push($balanceInfo['rows'],\n                    [\n                        'name'=>'Day Limit',\n                        'value'=>'Expires in '.$product->date_limit. ' days',\n                        'group'=>'Product Information'\n                    ]);\n            }\n        }\n        else {\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>'Requires Balance',\n                    'value'=>'No',\n                    'group'=>'Product Information'\n                ]);\n            return $balanceInfo;\n        }\n    }\n\n    function setCheckTypeInformation($product, &$balanceInfo)\n    {\n        $checkTypes = \\App\\CheckType:: LeftJoin('product_check_type', 'product_check_type.check_type_id', 'check_types.id')\n            ->selectRaw('id,category,subcategory,price')\n            ->where('product_id', $product->id)->get();\n\n        foreach($checkTypes as $checkType)\n        {\n            array_push($balanceInfo['rows'],\n                [\n                    'name'=>$checkType->category,\n                    'value'=>$checkType->price,\n                    'group'=>'Test Information'\n                ]);\n        }\n\n    }\n\n\n}","offset":2218,"type":"php"}} []
[2018-12-16 10:38:34] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Statement\ClassDeclaration [] []
[2018-12-16 10:38:34] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Parameter [] []
[2018-12-16 10:38:34] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\CallExpression [] []
[2018-12-16 10:38:34] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\ScopedPropertyAccessExpression [] []
[2018-12-16 10:38:35] phpactor.DEBUG: Resolved type "<unknown>" for method "findOrFail" of class "App\Product" [] []
[2018-12-16 10:38:35] phpactor.DEBUG: Resolving: Microsoft\PhpParser\Node\Expression\Variable [] []
[2018-12-16 10:38:35] phpactor.DEBUG: RESPONSE {"action":"return","parameters":{"value":{"suggestions":[{"type":"variable","name":"$request","label":"$request","short_description":"StoreBalance","class_import":null,"info":"StoreBalance"},{"type":"variable","name":"$this","label":"$this","short_description":"BalanceController","class_import":null,"info":"BalanceController"}],"issues":[]}}} []
{
    "version": "1.0.0",
    "action": "return",
    "parameters": {
        "value": {
            "suggestions": [
                {
                    "type": "variable",
                    "name": "$request",
                    "label": "$request",
                    "short_description": "StoreBalance",
                    "class_import": null,
                    "info": "StoreBalance"
                },
                {
                    "type": "variable",
                    "name": "$this",
                    "label": "$this",
                    "short_description": "BalanceController",
                    "class_import": null,
                    "info": "BalanceController"
                }
            ],
            "issues": []
        }
    }
}%

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

and same error? have you also upgraded neovim recently or similar?

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

It was throwing an error so I upgraded neovim to follow HEAD since I thought I was missing some apis. However, nothing changes.

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

does any other RPC command work from within VIM? e.g. :call phpactor#Status()

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

Yes.

Info
----
Version: df27a0c (2 days ago) Adds-whatchanged-667
Work dir: /Users/juju/Development/Applications/neovim-qt/neovim-qt/build/bin

Diagnostics
-----------
[‚úî] XDebug is disabled. XDebug has a negative effect on performance.
[‚úò] Composer not found - some functionality will not be available (e.g. class creation) and class location will fallback to scanning the filesystem - this can be slow. Make sure you've run `composer install` in your project!
[‚úò] Git not detected. Some operations which would have been better scoped to your project repository will now include vendor paths.
Config files
------------
[‚úò] /Users/juju/.config/phpactor/phpactor.json
[‚úî] /Users/juju/.config/phpactor/phpactor.yml
[‚úò] /Users/juju/Projects/PHP/knights/.phpactor.json
[‚úò] /Users/juju/Projects/PHP/knights/.phpactor.yml

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024
Work dir: /Users/juju/Development/Applications/neovim-qt/neovim-qt/build/bin

should be the root of your project, did you start VIM in your project root?

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

I am using neovim-qt. Let me try form terminal

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

It works in terminal :)
But I have been using neovim-qt from its very early days. It never had such a probelm.
Is there any way to set the path manually?

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

you can call :let g:phpactorInitialCwd=/path/to/your/project' if that works, I'm not sure what has changed to cause this to stop working in neovim-qt

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

Setting the directory manually fixes the issue. THANKS :)

However, I still think that when I cd into a directory, phpactor should pick the current path.
This could be caused by neovim-qt as I upgraded that twoo

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

Ouch it just happened again :(
status:

Info
----
Version: 5eb7190 (3 hours ago) adds-title-to-links-page
Work dir: /Volumes/MacOS/Users/juju/Projects/PHP/Knights

Diagnostics
-----------
[‚úî] Composer detected - faster class location and more features!
[‚úî] Git detected - enables faster refactorings in your repository scope!
[‚úî] XDebug is disabled. XDebug has a negative effect on performance.

Config files
------------
[‚úò] /Users/juju/.config/phpactor/phpactor.json
[‚úî] /Users/juju/.config/phpactor/phpactor.yml
[‚úò] /Users/juju/Projects/PHP/knights/app/Http/Controllers/.phpactor.json
[‚úò] /Users/juju/Projects/PHP/knights/app/Http/Controllers/.phpactor.yml

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

However, I still think that when I cd into a directory, phpactor should pick the current path.

Yeah ... you and others :) I repurposed this to address this: phpactor/phpactor#660

Ouch it just happened again :(

Is that your project dir?

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

This happened even after setting the project dir manually

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

hmm, but this is only in nvim-qt? If so, I will have to try it I guess.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

Nope it happens in termianl nvim too :(

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

I'm still curious about:

[php]  syntax error, unexpected ')', expecting variable (T_VARIABLE) or '{' or '$'

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

It is shown by ALE (The linter). I think it is not related to phpactor.

The real problem for me is this. When this exception is thrown I have to press multiple keystrokes just to dismiss it. Then I press another letter and it happens again.
When phpactor works, it works great. However, when it fails, it fails in a really disturbing way.

[ncm2_phpactor@yarp] error caught in notification handler 'on_complete 
......................
....................
[ncm2_phpactor@yarp] Traceback (most re
[ncm2_phpactor@yarp] cent call last):
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/yarp.py", line 30, in on_notification
[ncm2_phpactor@yarp]     getattr(module_obj, method)(*args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2.py", line 206, in on_complete
[ncm2_phpactor@yarp]     on_complete_impl(context, *args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2_phpactor.py", line 55, in on_complete
[ncm2_phpactor@yarp]     for e in result['suggestions']:
[ncm2_phpactor@yarp] KeyError: 'suggestions'

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

Can't we wrap the error throwing part with a try: except KeyError: as a temporary fix. Since, this exception does not allow me to do any work and phpactor is too good to live without it.

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

It might be that it's a Phpactor issue (and for some reason we can't reproduce it), maybe you could hack Phpactor to catch exceptions in the RPC command?

Otherwise if you have a plugin that changes the CWD try disabling that (to isolate the issue)

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

maybe you could hack Phpactor to catch exceptions in the RPC command?

Could you give me some hints.

Otherwise if you have a plugin that changes the CWD try disabling that (to isolate the issue)

No plugin changes it since I am setting the path manually as you illustrated above.

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

I get

untitled

When loading nvim-qt, it works as expected after setting g:phpactorInitialCwd though.

If I try and use omni complete I get

untitled

Which is at least a handled error. The NCM2 error should indeed not happen and is a regression.

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

Have created https://github.com/phpactor/ncm2-phpactor/pull/13/files to ignore errors from Phpactor, and phpactor/phpactor#676 to log errors in Phpactor which are encountered during the complete command (standard RPC calls handle exceptions well, but the complete command is older and does not currently).

Hopefully this will enable us to shed more light on this issue and prevent VIM from spamming you with errors.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

I updated phpactor to include your new patch and applied #13 manually.

The exceptions are thrown rarely. 👍

Yet sometimes I get this new exception:

[ncm2_phpactor@yarp] error caught in notification handler 'on_complete [{'filepath': '/Users/juju/Projects/PHP/knights/app/Http/Controllers/BalanceController.php', 'typed': '        $', 'scope_match': 'php', 'startccol': 9, 'scope_level': 1, 'word_pattern': '[\\$\\w][\\w]*', 'time': 1545192682.953121, 'lnum': 69, 'bufnr': 3, 'changedtick': 5, 'manual': 0, 'base': '$', 'ccol': 10, 'filetype': 'php', 'curpos': [0, 69, 10, 0, 10], 'tick': [[0, 69, 10], 0], 'early_cache': False, 'context_id': 31, 'scope': 'php', 'matcher': {'name': 'abbrfuzzy'}, 'source': {'on_complete': 'ncm2_phpactor#on_complete', 'subscope_enable': 1, 'early_cache': 0, 'name': 'phpactor', 'scope': ['php'], 'mark': 'b', 'on_warmup': 'ncm2_phpactor#on_warmup', 'ready': 1, 'enable': 1, 'auto_popup': 1, 'priority': 9, 'complete_pattern': ['\\$', '-\\>', '::'], 'word_pattern': '[\\$\\w][\\w]*'}, 'bcol': 10, 'match_end': 9}, ['<?php', '', 'namespace App\\Http\\Controllers;', '', 'use App\\Http\\Controllers\\Controller;', 'use Illuminate\\Http\\Request;', 'use Spatie\\QueryBuilder\\QueryBuilder;', '', 'use App\\Balance;', 'use App\\Office;', 'use App\\Merchant;', 'use App\\Product;', '', 'use App\\Http\\Requests\\Balances\\StoreBalance;', 'use App\\Http\\Requests\\Balances\\UpdateBalance;', 'use App\\Http\\Requests\\Balances\\RemoveBalance;', '', 'class BalanceController extends Controller', '{', '    /**', '     * Create a new controller instance.', '     *', '     * @return void', '     */', '    public function __construct()', '    {', "        $this->middleware(['auth', 'user.id']);", "        $this->middleware('permission:view_balance', ['only' => ['index', 'list']]);", "        $this->middleware('permission:create_balance|create_transaction', ['only' => ['create']]);", "        $this->middleware('permission:update_balance', ['only' => ['update']]);", "        $this->middleware('permission:destroy_balance', ['only' => ['destroy']]);", '    }', '', '    public function index()', '    {', "        return view('balances.index');", '    }', '', '    public function list(Request $request)', '    {', '        return QueryBuilder::for(Balance::class)', "            ->LeftJoin('products', 'balances.product_id', 'products.id')", "            ->LeftJoin('merchants', 'balances.merchant_id', 'merchants.id')", "            ->selectRaw('balances.*, merchants.name as merchant_name, merchants.phone as merchant_phone, products.name as product_name, products.amount_limit as amount_limit')", '            ->allowedFilters(', "                'balance',", "                'balances.id',", "                'expiry_date',", "                'products.amount_limit',", "                'balances.car_limit',", "                'products.name',", "                'balances.note',", "                'products.name',", "                'merchants.name'", '            )', "            ->orderBy('id', 'desc')", '            ->jsonPaginate();', '    }', '', '', '    /**', '     * Create a new _balance instance after a valid registration.', '     *', '     * @param  array  $data', '     * @return \\App\\Balance', '     */', '    protected function create(StoreBalance $request)', '    {', '        $', "        $product = Product::where(['name' =>$request->product_name])->firstOrFail();", '', "        $merchant_id = merchant::where(['name' =>$request->merchant_name])->firstOrFail()->id;", '', '', "        if($product->requiresCarBalance() && !$request->filled('car_limit'))", "            return ezReturnErrorMessage('Number of cars is required!');", '', "        $balance = Balance::create(array_merge($request->input(), ['product_id' => $product->id, 'merchant_id' => $merchant_id]));", '', "        return ezReturnSuccessMessage('Balance created successfully!', $balance);", '    }', '', '    public function update(UpdateBalance $request)', '    {', '        $Balance = Balance::findOrFail($request->id);', '', '        $Balance->update($request->input());', '', "        return ezReturnSuccessMessage('Balance updated successfully!');", '    }', '', '    public function destroy(Request $request)', '    {', '', '        $Balance = Balance::findOrFail($request->id);', '', '        $Balance->delete();', '', "        return ezReturnSuccessMessage('Balance removed successfully!');", '', '    }', '', '    public function balanceSufficesTransaction(Request $request){', "        if(    !$request->filled('product_name')", "            || !$request->filled('merchant_name')", "            || !$request->filled('transaction_cars'))", "            return ['result' => null];", '', "        $product = Product::where(['name' =>$request->product_name])->first();", "        $merchant = merchant::where(['name' =>$request->merchant_name])->first();", '        if($product == null || $merchant ==null)', "            return ['result' => null];", '', '        if(!$product->requiresBalance()){', "            return ['result' => true];", '        }', '', '        $transactionCars = collect(json_decode($request->transaction_cars));', "        $incomingTransactionAmount = $transactionCars->sum('amount');", '', "        return ['result' => $merchant->hasBalanceForIncomingAmount", '            ($product->id, $incomingTransactionAmount)];', '    }', '', '    public function productBalance(Request $request){', '', "        if(!$request->filled('product_name'))", '            return;', '', '        $balanceInfo = [', "            'product_requires_balance' =>null,", "            'rows' => []", '        ];', '', '        //Data template', "        //[{name:'n11',value:'v12',editor:'text',group:'Product Information'}]", '', "        $product = Product::where(['name' =>$request->product_name])->first();", '', '        if($product == null)', '            return $balanceInfo;', '', "        $balanceInfo['product_requires_balance'] = $product->requiresBalance();", '', '        $this->setProductInformation($product, $balanceInfo);', '        $this->setCheckTypeInformation($product, $balanceInfo);', '        $this->setBalanceInformation($product, $balanceInfo);', '        return $balanceInfo;', '', '    }', '', '    function setProductInformation($product, &$balanceInfo)', '    {', '        if($product->requiresBalance())', '        {', "            $balanceInfo['product'] = $product;", "            $balanceInfo['merchant'] = $product->requiresBalance();", "            array_push($balanceInfo['rows'], ['name'=>'Name','value'=>$product->name,'group'=>'Product Information']);", '            array_push($balanceInfo[\'rows\'], [\'name\'=>\'Requires Balance\',\'value\'=>\'<span style="color:red; font-weight:bold;">Yes</span>\',\'group\'=>\'Product Information\']);', '', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Has Amount Limit',", "                    'value'=> $product->requiresAmountBalance() ? 'Yes' : 'No',", "                    'group'=>'Product Information'", '                ]);', '', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Has Car Limit',", "                    'value'=> $product->requiresCarBalance() ? 'Yes' : 'No',", "                    'group'=>'Product Information'", '                ]);', '', '            if($product->amount_limit != null){', "                array_push($balanceInfo['rows'],", '                    [', "                        'name'=>'Amount Limit',", "                        'value'=>$product->amount_limit . ' ' . $product->amount_limit_unit . '(s)',", "                        'group'=>'Product Information'", '                    ]);', '            }', '', '            if($product->date_limit != null){', "                array_push($balanceInfo['rows'],", '                    [', "                        'name'=>'Day Limit',", "                        'value'=>'Expires in '.$product->date_limit. ' days',", "                        'group'=>'Product Information'", '                    ]);', '            }', '        }', '        else {', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>'Requires Balance',", "                    'value'=>'No',", "                    'group'=>'Product Info
[ncm2_phpactor@yarp] rmation'", '                ]);', '            return $balanceInfo;', '        }', '    }', '', '    function setCheckTypeInformation($product, &$balanceInfo)', '    {', "        $checkTypes = \\App\\CheckType:: LeftJoin('product_check_type', 'product_check_type.check_type_id', 'check_types.id')", "            ->selectRaw('id,category,subcategory,price')", "            ->where('product_id', $product->id)->get();", '', '        foreach($checkTypes as $checkType)', '        {', "            array_push($balanceInfo['rows'],", '                [', "                    'name'=>$checkType->category,", "                    'value'=>$checkType->price,", "                    'group'=>'Test Information'", '                ]);', '        }', '    }', '', '    function setBalanceInformation($product, &$balanceInfo)', '    {', "        if(request()->filled('merchant_name') && $product->requiresBalance())", '        {', "            $merchant = merchant::where(['name' =>request()->merchant_name])->firstOrFail();", '            $balance = Merchant::findOrFail($merchant->id)', '                                                 ->balance($product->id);', '            if($balance == null || $balance->is_expired){', "                array_push($balanceInfo['rows'], ['name'=>'Balance','value'=>'No balance','group'=>'Balance Information']);", '', '            }', '            else {', '                if($product->requiresAmountBalance()){', "                    array_push($balanceInfo['rows'],", '                        [', "                            'name'=>'Amount Left',", "                            'value'=>$product->amount_limit - $balance->amount() . ' ' . $product->amount_limit_unit . '(s)',", "                            'group'=>'Balance Information'", '                        ]);', '                }', '                if($product->requiresCarBalance()){', "                    array_push($balanceInfo['rows'],", '                        [', "                            'name'=>'Cars Left',", "                            'value'=>$balance->car_limit - $balance->cars() . ' Car(s)',", "                            'group'=>'Balance Information'", '                        ]);', '                }', '                if($balance->expiry_date !=null)', '                {', "                    array_push($balanceInfo['rows'],", '                        [', "                            'name'=>'Expiry Date',", "                            'value'=>$balance->expiry_date->format('d/m/Y h:i:s'),", "                            'group'=>'Balance Information'", '                        ]);', "                    array_push($balanceInfo['rows'],", '                        [', "                            'name'=>'Days Left',", "                            'value'=>$balance->expiry_date->diffForHumans(\\Carbon\\Carbon::now(), true, true, 3),", "                            'group'=>'Balance Information'", '                        ]);', '                }', '            }', '', '            if($product->requiresCarBalance()){', '', "                array_push($balanceInfo['rows'], [", "                    'name'=>'Number of Cars',", '                    \'value\'=>\'<span class="textbox" style="width: 123px;"><input  id="transaction_balance_car_limit" type="text" class="textbox-text textbox-prompt" autocomplete="off" tabindex="" placeholder="" style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 125px;"></span>\',', "                    'group'=>'New Balance'", '                ]);', '            }', "            array_push($balanceInfo['rows'], [", "                'name'=>'',", '                \'value\'=>\'<a href="#" class="easyui-linkbutton l-btn l-btn-small" iconcls="icon-add" onclick="addTransactionBalance(\\\'\'. $product->name .\'\\\',\\\'\'. $merchant->name .\'\\\')" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Add New Balance</span><span class="l-btn-icon icon-add">&nbsp;</span></span></a>\',', "                'group'=>'New Balance'", '            ]);', '        }', '    }', '', '', '}'], '/Users/juju/Projects/PHP/knights/app/Http/Controllers', ['php', '/Users/juju/.config/nvim/dein/repos/github.com/phpactor/phpactor/plugin/../bin/phpactor', 'complete', '-d', '/Volumes/MacOS/Users/juju/Projects/PHP/Knights', '--format=json', '--', 'stdin', '2056']]'
[ncm2_phpactor@yarp] Traceback (most recent call last):
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/yarp.py", line 30, in on_notification
[ncm2_phpactor@yarp]     getattr(module_obj, method)(*args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2.py", line 206, in on_complete
[ncm2_phpactor@yarp]     on_complete_impl(context, *args)
[ncm2_phpactor@yarp]   File "/Users/juju/.config/nvim/dein/.cache/init.vim/.dein/pythonx/ncm2_phpactor.py", line 41, in on_complete
[ncm2_phpactor@yarp]     result = json.loads(result)
[ncm2_phpactor@yarp]   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
[ncm2_phpactor@yarp]     return _default_decoder.decode(s)
[ncm2_phpactor@yarp]   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
[ncm2_phpactor@yarp]     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
[ncm2_phpactor@yarp]   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
[ncm2_phpactor@yarp]     raise JSONDecodeError("Expecting value", s, err.value) from None
[ncm2_phpactor@yarp] json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

from ncm2-phpactor.

dantleech avatar dantleech commented on August 24, 2024

actually, since that's a JSON decode error, Phpactor may not even be logging that error.

Enable logging in NCM2 instead, run:

export NVIM_PYTHON_LOG_FILE=/path/to/where/log/should/be
export NVIM_PYTHON_LOG_LEVEL=DEBUG
nvim-qt

ncm2 should then produce a bunch of log files one of them should end with _py3_ncm2_phpactor
here you will see the actual response text that Phpactor returned.

from ncm2-phpactor.

khalidchawtany avatar khalidchawtany commented on August 24, 2024

If I set export NVIM_PYTHON_LOG_LEVEL=DEBUG nvim python provider fails. I have to first report this to neovim :(

screen shot 2018-12-20 at 9 11 01 am

from ncm2-phpactor.

eddy147 avatar eddy147 commented on August 24, 2024

Any news on this?

from ncm2-phpactor.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.