Skip to content

Commit 0ad2b9e

Browse files
committed
Improve documentation, use fully qualified class names in all examples
1 parent 925d5ba commit 0ad2b9e

File tree

7 files changed

+15
-27
lines changed

7 files changed

+15
-27
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ Let's take these projects to the next level together! 🚀
5151
Once [installed](#install), you can use the following code to present a prompt in a CLI program:
5252

5353
```php
54-
$stdio = new Stdio();
54+
<?php
5555

56+
require __DIR__ . '/vendor/autoload.php';
57+
58+
$stdio = new Clue\React\Stdio\Stdio();
5659
$stdio->setPrompt('Input > ');
5760

5861
$stdio->on('data', function ($line) use ($stdio) {
@@ -76,7 +79,7 @@ It is responsible for orchestrating the input and output streams
7679
by registering and forwarding the corresponding events.
7780

7881
```php
79-
$stdio = new Stdio();
82+
$stdio = new Clue\React\Stdio\Stdio();
8083
```
8184

8285
This class takes an optional `LoopInterface|null $loop` parameter that can be used to

examples/01-periodic.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
43
use React\EventLoop\Loop;
54

65
require __DIR__ . '/../vendor/autoload.php';
76

8-
$stdio = new Stdio();
7+
$stdio = new Clue\React\Stdio\Stdio();
98

109
$stdio->write('Will print periodic messages until you submit anything' . PHP_EOL);
1110

examples/02-interactive.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
4-
53
require __DIR__ . '/../vendor/autoload.php';
64

7-
$stdio = new Stdio();
8-
5+
$stdio = new Clue\React\Stdio\Stdio();
96
$stdio->setPrompt('> ');
107

118
// limit history to HISTSIZE env

examples/03-commander.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
4-
use Clue\Arguments;
5-
use Clue\Commander\Router;
6-
use Clue\Commander\NoRouteFoundException;
7-
83
require __DIR__ . '/../vendor/autoload.php';
94

10-
$stdio = new Stdio();
5+
$stdio = new Clue\React\Stdio\Stdio();
116
$stdio->setPrompt('> ');
127

138
// limit history to HISTSIZE env
@@ -21,7 +16,7 @@
2116
}
2217

2318
// register all available commands and their arguments
24-
$router = new Router();
19+
$router = new Clue\Commander\Router();
2520
$router->add('exit | quit', function() use ($stdio) {
2621
$stdio->end();
2722
});
@@ -54,8 +49,8 @@
5449
}
5550

5651
try {
57-
$args = Arguments\split($line);
58-
} catch (Arguments\UnclosedQuotesException $e) {
52+
$args = Clue\Arguments\split($line);
53+
} catch (Clue\Arguments\UnclosedQuotesException $e) {
5954
$stdio->write('Error: Invalid command syntax (unclosed quotes)' . PHP_EOL);
6055
return;
6156
}
@@ -67,7 +62,7 @@
6762

6863
try {
6964
$router->handleArgs($args);
70-
} catch (NoRouteFoundException $e) {
65+
} catch (Clue\Commander\NoRouteFoundException $e) {
7166
$stdio->write('Error: Invalid command usage' . PHP_EOL);
7267
}
7368
});

examples/04-bindings.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
4-
53
require __DIR__ . '/../vendor/autoload.php';
64

7-
$stdio = new Stdio();
5+
$stdio = new Clue\React\Stdio\Stdio();
86
$stdio->setPrompt('> ');
97

108
// add some special key bindings

examples/05-cursor.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
4-
53
require __DIR__ . '/../vendor/autoload.php';
64

7-
$stdio = new Stdio();
5+
$stdio = new Clue\React\Stdio\Stdio();
86

97
$value = 10;
108
$stdio->on("\033[A", function () use (&$value, $stdio) {

examples/11-login.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22

3-
use Clue\React\Stdio\Stdio;
4-
53
require __DIR__ . '/../vendor/autoload.php';
64

7-
$stdio = new Stdio();
5+
$stdio = new Clue\React\Stdio\Stdio();
86
$stdio->setPrompt('Username: ');
97

108
$first = true;

0 commit comments

Comments
 (0)