Skip to content

Commit 6e3f75a

Browse files
committed
Prepare examples for use as fixtures
1 parent 9adf66c commit 6e3f75a

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

Phpakefile

+3-16
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,10 @@
66
*/
77

88
/**
9-
* Display hello world.
10-
*/
11-
function hello_world() {
12-
echo 'Hello world' . PHP_EOL;
13-
}
14-
15-
/**
16-
* Function names starting with _ do not translate into commands.
17-
*/
18-
function _this_is_not_a_task() {
19-
// Do something.
20-
}
21-
22-
/**
23-
* Additional Phpakefile can be imported like a regular PHP file.
9+
* Phpakefiles can be imported like a regular PHP files.
2410
*/
11+
require_once __DIR__ . '/examples/hello-world.phpakefile';
2512
require_once __DIR__ . '/examples/input-output.phpakefile';
2613
require_once __DIR__ . '/examples/variadic.phpakefile';
2714
require_once __DIR__ . '/examples/shell.phpakefile';
28-
require_once __DIR__ . '/examples/namespace.phpakefile';
15+
require_once __DIR__ . '/examples/fizzbuzz.phpakefile';

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ A *Phpakefile* contains definitions of tasks that can be executed by Phpake.
5656
The following subheadings are about defining such tasks. A Phpake task definition
5757
is simply a PHP function (a task callback). Here's are some examples:
5858

59-
- [Hello world](Phpakefile)
59+
- [Hello world](examples/hello-world.phpakefile)
6060
- [Input Output](examples/input-output.phpakefile)
61-
- [Namespaces](examples/variadic.phpakefile)
61+
- [Namespaces](examples/fizzbuzz.phpakefile)
6262
- [Variadic arguments](examples/variadic.phpakefile)
6363
- [Shell commands](examples/shell.phpakefile)
64+
- [Including commands](Phpakefile)
6465

6566
## Simple tasks
6667

File renamed without changes.

examples/hello-world.phpakefile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* Say hello world.
5+
*/
6+
function hello_world() {
7+
echo 'Hello world' . PHP_EOL;
8+
}
9+
10+
function hello_ladies() {
11+
// Doc block comments are optional.
12+
// This task will be recognized and it will work.
13+
}
14+
15+
/**
16+
* A task that fails and returns a non-zero error code.
17+
*/
18+
function make_a_mess() {
19+
return 19;
20+
}
21+
22+
/**
23+
* Function names starting with _ do not translate into commands.
24+
*/
25+
function _this_is_not_a_task() {
26+
// Do something.
27+
}

examples/input-output.phpakefile

+3-10
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ function show_date($output) {
1616
}
1717

1818
/**
19-
* Says hello to a human.
19+
* Say hello to a human.
2020
*
2121
* Uses a required parameter, and an optional parameter. "param" annotations
2222
* are used, to describe the parameters. These descriptions are displayed with
2323
* command-specific help.
2424
*
25+
* Notice how the in-built parameter $output was kept towards the end.
26+
*
2527
* @usage Niki
2628
* @usage Niki Martin
2729
*
28-
* Notice how the in-built parameter $output was kept towards the end.
29-
*
3030
* @param string $fname First name.
3131
* @param string|null $lname Last name.
3232
* @param object $output
@@ -35,10 +35,3 @@ function hello_human(string $fname, string $lname = NULL, $output = NULL) {
3535
$name = $lname ? "$fname $lname" : "$fname";
3636
$output->writeln("Hello <info>$name</info>!");
3737
}
38-
39-
/**
40-
* A task that fails and returns a non-zero error code.
41-
*/
42-
function make_a_mess() {
43-
return 19;
44-
}

0 commit comments

Comments
 (0)