gert-dev / php-ide-serenata Goto Github PK
View Code? Open in Web Editor NEWAtom IDE package that integrates the Serenata server to provide PHP code assistance
Home Page: https://serenata.gitlab.io/
License: Other
Atom IDE package that integrates the Serenata server to provide PHP code assistance
Home Page: https://serenata.gitlab.io/
License: Other
Atom Version: 1.2.1
System: Mac OS X 10.11
Thrown From: php-integrator-base package, v0.2.0
Uncaught Unexpected end of input
At /Users/xxxx/.atom/packages/php-integrator-base/lib/Proxy.coffee:57
undefined
-2:31.7.0 core:backspace (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-2:31.4.0 core:move-right (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
2x -2:31.1.0 core:backspace (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-2:30.3.0 core:move-right (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-2:28.1.0 core:backspace (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-2:27.2.0 core:save (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-1:50.4.0 command-palette:toggle (atom-text-editor.editor.is-focused)
-1:47.6.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-1:47.6.0 php-integrator-base:configuration (atom-text-editor.editor)
-1:42.5.0 command-palette:toggle (atom-text-editor.editor.is-focused)
-1:34.6.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-1:34.6.0 php-integrator-base:configuration (atom-text-editor.editor)
4x -0:58.7.0 symbols-view:go-to-declaration (atom-text-editor.editor.is-focused)
-0:09.8.0 core:move-left (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
2x -0:07.5.0 core:move-right (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
-0:05.6.0 core:save (atom-text-editor#php-integrator-base.additionalScripts.editor.mini.is-focused)
{
"core": {
"themes": [
"atom-material-ui",
"atom-material-syntax"
]
},
"php-integrator-base": {
"composerCommand": "/usr/local/bin/composer.phar",
"autoloadScripts": [
"vendor/autoload.php"
],
"classMapScripts": [
"vendor/composer/autoload_classmap.php"
],
"additionalScripts": [
"plugins/**/*.php",
"themes/**/*.php"
],
"phpCommand": "/usr/local/php5/bin/php"
}
}
# User
angularjs, v0.3.3
atom-jade, v0.3.0
atom-material-syntax, v0.2.4
atom-material-ui, v0.8.0
autocomplete-angular-material, v0.4.0
emmet, v2.3.14
file-icons, v1.6.11
language-jade, v0.6.2
php-integrator-base, v0.2.0
php-integrator-navigation, v0.2.1
react, v0.12.10
webbox-color, v0.5.9
# Dev
No dev packages
[Enter steps to reproduce below:]
<?php foreach ($sites_links as $key => $sitelink): ?>
<li>
<a href="<?=$sitelink['link'];?>"><?=$sitelink['name'];?></a>
</li>
<?php endforeach; ?>
Atom Version: 1.4.0
System: Windows 10
Thrown From: php-integrator-base package, v0.4.7
Uncaught TypeError: Cannot read property 'getTokenIterator' of undefined
At C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\pane.js:829
TypeError: Cannot read property 'getTokenIterator' of undefined
at TokenizedBuffer.module.exports.TokenizedBuffer.scopeDescriptorForPosition (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\tokenized-buffer.js:694:47)
at DisplayBuffer.module.exports.DisplayBuffer.scopeDescriptorForBufferPosition (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\display-buffer.js:832:35)
at TextEditor.module.exports.TextEditor.scopeDescriptorForBufferPosition (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\text-editor.js:2400:33)
at CachingParser.module.exports.Parser.determineFullClassName (file:///C:/Users/riart/.atom/packages/php-integrator-base/lib/Parser.coffee:102:38)
at CachingParser.module.exports.CachingParser.wrapCachedRequestToParent (file:///C:/Users/riart/.atom/packages/php-integrator-base/lib/CachingParser.coffee:47:84)
at CachingParser.module.exports.CachingParser.determineFullClassName (file:///C:/Users/riart/.atom/packages/php-integrator-base/lib/CachingParser.coffee:65:17)
at Service.module.exports.Service.determineFullClassName (file:///C:/Users/riart/.atom/packages/php-integrator-base/lib/Service.coffee:123:24)
at MethodProvider.module.exports.MethodProvider.registerAnnotations (file:///C:/Users/riart/.atom/packages/php-integrator-annotations/lib/MethodProvider.coffee:13:33)
at MethodProvider.module.exports.AbstractProvider.rescan (file:///C:/Users/riart/.atom/packages/php-integrator-annotations/lib/AbstractProvider.coffee:280:10)
at file:///C:/Users/riart/.atom/packages/php-integrator-annotations/lib/AbstractProvider.coffee:120:14
at Function.module.exports.Emitter.simpleDispatch (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\event-kit\lib\emitter.js:25:14)
at Emitter.module.exports.Emitter.emit (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\event-kit\lib\emitter.js:125:28)
at TextBuffer.module.exports.TextBuffer.saveAs (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1067:27)
at TextBuffer.module.exports.TextBuffer.save (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1037:19)
at TextEditor.module.exports.TextEditor.save (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\text-editor.js:602:26)
at Pane.module.exports.Pane.saveItem (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\pane.js:534:18)
at Pane.module.exports.Pane.saveActiveItem (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\pane.js:517:19)
at Workspace.module.exports.Workspace.saveActivePaneItem (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\workspace.js:643:35)
at atom-workspace.commandRegistry.add.core:save (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\register-default-commands.js:173:32)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\command-registry.js:260:29)
at C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\command-registry.js:3:61
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\atom-keymap\lib\keymap-manager.js:536:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\node_modules\atom-keymap\lib\keymap-manager.js:359:22)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\window-event-handler.js:97:36)
at HTMLDocument.<anonymous> (C:\Users\riart\AppData\Local\atom\app-1.4.0\resources\app.asar\src\window-event-handler.js:3:61)
2x -1:20.9.0 core:backspace (atom-text-editor.editor.is-focused)
2x -1:18.4.0 core:save (atom-text-editor.editor.is-focused)
-0:47 core:cut (atom-text-editor.editor.is-focused)
2x -0:46.7.0 core:save (atom-text-editor.editor.is-focused)
-0:41.6.0 core:paste (atom-text-editor.editor.is-focused)
-0:35.2.0 core:copy (atom-text-editor.editor.is-focused)
-0:34.7.0 core:paste (atom-text-editor.editor.is-focused)
2x -0:34.1.0 core:save (atom-text-editor.editor.is-focused)
-0:23.8.0 core:cut (atom-text-editor.editor.is-focused)
-0:20.2.0 autocomplete-plus:confirm (atom-text-editor.editor.is-focused.autocomplete-active)
-0:19.6.0 core:paste (atom-text-editor.editor.is-focused)
-0:18.8.0 snippets:next-tab-stop (atom-text-editor.editor.is-focused)
3x -0:17.5.0 core:backspace (atom-text-editor.editor.is-focused)
-0:06.5.0 core:copy (atom-text-editor.editor.is-focused)
-0:04.4.0 core:paste (atom-text-editor.editor.is-focused)
-0:00.9.0 core:save (atom-text-editor.editor.is-focused)
{
"core": {},
"php-integrator-base": {}
}
# User
docs-snippets, v0.8.0
less-compiler, v0.6.2
php-integrator-annotations, v0.2.3
php-integrator-autocomplete-plus, v0.4.0
php-integrator-base, v0.4.7
php-integrator-navigation, v0.3.0
php-integrator-tooltips, v0.3.0
terminal-panel, v1.14.1
# Dev
No dev packages
I see that integrator (or one of it's components) adding lines like that to my project classes:
use ORM;
use URL;
I no need to auto adding this lines, my system was autoloading this classes and work without it.
And when this strings added my project was crashed.
How to disable this feature?
$a = new DateTime();
$b = clone $a;
$b->{Show members from DateTime}
Using Atom 1.3.2, php-integrator-base 0.3.1.
Every time I run atom, I see "Indexing..." for a while in in the status bar. Then, when I save a file, I always see "Indexing failed!".
Steps to reproduce:
See also phpDocumentor's documentation.
/**
* @method int myMagicMethod(Somewhat\Complex\Type $v1, array $v2 = null) A description.
*/
class myClass {}
These should also be inherited from parent classes as well as interfaces.
Underlying PHP service returns the following text:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('sqlite:/Users/d...', NULL, NULL, Array)
#1 /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php(60): Doctrine\DBAL\Driver\PDOConnection->__construct('sqlite:/Users/d...', NULL, NULL, Array)
#2 /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOSqlite\Driver->connect(Array, NULL, NULL, Array)
#3 /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(816): Doctrine\DBAL\Connection->connect()
#4 /Users/dip/.atom/packages/php-integrator-base/php/src/IndexDatabase.php(77): Doctrine\DB in /Users/dip/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php on line 84
So indexing service tries to parse it like JSON and silently fails.
PHP-integrator should validate this issue and show a notification, so user can install all the required PHP extensions.
It does not appear that the phpDocumentor @property
comment is supported, and it does not appear that the @var
comment can be used independent of of a property declaration.
Is there something similar for dynamically created properties that is compatible with this plugin? Or better yet, would it be possible to add support for the @property
comment?
An example for such a use-case is Yii2's ActiveRecord classes.
By streaming output from the ReindexProvider
, we can show a progress bar that actually goes to 100% instead of a so-called 'marquee' progress bar. spawnSync or exec should already be able to handle streaming.
This is visible during variable autocompletion in php-integrator-autocomplete-plus, where Closure
will not be mentioned in front of the variable.
PHP backend throws a Fatal Error when the 'indexes' directory does not exist. Manually creating directory seems to solve the problem.
/usr/bin/php -d memory_limit=-1 ~/.atom/packages/php-integrator-base/lib/../php/src/Main.php ~/.atom/packages/php-integrator-base/indexes/PROJECT_DB_HASH.sqlite --reindex PATH_TO_PHP_PROJECT --stream-progress
Sample output:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file' in /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('sqlite:/home/to...', NULL, NULL, Array)
#1 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php(60): Doctrine\DBAL\Driver\PDOConnection->__construct('sqlite:/home/to...', NULL, NULL, Array)
#2 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOSqlite\Driver->connect(Array, NULL, NULL, Array)
#3 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(780): Doctrine\DBAL\Connection->connect()
#4 /home/tocjent/.atom/packages/php-integrator-b in /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php on line 81
The IndexDataAdapter
assumes that every structural element can have at most one base class, but apparently interfaces can use the extends
keyword to extend multiple interfaces at the same time.
There are several things that need to be modified to accomodate this:
OutlineIndexingVisitor
needs to be able to return multiple parents.DependencyFetchingVisitor
needs to fetch the multiple parents and list them as dependency.Indexer
must take multiple dependencies into account when doing topological sorting (might already happen automatically).getParentFqsens
in getParentFqsens
.IndexDataAdapter
must be updated to inherit from multiple base structural elements.I continuously was getting a Indexing failed error. Tracked it down to a function like this:
function foo(...$a) {
}
This is defined here: http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list.new
When a class has a method and property with the same name, problems arise:
$foo->testMe();
$foo->testMe = 5;
Previously all class members were returned in one large associative array, making arrays of members that had the same name. With commit d1cad92, methods and properties are now returned in separate associative arrays, more elegantly dealing with this problem. However, the CoffeeScript side only uses getClassMember
, which checks these associative arrays and just returns the first match it can find. Whether or not we're dealing with the property or method depends on the context of the code (i.e. parentheses at the end or not). Perhaps getClassMemberAt
can check the scope or check for an opening parenthesis and ask the Parser
for respectively a property or a method to disambiguate the query.
There are already a couple of specs present, but even more tests would be handy.
Functions and methods that omit the @return
tag in their docblock automatically return void
. However, built-in PHP functions and method from built-in classes do not have any docblock at all. These should not be receiving void
as return type, but rather null (i.e. the type is unknown). The same applies to functions and methods that have no docblock at all.
This will allow for the default value to be shown for optional parameters in other packages such as php-integrator-call-tips.
_ide_helper is a handy-dandy tool for making laravel's facades work a little more nicely with autocompletion and code navigation. Unfortunately, i get "Indexing failed" when i try to add it to the "additional scripts" section in php-integrator-base's settings.
Any idea what might be the problem?
I'm fairly new to Atom, so unfortunately i'm at a loss for debugging this myself, otherwise i would spend a bit more time. If you can point me in the right direction to get started debugging this, i'd be happy to resolve this.
Currently, descriptions after the @var statement are parsed, but they are not actually used, for example, this works and shows the correct description:
/**
* A short description.
*
* @var Foo
*/
protected $foo;
But this doesn't:
/**
* @var Foo A short description.
*/
protected $foo;
When both are present, we should probably just use the last one present (i.e. the one after the @var
tag) as this is ambiguous information and should be fixed in the user's docblock.
Whenever an if statement with an instanceof of a variable shows up, we can deduce its type correctly (assuming that it's not being overridden or reassigned afterwards):
if ($someCondition && ($foo instanceof My\Foo\Class) || $someOtherCondition) {
// We can now show autocompletion for My\Foo\Class on $foo->...
}
When using callables, that are actually defined by setting a variable to an anonymous function (closure), you're actually getting an object of type Closure, for example:
$test = function () {};
$test->bindTo($this);
This would need to be modified in getResultingTypeFromCallStack
so it picks up closures and returns their type as \Closure
.
For example:
/**
* class TestClass
*/
class MyClass
{
...
}
In this example autocompletion inside the class will fail because determineFullClassName
's regular expression will match inside the comment.
With 1d1867b it is now possible to have include files with global helper functions that contain docblocks. However, the type information from the docblock is not used in call stacks, for example:
/**
* @return \DateTime
*/
function helper() { ... }
$test = helper();
$test-> // No autocompletion, the type of '$test' is 'helper()' instead of \DateTime.
helper()-> // No autocompletion for \DateTime either.
[Enter steps to reproduce below:]
Atom Version: 1.3.2
System: Mac OS X 10.11.2
Thrown From: php-integrator-base package, v0.3.1
Failed to load the php-integrator-base package
At Cannot find module 'jquery'
Error: Cannot find module 'jquery'
at Module._resolveFilename (module.js:336:15)
at Function.Module._resolveFilename (/Applications/Atom.app/Contents/Resources/app.asar/src/module-cache.js:383:52)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
at Object.<anonymous> (/Users/jason/.atom/packages/php-integrator-base/lib/Main.coffee:4:5)
at Object.<anonymous> (/Users/jason/.atom/packages/php-integrator-base/lib/Main.coffee:1:1)
at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
at Object.defineProperty.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:208:21)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
at Package.module.exports.Package.requireMainModule (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:663:34)
at /Applications/Atom.app/Contents/Resources/app.asar/src/package.js:115:28
at Package.module.exports.Package.measure (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:92:15)
at Package.module.exports.Package.load (/Applications/Atom.app/Contents/Resources/app.asar/src/package.js:106:12)
at PackageManager.module.exports.PackageManager.loadPackage (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:438:14)
at PackageManager.module.exports.PackageManager.loadPackages (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:390:14)
at AtomEnvironment.module.exports.AtomEnvironment.startEditorWindow (/Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:682:21)
at module.exports (/Applications/Atom.app/Contents/Resources/app.asar/src/initialize-application-window.js:28:10)
at setupWindow (file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js:86:5)
at window.onload (file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js:41:9)
{
"core": {},
"php-integrator-base": {}
}
# User
Sublime-Style-Column-Selection, v1.3.0
column-select, v0.2.0
emmet, v2.3.17
linter, v1.11.3
linter-jshint, v1.2.1
php-integrator-autocomplete-plus, v0.3.0
php-integrator-base, v0.3.1
php-integrator-tooltips, v0.2.1
pigments, v0.19.5
project-manager, v2.6.5
vim-mode, v0.64.0
vim-mode-visual-block, v0.2.14
vim-surround, v0.8.1
# Dev
No dev packages
The following does not work:
$array = [
(new Foo())-> // Fails.
];
This is probably due to retrieveSanitizedCallStackAt
not properly stopping after the opening parenthesis. A unit test should be added to cover this case.
I am a HackLang user and curious if this works for it. HackLang files start with <?hh
instead of <?php
and have source.hack
in their scope instead of source.php
.
Right now when you use /** @return static */
as a return value it's not autocompleting the right return type. For example:
<?php
class DB {
static public function getObjectByID($object,$id) {
$return = new $object();
$return->id = $id;
return $return;
}
}
class Model {
var $id;
function Model($id) {
$this->id = $id;
}
/**
* @return static
*/
static public function getByID($id) {
return DB::getObjectByID(get_called_class(),$id);
}
}
class CustomModel extends Model {
var $field;
}
CustomModel::getByID(2)->field = "Testing";
// Autocomplete thinks that CustomModel::getByID(2) returns Model instead of CustomModel.
?>
I free handed this so sorry for mistakes. I did properly separate these into different files on my actual project.
Also sorry for putting in so many issues, really enjoying using this and I'll try to contribute when I can. Right now I'm not sure how the parser even works.
Every time I open a project in Atom, I get the following error message popping up then closing:
Incorrect setup!
Either PHP or Composer is not correctly set up and as a result PHP integrator will not work. Please visit the settings screen to correct this error. If you are not specifying an absolute path for PHP or Composer, make sure they are in your PATH.
What's strange is the plugin seems to work properly despite this error message, I've been using it since before I started getting this message.
On a side note, this message appears on all my projects, not just the ones using PHP and Composer. Perhaps this plugin could detect if a project is using Composer, and only run for those projects.
Can it work without autoload scripts? It would be cool to have an ability to integrate with CMS and others.
I wanna to work with CakePHP 2, Bitrix, Joomla, etc.
Now it works really great with Laravel 5!
It is currently not possible to correctly determine the type of variables that receive their type from lines that are spread over multiple consecutive lines, for example:
$test = $this->someClassInstance;
$test-> // Works.
$test =
$this->someClassInstance
$test-> // Fails.
The indexing loading bar always behaved somewhat oddly, in that if you create a new Untitled document that is unrelated to a project (the default when opening Atom unless a project was open when Atom was quit), it would show the loading icon forever.
Nothing major as it's not there for saved files, just a little odd.
But today I go to use this plugin with my Composer project I've been working on off-and-on, after a bit of a break so I'm not sure when this would have started, I see the loading bar twice, and one actually looks different from the other.
Eventually, the one on the left disappears, and shortly there after the one on the right disappears also. I'm not sure if it's running twice, or just a cosmetic issue, but thought it was worth noting.
It appears if a file containing multiple classes is indexed, only the first class is acknowledged.
e.g
TestClass.php:
<?php
class TestClass {
public function foo() {}
}
class TestClass_Controller {
public function bar() {}
}
TestClass_Controller
is ignored in this case!
Also, when using autocomplete, $this
remains as TestClass
, even when in the TestClass_Controller
class scope.
PHP is a scripting language, as such it is sometimes hard to determine what the exact type is of a variable, as the scope of variables extends outside if-statements, e.g.:
if (something) {
$test = new Foo();
} elseif (something else) {
$test = new Bar();
}
// Should $test be listed here or not? If yes, what type should it have?
Currently this is a best effort; $test
will be listed and its type will be inferred as being Bar
as that's the last match it can find. However, perhaps it's better if we confine the matching explicitly to a block; for example, using instanceof
:
$test = new Foo();
if ($test instanceof Bar) {
$test-> // Autocompletion for Bar, which is fine.
}
$test-> // Autocompletion for Bar??
In this case we should probably be showing autocompletion for Foo
instead, as outside the if-statement all bets on the type of $test
are off. In the top example, you should not be doing anything outside the if statements on $test
that aren't method calls or properties that are available for both Foo
and Bar
, in which case they should be sharing an interface:
if (something) {
$test = new Foo();
} elseif (something else) {
$test = new Bar();
}
// $test should be shown, but it should be having no type, i.e. getVariableType should
// be skipping nested blocks entirely.
/** @var InterfaceUsedByFooAndBar $test */
if (something) {
$test = new Foo();
} elseif (something else) {
$test = new Bar();
}
// $test should be shown and give autocompletion for InterfaceUsedByFooAndBar.
// function myFunction(InterfaceUsedByFooAndBar $test)
if (something) {
$test = new Foo();
} elseif (something else) {
$test = new Bar();
}
// $test should be shown and give autocompletion for InterfaceUsedByFooAndBar.
As a result of this, this will also happen:
$test = new SomethingElse();
if (something) {
$test = new Foo();
} elseif (something else) {
$test = new Bar();
}
// $test should be shown and give autocompletion for SomethingElse.
Important notes for development:
Currently, startLine
is returned for neither properties nor constants, as they aren't fetchable through Reflection. Instead, php-integrator-navigation searches for these items using regular expressions in CoffeeScript. This should not be necessary, the PHP side should be doing the search using regular expressions if at all necessary, as the 'client' side should not have to care where the data comes from. If, in the future, PHP decides to return this information through Reflection, we can then just rewrite it on the PHP side without modifying the other packages.
I don't believe this is an autocomplete bug, since autocomplete relies on the base for the data. When you open a project and open a new or existing file, the autocomplete has no information on any of the project classes. There's no initial index of all classes. You have to open each individual class file let it index it before you can use the class.
This currently does not work:
(new Foo)-> // No autocompletion is provided, even though we know the type of the expression.
getAllVariables
as well as getVariableType
should skip scopes that aren't relevant, for example:
$y = new Foo();
function foo()
{
$x = 5;
$y = new Bar();
$z = 3;
$callback = function () use ($z) {
// $x and $y should not be visible here, $z should be visible.
};
return null;
}
// I shouldn't see $x in autocompletion here as it is in another scope.
// $y should not resolve to an instance of Bar, but of Foo.
Currently, it includes all variables that occur somewhere between the start of the function or method and the buffer position.
getOuterFunctionStart
could be rewritten to return information about all ranges that contain information relevant to the current function, i.e. for the above example with the buffer position after return null
, it would return a range from function foo
up until use ($z) {
and another range from };
to after return null
. This way the ranges that don't apply can be easily skipped by iterating over the ranges that do apply in the caller. Also: getOuterFunctionStart
needs refactoring as it's currently fetching the entire buffer text whilst it could just use lineTextForBufferRow
instead.
[Enter steps to reproduce below:]
Atom Version: 1.3.3
System: Microsoft Windows 10 Home
Thrown From: php-integrator-base package, v0.4.4
Uncaught spawnSync C:\Bitnami\wampstack-7.0.0-0\php\php.exe ENOENT
At /C:/Users/MichaelA/.atom/packages/php-integrator-base/lib/Proxy.coffee:77
undefined
-0:20.2.0 core:backspace (atom-text-editor.editor.is-focused)
-0:19.6.0 editor:newline (atom-text-editor.editor.is-focused)
-0:15.8.0 core:backspace (atom-text-editor.editor.is-focused)
-0:05.5.0 core:save (atom-text-editor.editor.is-focused)
{
"core": {
"fileEncoding": "iso88591",
"projectHome": "F:\\_MY-WEBAPPS",
"themes": [
"one-light-ui",
"atom-dark-syntax"
],
"disabledPackages": [
"open-on-github"
]
},
"php-integrator-base": {
"phpCommand": "C:\\Bitnami\\wampstack-7.0.0-0\\php\\php.exe"
}
}
# User
aligner-php, v1.0.0
angular-jonpapa-snippets, v0.7.0
angular2-snippets, v0.3.0
angularjs, v0.3.3
angularjs-boilerplate-snippets, v0.3.1
angularjs-snippets, v0.10.18
angularjs-styleguide-snippets, v0.7.3
angularjs-styleguide-snippets-es6, v1.0.3
angularjs-styleguide-webpack-snippets, v1.0.1
atom-autocomplete-php, v0.18.4
atom-beautify, v0.28.20
atom-bootstrap4, v1.4.0
atom-html-preview, v0.1.13
atom-ternjs, v0.12.2
auto-detect-indentation, v0.4.2
autoclose-html, v0.19.0
autocomplete-angular-material, v0.4.0
autocomplete-html-entities, v0.1.0
autocomplete-php, v0.3.7
cdn-libs, v0.0.6
color-picker, v2.0.14
highlight-selected, v0.11.1
jquery-snippets, v11.0.0
language-coffee-script-angular, v2.2.0
linter, v1.11.3
linter-bootlint, v1.0.0
linter-js-standard, v3.2.1
minimap, v4.19.0
php-analyser, v0.2.0
php-cs-fixer, v2.5.2
php-integrator-base, v0.4.4
php-integrator-tooltips, v0.3.0
pigments, v0.19.5
# Dev
No dev packages
Indexing fails for me in a Symfony2 project, it seems that there are some issues related to indexing PHP's builtin constants.
I traced the issue to lines 967 - 979 in php/src/Indexer.php, commenting these lines results in calling toString() null.
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: constants.name' in /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91
Stack trace:
#0 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(91): PDOStatement->execute(Array)
#1 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(993): Doctrine\DBAL\Driver\PDOStatement->execute(Array)
#2 /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(696): Doctrine\DBAL\Connection->executeUpdate('INSERT INTO con...', Array, Array)
#3 /home/tocjent/.atom/packages/php-integrator-base/php/src/IndexDatabase.php(591): Doctrine\DBAL\Connection->insert('constants', Array)
#4 /home/tocjent/.atom/packages/php-integrator-base/php/src/Indexer.php(990): PhpIntegrator\Index in /home/tocjent/.atom/packages/php-integrator-base/php/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php on line 53
PHP Notice: Undefined property: PhpParser\Node\Stmt\Class_::$namespacedName in /home/tocjent/.atom/packages/php-integrator-base/php/src/Indexer/DependencyFetchingVisitor.php on line 36
PHP Fatal error: Call to a member function toString() on null in /home/tocjent/.atom/packages/php-integrator-base/php/src/Indexer/DependencyFetchingVisitor.php on line 36
I tried to load my stubs.php file, but it doesn't work.
https://github.com/Gert-dev/php-integrator-autocomplete-plus/issues/8
After playing with the script path it seems buggy?
I entered a not existing script path and all looks fine. No error message or "file not found" message.
Relative path (based on the project directory opened in Atom, stubs.php is also inside the project) I get an "Indexing failed!" message without any debugging information.
So how could I check if the correct file is loaded? Why there is no "file not found" message?
As the title indicates, investigate switching to ReflectionDocBlock also used by phpDocumentor. This removes the need for our custom DocParser
that is not entirely compliant and will also ensure that we are compliant with all the corner cases. Finally, it is likely that this project will follow the upcoming PSR-5 when it is released, which is even more interesting for compliance.
Everything we need seems to be supported, with the exception of one item [1].
[1] phpDocumentor/ReflectionDocBlock#69
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
(This issue applies to master only, as 0.3.0 hasn't been released yet.)
Works:
$func = function (array $value) {
return $value;
};
$func-> // Type properly deduced.
Fails:
$func = function (array $value) {
$value['a'] = $this->method($value['a']);
};
$func-> // Type not properly deduced.
I'm getting an error that only shows up in the Javascript error console (Atom doesn't throw and error and allow me to submit a bug report). I've included a screenshot of what I'm seeing in the console. I know there isn't much information in it, so let me know what else I can do to help you troubleshoot this problem.
Thanks!
Hopefully this will allow us to fall back on the cache for autocompletion when there is a syntax error (instead of stopping autocompletion and all other functionality from working altogether).
It would be neat if the indexer was more informative about errors, i.e.:
E_ALL
in the spawned subprocesses for this).Commit d6e9efa adds a visual indicator in the status bar when indexing is failing.
Currently we're checking for:
/** @var Type $foo */
/** @var $foo Type */
But descriptions are also possible:
/** @var Type $foo A description. */
/** @var $foo Type A description. */
Works (not valid PHP, but to indicate the search stops correctly on the equals sign):
$array = [
'test' = (new Foo())-> // No autocompletion (php-integrator-autocomplete-plus).
];
Fails:
$array = [
'test' => (new Foo())-> // No autocompletion (php-integrator-autocomplete-plus).
];
Should also add a spec for this corner case.
The type of a property will incorrectly resolve to null
with the following docblock:
/**
* @var BarAlias|null
* --------
*/
Hello!
I was using php integrator in my project last night normally, and today I upgraded to the last version and it's not indexing correctly anymore.
I have checked the settings and the composer and php commands are correct. I tested with the global composer and with a composer.phar located in my project's root directory.
My project is based on Laravel 5.1, which follows PSR-4 standards.
What could be causing this issue?
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.