I have installed Aptana Studio 3, set my workspace as C:\wamp\www and set project nature only to PHP - primary. Everything is working (for ex. autocomplete from extended class) but PHP documentation simply is not working. I added some function like
/**
* Test
*/
public function error($status_code, $message = null) {
....
}
but when I hover it (I saved the file) I get No available documentation? Where is the problem? :/
I'm on Windows 7 32-bit.
The hover will not work when you are on the error word at the function declaration (a bug).
It should work for you when you call the error function. You should see the documentation-hover when you code assist, and also see similar info when you hover the word.
Related
PhpStorm (version 2022.3.1) simply does not show "Missing parameter's type declaration warning".
In this piece of code I intentionally leave $name parameter in getId() method without type declaration and expect PhpStorm to highlight it:
<?php
declare(strict_types=1);
class TestClass
{
private int $id = 1;
public function getId($name): int
{
return $name === 'Citibank' ? 0 : $this->id;
}
}
But nothing happens.
I've checked Settings -> Editor -> Inspections -> PHP -> Type compatibility - the checkbox is checked, Scope - 'In All Scopes', Severity - 'Warning'.
I've also went through all the steps in File -> Repair IDE.
But still I get only one Weak Warning: 'Unused element: TestClass'.
Any ideas why is this happening? I know it looks more like a bug report, but I there's still a chance that it is a configuration problem or someone has encountered it before.
P.S. If anyone's willing to check my settings, here's exported file: google drive link.
In the referenced version (2022.3.1) this is still tied to the existence of a DocBlock annotation. Only if the DocBlock exists will this be checked. There is an issue reporting this.
I inherited a project that was created with Yii2, ver. 2.0.4, with the task to update said project to a more current version of Yii2 (2.0.15) because of the incompatibility of the older one with PHP 7.2+.
I noticed that there is a lot of use of assigning arrays to a model:
$model->_attributes = $array;
With the new version this results in an exception
'yii\base\UnknownPropertyException' with message 'Setting unknown property: app\models\model::_attributes'
For the time being I created a workaround with the following function:
function customSetAttributes(&$model, $array) {
foreach($model->attributeLabels() as $model_key => $model_label) {
if(!isset($array[$model_key])) continue;
$model->$model_key = $array[$model_key];
}
}
Also, the getter function now has a similar issue.
What I would like to know:
Was this type of assignment never intended in the first place (and I just haven't found the previous developer's code that enables it)? I skimmed over the Yii2 changelog but didn't notice anything related.
Is there a way to "salvage" the previous behaviour so I don't have to replace each occurence with my workaround function?
ActiveRecord::$_attributes was always private and never should be used in this way. I guess that previous developer edited framework core files in vendor directory and make this property protected/public.
You may try to emulate this behavior by creating virtual attribute using getter and setter:
public function get_attributes() {
return $this->getAttributes();
}
public function set_attributes($values) {
$this->setAttributes($values, false);
}
But this will not always work and it is more like an ugly hack to make crappy code work. I strongly suggest to fix code to use setAttributes() instead of _attributes.
Also you should compare yii2 package from vendor directory with source from https://github.com/yiisoft/yii2-framework/releases/tag/2.0.4 - you may find more places where core was edited.
So I have the following action in the controller. When Im using xDebug with Symfony 3 then the variables $request and $imNotBeingShowin is not shown in xDebug variable list. While variable $imBeingShown works fine when assigned to the class.
public function saveAction(Request $request)
{
$imNotBeingShown = 'why not?';
$this->imBeingShown = 'wooot';
}
Any idea what is going on? I can't seem to find anything about this issue in Google.
/Hendrik
Edit: added an extra image for proof
Edit: app_dev.php variables are shown in debugger
I have added an additional image, with code while debugging :).
This won't work. Once you've run your program it's loaded into memory. You can't change it on runtime.
I have just noticed that the object method autocomplete does not bring up a list of methods to autocomplete with. I saw it when I was using the $PDO->bindParam() method. Normally, I can just start typing "bi" after the method arrow and the autocomplete will come straight up with the method. Now, these methods do not appear, however methods and attributes in my personally defined classes will appear. Also, it says "PHPDoc not found".
It's strange because it has worked fine previously. The only thing I can think of is that I had to delete the project out of Netbeans and then recover it back using "new project from existing sources".
Is there a broken link to a documentation file I need to re-connect? How would I go about fixing this? Also, apologies if this is an asinine question.
Code completion
To get context sensitive code completion, follow these steps:
Include Yii folder (assuming it is properly placed outside project directory)
Open "File > Project properties > PHP Include Path" and add the Yii framework root path
Ignore yiilite.php to avoid doubled/missing documentation
Open "Tools > Options > Miscellaneous > Files"
Add to the front of "Files Ignored by the IDE" the file "^(yiilite\.php|CVS|SCCS|...."
Restart NetBeans
Code completion in view files
Add the following PHPDoc statement at the head of the file to use code completion in view files. (you may add additional passed parameters as well)
/* #var $this PostController */
/* #var $model Post */
$this->getSomeProValue(); // possible with code completion
$model->author; // possible with code completion
Usage:
Typing suggestions: Ctrl-Space
Show Function parameters: Ctrl-P
Comment your own code with PHPDoc style. Here's a good example.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Call to a member function on a non-object
I'm doing this tutorial here:
http://tv.cakephp.org/video/webtechnick/2011/01/12/nick_baker_--_facebook_integration_with_cakephp
I baked a new project with cake bake facebook_app and set the configuration database file to the correct settings and the default cakePHP screen showed that tmp directory was writable, DB setup was good, etc.
I downloaded the CakePHP plugin by WebTechNick here: https://github.com/webtechnick/CakePHP-Facebook-Plugin, and filled out app information (app_secret, app_id, etc), adding it to facebook_app/config/facebook.php
Changed facebook_app/app_controller.php:
class AppController extends Controller {
var $name = 'Facebook';
var $helpers = array('Session', 'Facebook.Facebook');
}
Then just exactly as in the tutorial `facebook_app/views/pages/home.ctp':
<h1>Facebook_App</h1>
<?php $this->Facebook->share(); ?>
returning the error message:
Undefined property: View::$Facebook
I realize that means PHP didn't recognize Facebook as an object. But I installed the plugin!
Also, it seems not MVCish to have something like $this->Facebook->share(); in a view (home.ctp). However, this is exactly how WebTechNick does it in his tutorial (I followed it exactly 3x) and it does not work for me. I'm a complete noob at cakePHP (although I've read the entire documentation) and I'm just trying to learn and understand through examples.
:) To be fair, it's PHP - you didn't install anything. Or if you prefer, "install" != "invoke." PHP is really amazingly easy to debug. I mean, it tells you exactly what's wrong:
Like turning to a channel that's not on the air, the error your getting means that the object you're calling doesn't actually exist, at least not in the scope you're trying to invoke it.
Is that your IDE? Is it set up for your Cake app? Are you sure the instructions were to set your AppController's $name to 'Facebook' instead of $name = Facebook_App in your AppController? It looks like you either replaced your actual app's AppController with the plugin files instead of putting them in the proper directory, or the plugin is not deferring / calling / extending / returning to the application the way it's supposed to. Knee jerk -> typo, naming conflict, path problem, permissions.
Cake's not even rendering. I can tell because your screenshot would show that error with the styled Cake errors. That tells you it's erroring before AppController class makes it to View class.
Create an instance of the Facebook object statically in the view and see what happens. Then, what does
function beforeFilter() {
parent::__construct() ?
}
get you? Anything? What about debug(), var_dump, the object functions will also shed light on what's happening. So will your logfiles.
Btw, if you don't use them already: Firefox + FirePHP + Xdebug = made of win.
I was having this problem and I found that the plugin I was using was for CakePHP 1.3 and I was using Cake 2.0. I found the BETA branch for the upgraded Cake 2.0 and it worked perfect.
Here is the Cake 2.0 BETA Branch