Nusphere PHPEd: PHP Function Hints Lost Arguments? - php

My PHPEd suddenly stopped showing arguments and arg order in the hints, and now just shows a basic description of the function.
Before I go digging around in the config files, has anyone else had this problem?
Thanks!
Edit:
Sorry, I may not have been entirely clear on this. There is no problem with my own classes, only with the actual php functions.
Example:
How it used to work:
I type a PHP function, say strpos. As soon as I type the '(' at the end of it, I get the little yellow box, showing something like this:
int strpos ( string $haystack , mixed $needle [, int $offset=0 ] )
with the first argument bold. If I type it, and then a comma, it bolds the second arg, and so on. This is really nice, since PHP functions are a bit scrambled as far as argument order, and I don't have to look them up every time.
How it works now:
I type a php function, say strpos. As soon as I type the '(' at the end of it, I get the little yellow box. It says something like "strpos - Returns the numeric position of the first occurrence of needle in the haystack string."
There are no arguments shown, which makes the little box basically worthless - I know what strpos does, I just want a reminder of the argument order.
I think this may be a problem with the included PHPDoc, which I never use, but may be the source of the data for the hint box.
I did recently upgrade to 5.6, but ended up removing it and restoring 5.2. I installed to a different folder, and uninstalled from there, but it may have overwritten something in the original folder?
I'm using v5.2 (5220).

A complete re-install seems to have done fixed the problem. Perhaps it was a problem with a partial upgrade or a version mismatch on the settings.

What version of PhpEd are you using ? And did you made an update of PhpEd recently ?
As mentionned in the forum, that can modify the "Function Arguments Tooltip" feature behavior.
One way to check if this is linked to settings is to move the phped.cfgconfig file (save it), and let PhpEd recreates it with default values. If that does restore the tooltips, use a diff program to check what option may have been changed.
Do you see no hints for all classes, or only your own Php classes (in the latter case, this thread has some setting advices) ?
Note: the reason I ask for the version is because of this very recent thread, about PhpEd5.5:
In that case, the advice is to copy %PROGRAMFILES%\nusphere\phped\config\func.rel into %APPDATA%\nusphere\phped\config\ directory overriding the file in it.

Related

Bring result of PHP-Script to accepted field in TYPO3 FORM

So, it's my first question here - i found a lot of hints which all working for itself but im struggling now with the final step to get solved.
Guess it's very specific pointed to TYPO3-CMS V9 and higher.
I can also support with all of the Codes, for the moment i guess this will be better on request.
Task: Create a simple Productorderform for logged-in-users pointing just there specific products form the specific price-lists. -> solved by using PHP-Script working with a CSV-File, grabbing also some functions from TYPO3 itself to get needed parameters.
This PHP creates a DATALIST on runtime for the INPUT-Field producing the needed HTML-Code -> solved and working as expected.
Tricky part.
As TYPO3 offers a CORE-Extension called FORM and the Option to - REPEAT - the fieldset.
Also for TYPO3 there is an extension which allows to put PHP-Code directly to TYPO3 as a Content-Element.
FORM itself allows to put Content-Element to a form.
Working so far, but as described, the field (its value) is not recognized when i fire the send button.
So for some reason i have to predefine the trigger also.
I tried step for step to extend the predefined field in the php with the tags of an empty one, all(?) the surrouding DIV etc. to make FORM recognize this field as a "native" field, just extend in the main tag with ... list="prodlist" ...
Well, as you might see, i'm not a developer or programmer, i might have some skills and experiences to know where and how to go with the level (and timeframe) i have.
So i guess the final step might not be that far, but as we say here, i can't see wood because of trees...
The FORM structure by the way is saved to a YAML-file which might be also manipulated, but as i have seen, it gets the triggers -what- to parse in some way from the FORM created.
Many thanks for hints, ideas an hopefully noone was falling to sleep reading this question... ;)

PHP linter for undefined variables/associative keys

We are looking for a PHP linter, and we are chasing a particular problem that's causing E_NOTICE's, a lot of them:
if($undef_variable)...
if($assoc['undef_key'])...
$undef_variable?...:...
$assoc['undef_key']?...:...
Functionally, the code works perfectly so if the tools was also able to replace on-the-fly such occurences with i.e.
if($undef_variable??null)
That would be a huge help.
Some of the code is in templates that are in included with some pre-set variables (always the same). So ideally the tool would also allow configuring some available global-namespace variables.
The tool should absolutely understand PHP7 syntax, especially anonymous functions.
At a minimum, we need to generate a list of every occurence where a variable is used as a boolean condition and is not defined in the same scope, and every occurence where an array key is used as a boolean condition.
Phpcs- PhpCodeSniffer can be used for that. You need to configure a rule for that. Find it here - Phpcs
Check this rule -
https://github.com/sirbrillig/phpcs-variable-analysis
If you use PhpStorm, it has an option in Inspections. https://www.jetbrains.com/help/phpstorm/php-undefined-variable.html

Something seems to fail after 1622 characters(null values)

I'm having this issue with the JSONAPI for minecraft. http://mcjsonapi.com/
I am trying to use the method "files.write" or "setFileContents" to replace the contents of a file. The website states this about the method.
Pretty simple. Just rewrites the file right? Yeah but this is proving to be more difficult then I thought. At first attempt, I was trying to set 3450 characters to the file "groups.yml" on the minecraft server. Here's the code I ran in PHP:
var_dump(
$api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", (string)$yaml))
);
The var_dump is supposed to either return a success statement or an error describing what went wrong. But instead all I get is "null". This isn't right, and I know $yaml is being casted to a string, which isn't the issue. So I decide to start testing around. After much testing, I find that the character length of what I can set is exactly 1622. Adding another space or anything causes null, otherwise, it works. This is the modified file that is below 1622 characters I tested with.
So great, you found the issue, right? No, I didn't. I thought 1622 was an odd number to stop working, so I did some further testing. I tried to set 3000 characters I generated from just smashing my keyboard, and it worked! So what's going on here?
This and this works, but this doesn't. Why is this? This app called Adminium runs this exact API, and includes a file management system inside the app which I am assuming uses the same methods I am using, but it doesn't have a problem.
I have a forum post here that I also asked on, and still haven't gotten to an answer yet.

Drupal - Search showing preg_match error

I have a custom search going on in one of the website I am building in Drupal. Search works perfectly fine when the "Rebuild theme registry on every page." checkbox is selected on the Theme Configure page. However, when I uncheck it (for production), the search no longer works, the same page just reloads again on hitting the search button. Upon looking at the Recent Log Entries I found the error:
preg_match() expects parameter 2 to be string, array given in /var/www/devel_sites/SITENAME/docroot/modules/search/search.module on line 671.
Anybody got any ideas why my search would be depending upon the theme registry and how to fix this? I have a custom module for search and part of the functionality is in template.php.
Any tips are appreciated, thanks.
Without posting code (since the code is custom,) I don't think anyone can answer your question satisfactorily. However, if you don't mind modifying module code, simply do a is_array conditional before line 671 and if it is, implode the terms (or inspect it and get rid of any garbage.) Pass that string on to line 671.
I was (finally) able to resolve the issue and I am posting the resolution below in case someone else faces the same.
I started by moving all the functional logic from template.php to my custom module (I should have done it anyways and it seemed like it might be an issue) but it didn't solve it. I had to dig in my custom module code and that's where I found what the problem was. I was using the following to get the entered keywords:
$form_state['values']['processed_keys']
It turns out, when Rebuild Theme registry option is turned off, the above array value is overwritten by the theme registry and is being replaced by an empty array, hence causing the error in line 671 of the search module which, is expecting a string as the second argument, and not an array. Replacing the above with the below solved it for me:
$form['basic']['inline']['processed_keys']['#post']['keys']

NetBeans Code Templates ${date}?

I have this code template in Eclipse
#since ${date}
when entered i get something like this :
#since 4.8.2009
But when i add the same template (#since ${date}) to NetBeans
it outputs
#since date
Can someone help ?
No answer yet ? Is this not possible in Netbeans ???
Something like the following example should doing the job :
${date?date?string("yyyy")}.${date?date?string("MM")}.${date?date?string("dd")}
yyyy => year on 4 elements (ex: 2012)
MM => Month on 2 elements (ex: march -> 03)
dd => Day of the month on 2 elements (ex: 23)
. => separator you want to separate each fields (ex: - or / or . or smth else)
You should have to check about available format somewhere in the netbeans help (sorry I don't find out informations about this for now).
I see that's a very old post, but if it may usefull for someone ...
regards.
ollie314
Not wanting to raise the dead with this post, but I thought it worth mentioning so I signed up to SO specifically to clarify, since Ollie314 saved me a lot of time.
The format ollie314 used is correct (for version 7.1+ at least) BUT just to be clear, if it's not displaying correctly it may be due to your system locale settings, if outside of USA. Be sure to include <#setting locale="en_AU"> (replace en_AU with your locale id) in the template you are editing, prior to the date?date?string cast declaration, or it will not work. If you place it in the user settings it won't cast the date string in the template and you will generate errors in your template output.
The documentation from Netbeans isn't particularly clear on that. Still, best IDE ever :)
Inserting ${date?date?string("yyyy")} within your template will do the trick (if you want year only)
Note: With NetBeans 6.5/6.7, if you do not find that template, you could create it.
See this tutorial.
I'm pretty sure this is not possible in Netbeans, or at least not worth the amount of trouble. It's possible that you could author your own Netbeans module, add a code template to the module (in which you might be able to put the ${date} as an extra variable, I'm not sure), and then add the module to Netbeans. But you could also just type the date in, which, unless you type it several thousand times per day, would probably take less time.
Your snippet looks like freemarker code. This is used in Netbeans for file templates (Tools -> Templates). If you put ${date} in a file template it will get transformed when the file is created to the current date. If you're trying to use it as a code template I don't know how that works.
Even simpler, use ${date?date?string.yyyy}

Categories