Skip to content

Commit a51ed03

Browse files
committed
minor #47 Improved some PHPdoc comments (javiereguiluz)
This PR was merged into the 1.0-dev branch. Discussion ---------- Improved some PHPdoc comments Commits ------- 6a894ad Improved some PHPdoc comments
2 parents d59e03b + 6a894ad commit a51ed03

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/Command/AbstractCommand.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,34 @@ public function __construct(Generator $generator)
4141
}
4242

4343
/**
44-
* Returns the parameters used to parse the file templates, to generate the
45-
* file names, etc.
44+
* Returns the values used to fill in the skeleton files of the generated
45+
* code and the success/error messages as pairs of param_name => param_value.
46+
* (e.g. ['user' => 'Jane', 'project_dir' => realpath(__DIR__.'/..')])
4647
*/
4748
abstract protected function getParameters(): array;
4849

4950
/**
50-
* Returns the list of files to generate and the templates used to do that.
51+
* Returns the list of files to generate as pairs of skeleton_filepath => generated_filepath
52+
* Skeleton files must be absolute paths and generated paths are relative to the app.
53+
* (e.g. [__DIR__.'/../Resources/skeleton/command/Command.php.txt' => 'src/Command/'.$params['command_class_name'].'.php'])
5154
*/
5255
abstract protected function getFiles(array $params): array;
5356

5457
/**
55-
* Override to add a final "next steps" message.
56-
*
57-
* @param array $params
58-
* @param ConsoleStyle $io
58+
* Optional information displayed to the user after all files have been generated.
5959
*/
6060
abstract protected function writeNextStepsMessage(array $params, ConsoleStyle $io);
6161

62+
/**
63+
* Defines the optional or required dependencies of the maker command, which are
64+
* checked before running the command and used to display actionable error messages.
65+
*/
6266
abstract protected function configureDependencies(DependencyBuilder $dependencies);
6367

6468
/**
6569
* Call in configure() to disable the automatic interactive prompt for an arg.
66-
*
67-
* @param string $argumentName
6870
*/
69-
protected function setArgumentAsNonInteractive($argumentName)
71+
protected function setArgumentAsNonInteractive(string $argumentName)
7072
{
7173
$this->nonInteractiveArguments[] = $argumentName;
7274
}

src/Str.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,37 @@
1818
final class Str
1919
{
2020
/**
21-
* Looks for suffixes in a case-insensitive way.
21+
* Looks for suffixes in strings in a case-insensitive way.
2222
*/
2323
public static function hasSuffix(string $value, string $suffix): bool
2424
{
2525
return 0 === strcasecmp($suffix, substr($value, -strlen($suffix)));
2626
}
2727

2828
/**
29-
* Ensures that the given string ends with the given suffix. It works in a
30-
* case-insensitive way (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'FooCommand'
29+
* Ensures that the given string ends with the given suffix. If the string
30+
* already contains the suffix, it's not added twice. It's case-insensitive
31+
* (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'FooCommand')
3132
*/
3233
public static function addSuffix(string $value, string $suffix): string
3334
{
3435
return self::removeSuffix($value, $suffix).$suffix;
3536
}
3637

3738
/**
38-
* Ensures that the given string doesn't end with the given suffix. It works in a
39-
* case-insensitive way (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'Foo'
39+
* Ensures that the given string doesn't end with the given suffix. If the
40+
* string contains the suffix multiple times, only the last one is removed.
41+
* It's case-insensitive (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'Foo'
4042
*/
4143
public static function removeSuffix(string $value, string $suffix): string
4244
{
4345
return self::hasSuffix($value, $suffix) ? substr($value, 0, -strlen($suffix)) : $value;
4446
}
4547

4648
/**
47-
* Transforms the given string into the format commonly used by PHP classes
48-
* (e.g. `app:do_this-and_that` -> `AppDoThisAndThat`)
49+
* Transforms the given string into the format commonly used by PHP classes,
50+
* (e.g. `app:do_this-and_that` -> `AppDoThisAndThat`) but it doesn't check
51+
* the validity of the class name.
4952
*/
5053
public static function asClassName(string $value, string $suffix = ''): string
5154
{

0 commit comments

Comments
 (0)