Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Last active August 31, 2018 15:44
Show Gist options
  • Save Ciantic/07f14ed0247ec3cd92457099cb26e0fe to your computer and use it in GitHub Desktop.
Save Ciantic/07f14ed0247ec3cd92457099cb26e0fe to your computer and use it in GitHub Desktop.
Fixing a PHP Language Server for my own taste
{
"name": "ciantic/wp",
"authors": [
{
"name": "Ciantic",
"email": "nothere@example.com"
}
],
"require": {
"wp/WordPress": "^4.9",
"wp-plugins/advanced-custom-fields-pro": "^5.0",
"wp-plugins/woocommerce": "^5.0"
}
}
{
"packages": [
{
"name": "wp/WordPress",
"version": "4.9.4"
},
{
"name": "wp-plugins/advanced-custom-fields-pro",
"version": "5.6.8"
},
{
"name": "wp-plugins/woocommerce",
"version": "3.3.3"
}
],
"packages-dev": []
}
<?php
/**
* Will read and parse the passed source files in the project and add them to the appropiate indexes
*
* @return Promise <void>
*/
public function index(): Promise
{
return coroutine(function () {
$pattern = Path::makeAbsolute('**/*.php', $this->rootPath);
$uris = yield $this->filesFinder->find($pattern);
// CIANTIC Fixes things for good
if (preg_match("#wp-content[\\\\/]themes#", $this->rootPath)) {
$this->client->window->logMessage(MessageType::INFO, "My WordPress themes should have stuff from here!");
$this->composerLock = json_decode(file_get_contents("file:///C:/DepSource/WP/composer.lock"));
$this->composerJson = json_decode(file_get_contents("file:///C:/DepSource/WP/composer.json"));
// $this->client->window->logMessage(MessageType::INFO, "test" . var_export($this->composerLock, true) . var_export($this->composerJson, true));
$uris = array_merge($uris, yield $this->filesFinder->find('C:/DepSource/WP/**/*.php'));
}
$count = count($uris);
$startTime = microtime(true);
$this->client->window->logMessage(MessageType::INFO, "$count files total");
/** @var string[] */
$source = [];
/** @var string[][] */
$deps = [];
@Ciantic
Copy link
Author

Ciantic commented Apr 10, 2018

Also remember to change PHPDocumentLoader.php line $limit = 15... to something greater.

@Ciantic
Copy link
Author

Ciantic commented Aug 30, 2018

  1. Create folder "C:/DepSource/WP"
  2. Store the composer.json and composer.lock there
  3. Download WordPress to "C:/DepSource/WP/vendor/wp/"
  4. Open \felixfbecker.php-intellisense-2.3.4\vendor\felixfbecker\language-server\src\Indexer.php add the changes above

@Ciantic
Copy link
Author

Ciantic commented Aug 30, 2018

Note This does extra check there: if (preg_match("#wp-content[\\\\/]themes#", $this->rootPath)) { if your themes are not in path wp-content/themes you have to change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment