Sublime Forum

PHP Completions

#1

Iā€™m on Build 2181 so Iā€™m unsure if** PHP.sublime-completions** has been updated recently. Nevertheless, Iā€™m revising this file - see my GitHub.

The most significant difference is that Iā€™ve commented out a (very) large number of ā€œlibrariesā€. They have been moved to **PECL **extensionsā€™ control anyway, and I donā€™t want them to display by default. If I decide to use them I will just un-comment the relevant section in my completions file. There is a text file on my GitHub with more details, including a list of the extensions I have commented-out, and other information.

Iā€™ve added in a (v. large) number of new functions;
Iā€™ve switched the order of the mysql functions with their mysqli versions;
Iā€™ve updated lots of parameters (but I havenā€™t managed all of them yet!);
Iā€™ve favoured the correct (Pascal) casing for classes, interfaces and exceptions;
Iā€™ve mainly kept the proceduralā€™ functions, rather than their OO equivalent methods, except for the DOM library (where Iā€™ve done the reverse).
[Adding all the OO-methods will make the file twice as largeā€¦]

**NB **If you update to a future build you may find that PHP.sublime-completions is added, or over-written, so you might keep a copy of my version separately.

If you spot any typos, or have any suggestions, I will be glad to hear from you :smile:

0 Likes

#2

**PS **Iā€™m attempting to strike a balance when supplying parameters: that is, between providing useful information, and not being over-whelming/overly fastidious.

For example, I occasionally use expressions like** ${1:host_etc}** to indicate that there are other parameters, but perhaps they are not used much, or are quite detailed.
Similarly, when the allowed combination(s) of parameters are too many, I may just leave the cursor within the braces ().

For class (interfaces, exceptions, etc.) that do not have a constructor Iā€™ve just added their PascalCase name, otherwise Iā€™ve included their constructor as well.

Again, I welcome any comments/suggestions. Andy.

0 Likes

#3

iā€™ll make u a statue made of gold and silver XD

0 Likes

#4

Thank you, although Iā€™d rather you just give me the gold and the silver :smiley: - Iā€™ll buy a hammer and knock up a statue myself :laughing:

Iā€™ve updated it (on GitHub) with a load more parameters, and class-names (properly cased) and constructors.

If you, or someone, know which library(ies)/extensions are most popular I might add the OO-methods for it to my file. Andy.

Added: Actually, the most popular ā€œextensionā€ must be mysqli. I think Iā€™ll add these methods; Iā€™ll group them ahead of their
procedural equivalents, as the OO approach is recommended (and easier to type :wink: )

I may not bother adding OO-methods for other extensions, unless someone requests that I doā€¦ Andy.

0 Likes

#5

Iā€™ve just updated my repo, as follows:

Added mysqli (OO) methods;
Commented out mysql (in favour of mysqli);
Filled out more parameters for: sqlite, sqlsvr, xmlwriter (for the procedural functions).

Iā€™ll leave it alone for a while, unless someone expresses an interest in a particular extension - or anyone spots any typos :laughing:

I hope it strikes the right balance between providing the most useful functions, and parameters, and not over-whelming the completions list. [A reminder that a lot of extensions are commented out in the completions file - just uncomment any that you might use.]

Feedback welcome. Andy.

0 Likes

#6

i think that pdo itā€™s a little bit less popular than mysqli but exponentially growing and far better^

0 Likes

#7

Iā€™ve updated to include PDO and PDOStatement methods. Iā€™ve also added mysqli pre-defined constants. Andy.

0 Likes

#8

**Nudge **If anyone notices any mistakes :laughing: , or has suggestions, about this file, can I encourage you to get in touch - either here or via my repo.

Andy.

0 Likes

#9

Just to note that Iā€™ve commented out the global variables - $_POST, etc. The dollar sign causes misbehaviour.
This is not much of a loss as they will appear in the completions-list anyway, under normal file-completion rules.

Also, hereā€™s a sensible piece of advice: rather than deleting the comment lines when you wish to use a particular extension, do this:

/* My note(s) here UNCOMMENTED */ // the completions are listed here /* UNCOMMENTED */
This will make them much easier to find when you later want to disable (comment) them.

BTW Iā€™ve now commented-out the Mongo library as it is no longer bundled with PHP.

Andy.

0 Likes

#10

Iā€™m hoping that my PHP completions file is pretty much *complete *now, but I will still welcome any comments or suggestions to improve it (if possible :smiley: ).

Iā€™ve added OO methods for XMLReader, XMLWriter and XSLTProcessor. I havenā€™t commented-out their procedural/function equivalents as Iā€™ve no idea whether people still use them :question:

For 30 specific functions Iā€™ve created two versions. For example:

{ "trigger": "mkdir()", "contents": "mkdir(${1:pathname})$0" }, { "trigger": "mkdir(full)", "contents": "mkdir(${1:pathname}${2:, mode]}${3:, recursive]}${4:, context]})$0" },
Mostly this is applied to database connect() functions. I believe this should be useful, so that we donā€™t spend too much time deleting optional parameters that we rarely need.

The GitHub

It is a shame not to receive much input (validation, he, he) from this forum, but this doesnā€™t prevent me from being pleased with my resultant file. Andy.

0 Likes

#11

You should add this to Package Control. (I couldnā€™t find it there, at least)

0 Likes

#12

@Vanish
Hello. Iā€™m not sure if this is suitable as a Package at the moment, as it replaces a standard file, and the file could also be replaced on a future ST upgrade or build.

So, for the moment, my file needs to be downloaded from my GitHub and used to replace the standard PHP.sublime-completions file (keeping a backup of that file just in case).

If I can obtain responses from users - to confirm that this is an improvement on the standard PHP completions file - then perhaps jps could use it for a future upgrade/build(?). The only difference being that people would need to be advised that there are (many) extensions in the file that would need to be un-commented if, and when, required.

Andy.

0 Likes

#13

Just an update:
Iā€™ve decided to comment-out the msql (Mini SQL) functions. Theyā€™re too similar to mysqli, etc., and I figure that if someone uses this database they are likely to comment-out other similarly-named libraries. (At least, I would :smile: )

Iā€™ve also added a number of missing mysqli functions - partly because they are used in a book that Iā€™m reading.

I wonā€™t update here any more, as up-to-date info can be found at my GitHub. Besides, I consider the file complete (99.5% :wink: ). Andy.

0 Likes

#14

[quote=ā€œagibsonswā€]Just an update:
Iā€™ve decided to comment-out the msql (Mini SQL) functions. Theyā€™re too similar to mysqli, etc., and I figure that if someone uses this database they are likely to comment-out other similarly-named libraries. (At least, I would :smile: )

Iā€™ve also added a number of missing mysqli functions - partly because they are used in a book that Iā€™m reading.

I wonā€™t update here any more, as up-to-date info can be found at my GitHub. Besides, I consider the file complete (99.5% :wink: ). Andy.[/quote]

great andy^^^

0 Likes

#15

Thank you @Fed03

Althoughā€¦ you might be commenting on my saying ā€œI wonā€™t update here any moreā€ :smiley:

0 Likes

#16

I consider this project complete. It seems amazing that I could create such a large file without a single error or typo :question:

0 Likes

#17

Nice work!
btw:
The link to the screenshot is not validā€¦

0 Likes

#18

[quote=ā€œseth007ā€]Nice work!
btw:
The link to the screenshot is not validā€¦[/quote]

Hello and thank you. Iā€™ve deleted the screenshot link from my previous post.

Andy.

0 Likes