Closed klesun closed 3 years ago
When you are typing array keys in a doc it would be VERY convenient if caret position was indented after a line break. (and add closing brackets btw) https://github.com/klesun/deep-assoc-completion/commit/e28b45e7db3f76b7c80a5936a70dcad5651f243d
should not suggest numeric keys for indexed arrays in usage-based completion. 2f08286d523870227e82aedb8b3c4957f9544bae
Provide array static method name completion even with $this
, like [$this, 'getRateAmount']
since writing $this
is usually more convenient than self::class
(5 characters vs 11). These options should be highlighted somehow and put to the bottom to make it clear that they are static.
Could show them without bold like IDEA does for inherited methods. Would be also nice to do same with 1,2,3,4,5
completion when there are string key name options, from recursive ParamUtil::sample()
for example. a4cd89cb080d1f3644f16b14211c32b79d058961
When both this plugin and deep-js-completion are loaded, make /** @var $formData = at('mcoForm.js').makeFormData() */
provide completion using the type resolution from the other plugin. 9a5a8295b9e28834a64dea3cd2547ad92369a48b
A bug, plugin makes static calls suggest non-static methods: 56ab8c5fedb70b76fde43c5036982233c958883f
For some reason, using undeclared $i
variable in the doc does not give me any key, whereas using $any
does. Is there some global $i
variable declared in the project? Same expression in the code does give completion so I guess not...
Also, an unrelated issue, but $object
type does not get resolved from private func usages when you specify type in some other file like this: @param $agents = [AgentImportV11::normalizeActive()]
3cb5ac23c88b97ed3315cb2b86b237456dfb0d91
There are also various function that take/return some constant values, would be nice to hardcode them as well (regex, curl, mysql, PDO, LIBXML, FILE_APPEND, SORT). Making built-in function constants popup without '' woul be good too. Would be nice if completion worked in a bit mask as well. 460a80259ac63726da13827e5c80fe8d8adc1ad4
Support SQL::select
in CMS. I guess all that is needed is to start supporting mysqli, not just PDO. 36bcca2a2099a89325e3bc673896aac825162560
A bug, when you try to Ctrl + B on a non-literal key in an assignment, you get redirected to this same assignment instead of built-in Go To of the key expression:
$gdsToStatus[$gds->getName()] = $status;
When I Ctrl + Click getName
I want to get to the function getName
definition, but I don't - should fix. (Reproduces only when getName
is a magic method, plugin's member Go To fires otherwise probably) e0c56dc105ca4b1e55822783d5c73e9ca48f2f21
Implement used key completion for built-in functions like stream_context_create()
:
stream_context_create([
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
]);
I believe there were some more functions that take associative array arguments... curl_setopt_array()
maybe? 793e4949e342d5934280c8f3137907da88a7d033
Completion of string value passed to the function if this string is used as key name inside: 6e43e280974e22f7f5fe9f82ffc97cbdcce347b6
public function __construct(string $profile)
{
$this->profile = $profile;
if ($settings = $this->getProfiles()[$profile] ?? null) {
$this->setting = $settings;
} else {
throw new \Exception('Unknown profile ['.$profile.']');
}
}
$client = new \Delpaso\DelpasoSoapClient('');
Show comments typed above or right to a key in the completion if any instead of a brief value: 83be277e97e1bc15a144c7b07599143b10545f7e
/**
* @param $dict = [
* 'dbName' => 'rbstools', // name of the MySQL database
* // IP address of the database
* 'host' => '192.168.0.1',
* ]
*/
Class/Method completion should work in the multi-line doc comments: d30957e5e4b57de35b9cc027e5beb1ae7ce83f15
/** @param $params = [
* 'status' => 'price_dropped',
* 'oldPrice' => '1500.00',
* 'newPrice' => '1400.00',
* 'oldPtcBlock' => ApolloPricingAdapter::transformPtcBlock(),
* 'newPtcBlock' => [], // ...
* 'oldMods' => [], // ...
* 'newMods' => [], // ...
* 'oldPricingDump' => '>*LF ...',
* 'newPricingDump' => '>$B ...',
* 'pnr' => ApolloPnr::makeFromDump(),
* ]; */
public function execute(array $params);
I guess next lines are a separate PSI, that's why completion does not work. Related to #40
Provide variable name completion and Go To from extract()
. Since we already do so for compact()
and $GLOBALS
. 2197a04a44d03231f274e2501fefdcd19f0ce11e
Provide Used Key Completion in CMS framework Model::getOne(['' => '123'])
, Model::get(['' => '123'])
and ModelParams::filter(['' => '123'])
. https://github.com/klesun/deep-assoc-completion/commit/4bb771d2e8d61d6381fd75b069e3dc3d14bb58a8
Infer type of $someCls = static::class
and $obj = new $someCls();
so that I would get completion in $obj->...
. (GTL, Amadeus Controller) https://github.com/klesun/deep-assoc-completion/commit/d6d971890ddf2dfab09997bbf43a1a921a40bb38
/** @var RbsPnrAdapter $rbsAdapter */
$rbsAdapter = app()->make(RbsPnrAdapter::class);
$parsedPnr = $rbsAdapter->parsePnr($data['msg']);
Add support for array_fill_keys
. Also, array_replace
should take type from all passed arrays, not just first. 5be88a4
It should be easy to make Used Key Completion suggest SQL query params used in the query like col_name = :var_name
. At least suggest completion in the array. Though to suggest completion in the SQL string it should also be pretty easy:
$row = Db::inst()->fetchOne(implode(PHP_EOL, [
'SELECT * FROM pnrs_for_price_drop_monitoring',
'WHERE gds = :gds AND record_locator = :record_locator;',
]), [
'' => $job['record_locator'], // completion here
]);
https://github.com/klesun/deep-assoc-completion/commit/ef0abbf38886abf95305aa1b0363a9e72fcd7057
To N-th test should work even when caret is not inside a function - take all @dataProvider
-s in the file, if there are many - use first having at least N
tests. https://github.com/klesun/deep-assoc-completion/commit/a8ebf5ac816336ee33bd7aa5cf525ccb6145bc12
When you Ctrl + B on a key you got from array_keys()
call, you should be redirected to the definition of this key, not to the array_keys
expression:
$arr = ['itinerary' => ['KIVKBP', 'KBPRIX'], 'paxes' => ['Vova', 'Petja']];
$keys = array_keys($arr);
$newArr = [];
foreach ($keys as $key) {
$newArr[$key] = 'new value';
}
$newArr['itinerary'];
Same probably should apply to other functions like array_combine
, etc... I believe, for array_combine
it was even already implemented. https://github.com/klesun/deep-assoc-completion/commit/ff428124f3f617f9b3889507a6680f489b033cf0
I believe irrelevant options (oneOf
, minLen
, pattern
, etc...) can be removed from here if you check for class when getting constructor arguments:
The irrelevant options get here from the second argument passed to new StringP
because plugin thinks they are same thing as second argument passed to new DictP
. And it thinks this way because IDEA assigns DictP type to the $scheme
var in $scheme instanceof DictP
.
https://github.com/klesun/deep-assoc-completion/commit/678f4b590bf87b1a1f2d8fc035c4b397f50e59cf
Method name completion should work on 'processPnrSchema' here: /** @param $params = ParamUtil::sample(AmadeusController::processPnrSchema()) */
5de5d72ec21b9e23574487241e0a770950ea1c1f
@return
doc should be infered from implemented interface:
$gtlResult = GtlProvider::get()->getAmadeusPnr([
'recordLocator' => $this->recordLocator,
'sessionToken' => $this->getSession()->getSessionToken(),
]);
$gtlResult->unwrap()['']; // completion should be here
https://github.com/klesun/deep-assoc-completion/commit/0879071e73fee5ee558479ccc5ddf5612a4798ca
Add key completion from stream_get_meta_data
and curl_getinfo
that return associative array. It would also be nice to add more such functions if I manage to find them. https://github.com/klesun/deep-assoc-completion/commit/74263ffc4f6d986a5bf8fce2d05365ac2c3dea66
Add completion and Go To to the array_key_exists
same way as it is done for array_column
896d8d4bea7b1868c18b9a423ecb406cbe57c629
explode()
and other similar functions return type should be resolved as indexed array of strings. e3f54bf743081b9e11c2a551040424c3d6b04671
Completion should work here:
$onlyRaw = function($matches){return ['raw' => $matches[0], 'parsed' => null];};
$lexer = new Lexer([
(new Lexeme('returnDate', '/^¥R(\d{1,2}[A-Z]{3}\d{0,2})/'))->preprocessData($onlyRaw),
]);
$lexed = $lexer->lex($modsPart);
$lexed['lexemes'][0][''];
$lexed['lexemes'][0]['lexeme'] === '';
Does it not work because of caching? eeee3f9968c0ffd8ce1ebeb290bbdc4ffdd06431
A bug: method name completion in @return
tag does not work if neither array
type nor =
are specified. Class name completion works though... 4c879a76a16309b24c2753531e550af7769d17e5
Also provide completion of methods from self::
by the way. https://github.com/klesun/deep-assoc-completion/commit/5b5124263db8b87110d49b8ab236336e9edc349a
Provide doc completion in @var
tag same as in @param
tag. https://github.com/klesun/deep-assoc-completion/commit/c483038106233e575c1a180b88090c341a2af8d4
/** @var $avail = AbstractTravelportController:: */
$avail = $gtl->performRequest('apollo.xml.getHotelAvailability', [
Also provide function name completion and GoTo in @return
tag. https://github.com/klesun/deep-assoc-completion/commit/6f2ed38f6173ce2e3a568744ea3c2abcf4b33beb
It would be much more usefull if Ctrl + Alt + Q keys were in php array format, not json, since you would usually have to change 15d48a2c1d9eb1f262e736ea98ae7a8c812bd1f8:
-s to =>
when you copy them somewhere. Also Ctrl + C stopped working in this dialog window, should fix this too.
'ptc' should be suggested here: 15db08713527689166b9d58ad877d02dc78b0d20
if ((new Lexeme('ptc', '/^\*([A-Z0-9]{3})/'))->name === '') {
// ...
}
15db08713527689166b9d58ad877d02dc78b0d20'start'
and 'value'
should be suggested here (and in in following map
chains).
\Lib\Result::makeOk(['start' => 123, 'value' => 123])
->flatMap(function($value){$value[''];});
adb505d70a33fcc79a958451acb7446d6e53dd62'cat'
, 'dog'
, 'monkey'
should be suggested here
$animals = ['cat', 'dog', 'monkey'];
$i = rand(0, 10);
if (($animals[$i] ?? null) === '') {
}
- ~~It would be very very good if `Find Usages` on a method used this way would return something:~~
```php
Fp::any(
[static::class, 'isTourFare'],
$pricingStoreInfo['pricingList'] ?? []
)
0364a222275da8e2708e8255fc1f5287d206beb4
When you are writing php doc for completion, it would be nice if it suggested you key names here, not just method name:
/** @param $ssrs = SiParser::parse()[''] */
public static function transformDocSsrs(array $ssrs)
{
}
bfa6a63c44ff7398546c3c75bcf12cdf53607c93
Used keys completion should be inferred from abstract method implementation. Moreover, it would be very nice if we used only the function of exact class if we know it. Completion should work here:
$result = (new \Gtl\AmadeusSoapActions\AmadeusListQueuePnrs('GENERIC'))
->execute([
''
]);
c12fad2c408e8ca60bd761b672a0fc55a203c03c
Support 7dbc9d76f82ef3c9ae26d62c8ea3404fae1a0c98@return array like ['a' => 5]
and @return array ['a' => 5]
and @return ['a' => 5]
7ab23fa0db49d011286e963526adde9dc9d2e8cdarray_intersect($cmdTypes, ['redisplayPnr', 'itinerary', 'airItinerary', 'storeKeepPnr', 'changeArea', ''])
...please?
Top Featur: Go To Test by number.
You press Ctrl + Alt + ;, enter the test number $i
from here:
~~70) Rbs\GdsDirect\DialectTranslator\GdsDialectTranslatorTest::testTranslator with data set #2078~~
Plugin looks at return type of
eedb81b2e7a212e8dfc982b8883e1c5b68e34063@dataProvider
function and navigates you to the declaration of $i
-th element (if just one).
Also the string values completion https://github.com/klesun/deep-assoc-completion/commit/d6883a306ad30751b1de7d8a7e1717bef66dc61c$type === 'ITINERARY_SEGMENT'
should also work with in_array($type, ['ITINERARY_SEGMENT'])
Similar to recent feature, cb9a445fcdfb6528ff4879c91c3fa95cdb5b5010if (in_array('deletePnrField', array_column($flatCmds, 'type'))) {
should provide completion and Ctrl+B (this time we need completion in needle, not haystack). in_array('', $remarkTypes)
Add an option in config (disabled by default) to remove unused . 94628387635233371b4bccc96b76d2be1122025cuse
-s on save without changing order of other use
-s
Same applies for keys assigned like that: 03f802770b4aa72c8eaa434814af67cf3b0eb19a$pnrFields[$name] = $result
- Go To key should lead to the string literal, not assignment expression.
Ctrl+B should work on $type === 'ITINERARY_SEGMENT'
. And Ctrl+B on keys created in array_combine
should lead to the string literal, not the array_combine()
expression.
Should make a page in Options page where following will be configurable:
false
, since it causes problems for Laravel users.5
by default and play with it later in RBS.~~It would be good if type of what you pass to the constructor could preserved in the object:~
Following code should provide completion:
Result::makeOk(['a' => 5, 'b' => 4])->unwrap()[''];
326466bf685bc0fc3c422c1f5848a176c16ea5d0
Infer type when associative arrays are merged with
08d17d1ed0517300c21e8944c37de5a43a4c58ad+
:
Completion should work with iterator functions: b5a460ceb52d767c78ac149990c8b1f4bf4021b8
key(), current(), next()
:
IDEA often suggests handy Go To Definition on function references like this cf0cd428f9f2c371d0dd0f946ca8c3d3792690bd[static::class, 'makeDocsCmd']
. Sadly they are suggested only when array is passed directly somewhere with callable
type hint. So I'd like to add a Go To Definition provider that would suggest the Go To on any array having form similar to: [static::class, 'makeDocsCmd']
.
It would be nice when you press Ctrl + Alt + Q on an argument in function declaration that you would get the keys that are used on that var (the keys used in the KeysFromUsagePvdr.java). 83bf1cb9257a2233821a3f4b035be9c1291a12ca
Provide completion inside 4605a472d3b2068881259c6c43b4e6d6be32a10d[]
, not just ['']
. Now this will be usefull since I can now put mine options to the top of the list - hundreds of expressions suggested by phpstorm is not problem anymore.
It would be useful if I could have completion from SQL SELECT
-s:
SELECT
and FROM
by ,
, use text after AS
or last \w
part as key name.'SELECT',
' s.id,',
' s.is_active,',
' s.gds,',
'FROM terminal_sessions s',
upgrade_sql.php
on SELECT *
could be done, but not sure, since it's usually huge... May also look at the IDEA's feature to plug your DB for schema...
Now, that i think about it, maybe there is no need for project-specific configurations. I got Fp::
resolved automatically thanks to return type based on passed args, maybe something similar could be done for the PDO
? Like $stmt = PDO::$connection->query($sql)
or $stmt = PDO::$connection->prepare($sql)->execute($params)
followed by $stmt->fetch(\PDO::FETCH_ASSOC)
returns rows from $sql
...~~
1569db36cd4c7e40739bea3f43ecca6daec01c9bCompletion in 1d890887698e9d45897fe9a1ef142cecbc0ecd73array_merge($default, [''])
, array_replace($default, [''])
and others if any.
It would be good to make completion appear on it's own (with a 0.05s timeout) when user puts caret in quotes, but should be very careful to not cause freezing, cuz i personally hate it. 266edef3b1818394553d05759a0b817542881bb2
Show array keys in the short completion type preview. We already know them, so this should not cause additional load. e213e6ee1536c5099b11e7f5384a865af3a742e2
Irrelevant built-in suggestions are pissing me off. I already know that i can't set priority of my suggestions higher using Lookup. Maybe i can interact with the completion window itself by moving pointer to my suggestions or (ideally) remove duplicating built-in suggestions. Ability to increase the length of this window would be nice too (only 4.5 lines at once fit).
e2c2a0bd83fbedbe9d107af0da14cce60786e5ab
b815e879ac01ce5fea67688db0a2370213052add
Completion inside a lambda assigned to a variable based on usage like in the assoc array initialisation. Vary please! semi-done: c8f96bca7e0e62f59b8f47aa1776cc98fb086b54
Fp
functions: map
, filter
, groupBy
, etc...array_reduce
and not provide completion if user mismatched array and func in array_filter
arguments.Completion from cb4a2f3eaca7a8db2bf6020f1e7ae9ba7957abb3@dataProvider providePricingToWrongDestinationTests
in phpunit tests
Currently i provide object class info in such expressions: 450c6a4d205cc048f194f75edd844f8bfc60934d$dumpData['itinerary']->segments
, $dumpData['itinerary']->getCabinClass()
. Class info should also be provided in assignments to a var $itin = $dumpData['itinerary']
Autocomplete inside
870d66907f73a40aaf63847f102e81d7d1977c4c - array_map
and array_filter
.array_map
f1226f79b51a992a2a1b725c77c658aeec7fbf7f - Fp::map
~~When suggesting completion in the doc for an interface class - include abstract methods as well (currently i return only getOwnMethods
, which apparently does not inclide them).
Example:~~ a9ae5eb0c00a74db6c1062039683d04375d0838b
@param $pricingStoreInfo = IGdsPnrFieldsProvider::
doh, there is more to it, apparently completion of interface methods from docs does not work at all unless you specify the full namespace to the interface.
Completion of function name when you are making a reference using array would be nice: 2eb655226f56882170d3df1f299dbccb0df58197
[ApolloReservationItineraryParser::class, '']
.
Completion/Go To Definition in
dcd1b97129443fccf6b9b1b65e0ec711b5c97080 - completion
26e1d63c3c38afaadf2ee2714ee563730ab10d26 - go to definition
array_column
@klesun how about suggetions of keys from arrays returned by php internal functions? Like for example debug_backtrace
@Jurigag, sounds good. I'm actually already doing this for a set of functions I managed to find, but apparently debug_backtrace
wasn't among them. I'll add debug_backtrace
to the list soon. If there are any other functions on your mind, I'll gladly add them as well.
Added support for debug_backtrace()
in 2019.04.11.001
Cool.
I'm also wondering if you could provide some way to define those possible keys for 3-rd party php extensions using php stubs(just empty php classes with phpdocs definitions)? Like for example, there is c-based framework called phalcon, which just works as extension. There is method like \Phalcon\Mvc\Model::findFirst()
which can accept array like this:
$robot = Robots::findFirst(
[
"type = 'virtual'",
'order' => 'name DESC',
'limit' => 30,
]
);
Of course adding it for all extensions possible would be a a lot of effort. Maybe you could implement syntax using some kind of annotations so for example here https://github.com/phalcon/ide-stubs/blob/master/src/Phalcon/mvc/Model.php#L559 we could just add some magic thing which would your extension then use and autocomplete those keys above, like order limit etc?
@Jurigag, if you are a contributor of phalcon/ide-stubs
, you can specify function argument type for the plugin like this:
/**
* @param mixed $parameters = [
* 'type' => 'virtual',
* 'order' => 'name DESC',
* 'limit' => 30,
* ]
* @return Model
*/
public static function findFirst($parameters = null) {}
Oh, thanks for this.
It would be nice to have an ability to use annotation from the PSALM static analysis. We already use it for the type analysis, so autocompleat would be the great feature in additional.
This is an example from the documentation https://psalm.dev/docs/docblock_type_syntax/#array-types
and one from me:
/** @var \Generator<array{
* itemNo:string,
* variants:array<array{
* Code:string,
* stock:array<array{
* serialNo:string,
* locationCode:string,
* differentialTaxation:bool
* }>
* }>
* }>
* $products
*/
Thanks!
Filed a separate issue - https://github.com/klesun/deep-assoc-completion/issues/77
Hello, could you tell me if it's possible to describe somehow the possibility to support a collection of assoc arrays? What I mean is the next:
[
[
'user' => [
'id' => 123,
'name' => 'Joe',
],
], [
'order' => [
'id' => 21,
'offer_id' => 212,
],
], [
'offer' => [
'id' => 212,
'name' => 'Toys',
],
],
]
So I could describe a possible set of options and then I can use it in any order?
@mialex, you can use psalm format (just added support for |
in 2019.05.29.001):
Another trick would be to use an undefined var (for example $any
) as key:
@param $records = [
$any => ['user' => ['id' => 123, 'name' => 'Joe']],
$any => ['order' => ['id' => 21, 'offer_id' => 212]],
$any => ['offer' => ['id' => 212, 'name' => 'Toys']],
]
Im wondering if it's somehow possible - add autocomplete based on xdebug variables? @klesun
@Jurigag, if this is just a static set of keywords, no problem. Could you provide a link describing them?
Well i mean when xdebug session is active. Like suggest keys here:
https://github.com/klesun/deep-assoc-completion/issues/110 I'll look into that. If there will be a usable xdebug API in the phpstorm I'll add it.
Closing as no time for implementing the remaining minor features in the list. If someone considers some particular ones a must-have, please open a separate ticket.
Not Resolved Yet
Here are listed some small things that are relatively easy to implement and do not affect the whole behaviour much. Some stuff lays here for pretty long time, so if you are interested in some of these features, you can ping me, I'll start doing it. Otherwise I will implement the feature only when I need it in some of my php projects (whcih may happen... not very soon).
Make used key completion support key chain like this:
$rcvd['rcvd']['originData']['receivedFrom']
(currentyl it only suggests the'rcvd'
key)Rewrite
getBriefValueStr
so that it worked with the iterator, not array - just take first few type till string fits into the n characters.It would be cool to have both project-level and IDE-level settings...
It would be nice if functions in doc comments were captured by the reference provider...
Maybe make dependency on DB plugin optional? It would make sense if you keep useless plugins disabled to speed up startup...
Maybe infer type of
json_decode('{"a":"5", "b": 6}')
, but with very strict depth limit and guards for >1 MiB files.Support GoTo method name in multi-line php doc
Infer dynamic property assignment and
json_decode(json_encode(..., $flag))
.BagAccess.php
:It would be pretty cool if completion worked here:
IDEA does the job when there is no concatenation, but this is not always the case. So I suggest to provide the completion in any string that matches pattern
JOIN {tableName} alias ON alias.{suggestColumnsHere}
. Could go even further and actually semi-parse whole SQL string and provide completion inWHERE
,SELECT
,GROUP BY
, etc... as well.Go To column in DB schema in the "Database" tab instead of just the
Db::exec()
expression.It would be nice if Reference Provider highlighted same key on same variable/field in a function.
Used key completion should work here:
Infer arguments inside lambda passed to something other than50f0bf275976e21e774ae37603f0724db8e54be6array_map
like here:Actually I already do something similar -Should supportArgRes::getFuncVarUsageArg()
. Could at least make it infer type only from the direct function it is passed to to not waste performance... or put some sane depth limit.array_map
and other built-in functions there. See TODO inArgRes::getArgFromMethodCall()
Provide array structure description in built-in "Show Docs" pop-up that is shown when you press Ctrl + Q instead of separate (Ctrl + Alt + Q) shortcut. This time i should handle it, it did not work initially because of absence of "order"="first" likely. Btw, would be nice if docs were also shown when you press the shortcut inside quotes (we don't always have a var).
Support vars in
""
string literals: