PHP Storm Magic Method Access Error on persistence->parameters - php

When i code phalcon with phpstorm i have one particular error i cannot figure out how to resolve. I like to see the green check at the top of each page to indicate there are no issues but this error is preventing the green checkmark shown.
So this is what causes the error:
$this->persistent->parameters = null;
How can i alter that code to prevent the PHP Storm error:
Field accessed via magic method
I know its a bit picky but would love to solve this

Use #property PhpDoc construction. Example:
It's also gives autocomplete to magic properties. Always use all available inspections.

Uncheck "Notify about access to a field via magic method".
You can find this setting under Project Settings -> Inspections -> PHP -> Undefined -> Undefined field.

You can try to download the framework code from the devtoolos on Github and Include it in PHP Storm. You can either add it as library dependency or simple paste it in the file explorer of your project.
https://github.com/phalcon/phalcon-devtools/tree/master/ide/2.0.7/Phalcon
It should have all the required PHP Doc

Related

Disable Undefined Property error in PHP Devsense extension on VSCode

I just added the PHP extension by Devsense to my VSCode and now it's lighting up like a Christmas tree. I want to disable the Intellisense option for unknown/undefined properties.
Here is the issue
and the error message
Undefined property: MY_Model::$load PHP(PHP0416)
And a link to the post where they talk about adding it
I saw some options for Intelliphense where you could set "intelephense.diagnostics.undefinedProperties": false
in the vscode settings.json, but I couldn't find anything that would work for this extension.
The fix described here in the 3rd post to add the property in a comment does work, but is not feasible in the codebases I am working in. I need something more like the second post, where I can just disable the check altogether
I found the answer to my own question. Leaving it here because It took me way too long.
You just have to exclude the error code, in this case error code 0416
1 - Open Settings.json : ctrl + shift + P and type 'settings.json'
2 - Select 'Open User Settings (JSON)
3 - At the end of file, add this code:
"php.problems.exclude" : {
"/" : [416],
"vendor/" : true,
}

What is the "Use Trait Body" setting for?

Recently I've started using PHP (worked for MS shops since graduating, and that was mostly what I used in college too). To help with this, I'm using Netbeans and am in the process of configuring it so that it's more similar to Visual Studio.
Under Options -> Editor -> Formatting, I've found this setting highlighted in the red box:
Any setting I pick for that value makes no difference in the sample file on the right. I copied the text from when I use the "Same Line" value and did a diff on it against the text when using "New Line" and they're identical.
So, what is this setting?
In the example to the right of the options, I thought this would impact the (new Example())->alignParamsExample(... and push anything after the -> onto a New Line, but that's not the case.
I've also read the documentation about traits but I'm still unclear exactly as to what the "trait body" would be. I typed out the code they provided in "Example #2 Precedence Order Example" but noticed no behavioral difference in the IDE.
I've tagged this question with both Netbeans and php tags; if I select other languages this option isn't present (but I only have HTML, JSON, Javascript, and PHP to chose from) so I wasn't sure if this is a "PHP thing" or a "Netbeans thing." If it's explicitly one or the other, let me know and I'll remove the tag.
I think this is about that block in class:
class ExampleClass
{
/** Start of Use Trait Body **/
use TraitOne;
use TraitTwo;
use TraitThree;
/** End of Use Trait Body **/
}

CKFinder 3 upgrade difficulty

I'm following the CKFinder 2 to 3 upgrade guide and it's not making much sense. In CKFinder 2, the PHP code provided could be used to generate the JS snippet with appropriate config and params, like this:
require_once 'ckfinder/core/ckfinder_php5.php';
$finder = new CKFinder() ;
$finder->SelectFunction = 'ShowFileInfo' ;
$finder->DisableThumbnailSelection = true;
$finder->RememberLastFolder = true;
$finder->Id = $name;
$finder->StartupFolderExpanded = true;
$finder->Width = $width;
$finder->Height = $height;
echo $finder->CreateHtml();
This code picks up the config and incorporates it into the generated JS.
In 3 this seems to have disappeared entirely - the upgrade guide describes the changes needed in config.php, but there is no indication of how this is ever used since there is no other PHP involved, and it says
It is no longer possible to enable CKFinder on a page from the PHP level
All that is shown is how to create the JS snippet, which does not contain any config, and so will use incorrect settings. There is no indication of how the config properties set in config.php ever get to the JS code - as far as I can see there is no connection at all and no mention of any other PHP files, even though some are provided but not documented.
This makes no sense - PHP can quite happily generate HTML and JS that is run on the page, which is all the old CreateHTML function did. I don't understand why there is no mention of this mechanism since it was how we were supposed to use CKFinder previously - it's as if the migration guide is for some unrelated package!
If I update the config file and use the default JS widget code as suggested, it breaks the page completely, altering the MIME output type so it does not get rendered as HTML and appends this error:
{"error":{"number":10,"message":"Invalid command."}}
The docs cover various fine details of what PHP config settings mean, but nowhere that I've found says how it's ever loaded, triggered or associated with the JS. How is this supposed to work?
Indeed the CKFinder 3 documentation was lacking some important information. We're gradually adding new articles there. Based on topics you mentioned I just added:
Explanation how PHP code that worked for CKFinder 2 can be refactored to plain JavaScript in CKFinder 3. Should look familiar ;)
A table with Configuration Options Migration - JavaScript Settings which should help you with discovering again options like rememberLastFolder

turning on the dom_xml functionality on php 5

I am trying to implement an store locator using php and mysql and google maps
I have gone through this article "https://developers.google.com/maps/articles/phpsqlajax_v3 "
it says "Check your configuration or try initializing a domxml_new_doc() to determine if your server's PHP has dom_xml functionality on."
But apparantly mine is not on because it is giving me this error :
"Fatal error: Call to undefined function domxml_new_doc() in C:\wamp\www\StoreLocator\phpsqlajax_genxml.php on line 5"
I am using php 5, and I am not sure how I can turn it on.
Please help me with your opinions.
This question might help answer your problems.
Are you sure you want to go down the XML route and not the JSON one?

PHP function descriptions as I type in Notepad++

Is there a plugin for Notepad++ which would allow me to see functions including parameters/returns as I type?
For example, if i type "implode(", I'd see:
string implode ( string $glue , array $pieces )
Update: Wow, I'm surprised so many other people were as interested in this as me. The take-home lesson for me was to always explore all the Settings options!
You don't need a plugin! 5.0 and above have this already.
Go to Settings -> Preferences, then go to the Backup/Auto-Completion tab, and you'll find it at the bottom! Check the box for function parameters hint as well.
You'll get exactly what you've asked for, as long as it knows the file is PHP.
maybe, plugin Auto completion for custom PHP classes (ACCPC) is what you're mean.
basic info:
Show an overview over your classes' attributes & methods in a nice popup!
A popup window appears after typing the "->" or "::" behind a class or an instantiated object variable which displays all attributes and methods of it's class.
more information:
http://sourceforge.net/projects/accpc/
maybe this answer can helpful too:
Get parameter hints from Editing the API XML file
https://stackoverflow.com/a/12609240/2427906
You can read about it in Notepad++'s documentation site found here
http://npp-community.tuxfamily.org/
The auto complete section can be found here
http://npp-community.tuxfamily.org/documentation/notepad-user-manual//editing/auto-completion

Categories