I have been using gvim for a while and now im trying eclipse and a feature that I really miss is the auto complete. Not just typing pre and getting preg_replace as a suggestion, but if I have a variable name that I have been using like $_POST['confirm_delete'] then confirm_delete comes up as a suggestion if I type con.
Can I get this feature with eclipse?
Yes, Eclipse does have autocomplete. But not for unknown array indices like $_POST['myindex']. Autocomplete works for all your normal variables and classes/methods.
This might help : once you have already typed confirm_delete in your file somewhere, you can use eclipse's global autocomplete feature Alt + /. For example if you type con and Alt + / it will complete it with confirm_delete if it is the only word in the file that starts with "con" (otherwise type a few extra letters to be sure).
This works everywhere in the file, even in comments.
Eclipse (also Netbeans) cant auto complete array indexes.
Related
So, I am just curious if there are any simple method to select / replace all declared PHP variable in blade using Visual Studio Code. Because, I am trying to make the static version from its original version and the code itself has ~~500 line of code so it would take some times to remove / edit those variables manually. Or maybe using Regex Method ? (since I am not really expert about those regex rules).
Thanks before
Ctrl + Shift + F
this is the VS Code shortcut
How to automatically convert short array syntax to long(traditional) in PhpStorm?
I used the feature "Code -> Inspect Code" in PhpStorm and then one by one click convert short syntax to long.
Inspect code
Manually convert
There has to be a way to automate this job? Are there macros in PHPStorm?
go to Settings(Ctrl + Alt + S)-> Editor -> Code Style -> PHP -> Code Conversion -> Array Declaration Style -> tick Force short declaration style Checkbox.
press OK -> press Ctrl + Alt + L -> voila
Bartosz is right. To avoid manual work you can use Short Array Syntax Converter tool with revert (short into long array syntax) option. But be aware, that
Reverting has not yet been thoroughly tested, so use with extreme
percaution!
I'm afraid it's not possible. If it was a failing inspection, there would be a "Fix all problems in file" option in the submenu. Intentions don't have this functionality.
Have You tried setting PHP version to 5.3 and then only search for this via Inspect code? Don't have PhpStorm installed anymore.
Recently I've begin moving to sublime text 3 from Netbeans.
I've discovered almost all needed features but still can't find one.
There is a cool feature in Netbeans:
It does the following. If I have such code:
$product = new Product;
$product->someMethod();
I don't need actually to type - and then shift + > to get -> . It's enough just to presss - sign and Netbeans figures out on his own that it should be -> .
The same is applied to array.
I understand that Sublime doesn't do as deep code analysis as Netbeans does.
Of course it would perfect solution if it could figure out like Netbeans does.
But I would happy to replace - sign on numpad keyboard to -> always.
I've tried snippets. It looks like this:
It works ok. But only if it goes as the first symbol in the word.
But then I need to reference an object referencing never goes first.
I can't believe that all people type manually every time - and shift+> to get referencing the object. There must be better way.
Any ideas? How did you tackle this problem?
Looks like there is no silver bullet which would kill any beast.
Though ST is a cool editor it's just editor, it's good for js, scss,css, python where Netbeans sucks but too bad for php.
Probably I would be happy with ST for PHP if I didn't know that you can get more boosting using full-blown IDE.
So frontend development will be carried on ST and backend on Netbeans.
Edit
Of course I tried the whole bunch of available plugins. This is the list of tried:
To replace the - key with -> in all situations in Sublime Text (meaning if you want to write, for example 1 - 2, you would have to type 1 -backspace 2, you can do the following:
From the Preferences menu in Sublime Text
Click Keybindings - User
Write [{ "keys": ["-"], "command": "insert", "args": { "characters": "->" } }] (note that this assumes that you don't already have anything in the user keybinding file. If you do, before the ] at the end of the file, type , and the above without the enclosing [ and ] characters. The file needs to be a valid JSON array of keybindings.)
Save it
Try typing - and see the magic
You may be able to do some magic with contexts to get this keybinding only for PHP syntax files, or you could just write a simple Python plugin that your keybinding would execute, which would enter - in the document if it is not a PHP file and -> if it is.
After a dozen years of using a simple shareware text editor to write PHP, I'm finally jumping into the world of IDEs like it's 1999.
I'm playing around with debugging in NetBeans using XDebug. I see how I can set breakpoints or step through each line in the code and see what values are assigned to variables. Very cool!
However, I don't see what happens to anything that's been echoed or sent to the buffer.
Is there a way to see this, or does NetBeans assume that I'm assigning all of my strings to variables to be output at the end (which is how I usually do it anyway)?
You can use ob_start() to buffer your output, and then copy it to a variable using ob_get_contents().
you can also use the IDE and add the ob_get_contents() expression
I'm looking for something that Is really hard for me to do.. I really tried to search all over the net for Solution, But I couldn't seem to find any. I also tried doing this for hours.
What I'm doing: Making a theme for PHPBB2, Installed a MOD that can include PHP in themes.
What is the problem: When I'm doing {} tags in php, It just can't echo those tags.
Let's say I have a function that creates a Table for me, like that:
CreateMyTable(Name,Size,Color);
I put in the function those strings:
CreateMyTable("{FORUM_NAME}",1000,red);
The title stays blank, I actually want it to echo {FORUM_NAME}.
How can I do this?
P.S: I can't do this
CreateMyTable(?>{FORUM_NAME}<?php , 1000, red);
It's not going to work becuase <? = <!-- PHP --> , ?> = <!-- ENDPHP -->.
Thanks for your help :)
If you look in the PHPbb2 template class, you'll find that the template is simply an evaluated set of PHP using the eval() function. You can either print the contents of the PHP before it is parsed using eval() and then use the variable name that the template gives, IE something like (which may not work depending how your template is setup):
CreateMyTable(((isset($this->_tpldata['.'][0]['FORUM_NAME'])) ? $this->_tpldata['.'][0]['FORUM_NAME'] : '' ),1000,randomcolor());
Please note, in order to do it similar to the way above you'd actually have to insert this into your template class.
An much better solution is to avoid using the mod that allows PHP in templates and use JavaScript in the templates to create the function, then print a call to that JavaScript function.
This will work:
CreateMyTable(FORUM_NAME,1000,red);
I also noticed that red is used without quotes - is this also a constant? If it's a variable it needs to have a $ in front of it. If it's a string it should be between quotes.
CreateMyTable(FORUM_NAME,1000,"red");