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