Skip to content

Commit cd3d8b8

Browse files
committed
TRADER-18 php parallel ide autocomplete init
1 parent ba90e89 commit cd3d8b8

File tree

6 files changed

+157
-1
lines changed

6 files changed

+157
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
composer.lock
3+
vendor/

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# php-parallel-ide-autocomplete
1+
# PHP Parallel - IDE autocomplete
2+
3+
This package allows you to activate the auto-complete in the IDE for native functions from the extension: [PHP Parallel](https://www.php.net/manual/en/book.parallel.php).
4+
5+
## Installation
6+
7+
Install the library using Composer. Please read the [Composer Documentation](https://getcomposer.org/doc/01-basic-usage.md) if you are unfamiliar with Composer or dependency managers in general.
8+
9+
You don't need this package in production, please use `require-dev`.
10+
```shell
11+
composer require --dev boruta/php-parallel-ide-autocomplete
12+
```
13+
14+
That's it, the IDE autocomplete should work.
15+
16+
## Requirements
17+
18+
Package requires PHP 7.2 or above and `ext-parallel` >= 1.1.4.
19+
20+
## About
21+
22+
If your IDE does not auto-complete functions from the PHP Parallel extension, add this package to your project to fix it. The directory `autocomplete` contains documentation of the functions from the extension mentioned above, without their implementation. This files are not automatically loaded by composer and you shouldn't include them. It's just their presence in the project directory, which fixes the missing documentation in the IDE. Just add the package to composer and your IDE should start displaying the documentation correctly.
23+
24+
![PHPStorm auto-complete fixed](image.png "PHPStorm auto-complete fixed")
25+
26+

autocomplete/Future.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace parallel;
5+
6+
7+
use RuntimeException;
8+
9+
/**
10+
* Interface Future
11+
* @package parallel
12+
* @link https://www.php.net/manual/en/class.parallel-future.php
13+
*/
14+
final class Future
15+
{
16+
private const EXCEPTION_MESSAGE = 'You should not autoload or include file `Future.php`! This file exists only for IDE auto complete function.';
17+
18+
/**
19+
* Shall return (and if necessary wait for) return from task.
20+
*
21+
* @return mixed
22+
*/
23+
public function value()
24+
{
25+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
26+
}
27+
28+
/**
29+
* Shall indicate if the task was cancelled.
30+
*
31+
* @return bool
32+
*/
33+
public function cancelled(): bool
34+
{
35+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
36+
}
37+
38+
/**
39+
* Shall indicate if the task is completed.
40+
*
41+
* @return bool
42+
*/
43+
public function done(): bool
44+
{
45+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
46+
}
47+
48+
/**
49+
* Shall try to cancel the task. If task is running, it will be interrupted.
50+
*
51+
* @return bool
52+
*/
53+
public function cancel(): bool
54+
{
55+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
56+
}
57+
}

autocomplete/Runtime.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace parallel;
5+
6+
7+
use RuntimeException;
8+
9+
/**
10+
* Interface Runtime
11+
* @package parallel
12+
* @link https://www.php.net/manual/en/parallel-runtime.run.php
13+
*/
14+
final class Runtime
15+
{
16+
private const EXCEPTION_MESSAGE = 'You should not autoload or include file `Runtime.php`! This file exists only for IDE auto complete function.';
17+
18+
/**
19+
* Shall construct a new runtime with or without bootstrapping.
20+
*
21+
* @param string $bootstrap [optional] The location of a bootstrap file, generally an autoloader.
22+
*/
23+
public function __construct(string $bootstrap = '')
24+
{
25+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
26+
}
27+
28+
/**
29+
* Shall schedule task for execution in parallel, passing argv at execution time.
30+
*
31+
* @param callable $task A Closure with specific characteristics.
32+
* @param array $argv [optional] An array of arguments with specific characteristics to be passed to task at execution time.
33+
* @return Future|null
34+
*/
35+
public function run(callable $task, array $argv = []): ?Future
36+
{
37+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
38+
}
39+
40+
/**
41+
* Shall request that the runtime shutdown. Tasks scheduled for execution will be executed before the shutdown occurs.
42+
*/
43+
public function close(): void
44+
{
45+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
46+
}
47+
48+
/**
49+
* Shall attempt to force the runtime to shutdown. Tasks scheduled for execution will not be executed, the currently running task shall be interrupted.
50+
*/
51+
public function kill(): void
52+
{
53+
throw new RuntimeException(self::EXCEPTION_MESSAGE);
54+
}
55+
}

composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "boruta/php-parallel-ide-autocomplete",
3+
"description": "This package allows you to activate the auto-complete in the IDE for native functions from the extension: PHP Parallel.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Boruta",
9+
"email": "sebastian@boruta.info"
10+
}
11+
],
12+
"require": {
13+
"php": ">=7.2",
14+
"ext-parallel": ">=1.1.4"
15+
}
16+
}

image.png

17 KB
Loading

0 commit comments

Comments
 (0)