Skip to content

Commit 471bf06

Browse files
committed
Merge branch 'master' into 3.1
# Conflicts: # .github/workflows/test.yml # src/service-governance/src/Listener/RegisterServiceListener.php # src/stringable/composer.json # src/stringable/tests/StrTest.php
2 parents 1c760c8 + eb3af1d commit 471bf06

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616
- name: Create Release
1717
id: create_release
1818
uses: actions/create-release@v1

publish/devtool.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
'aspect' => [
3030
'namespace' => 'App\\Aspect',
3131
],
32+
'class' => [
33+
'namespace' => 'App',
34+
],
3235
'command' => [
3336
'namespace' => 'App\\Command',
3437
],

src/Generator/ClassCommand.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace Hyperf\Devtool\Generator;
13+
14+
use Hyperf\Command\Annotation\Command;
15+
16+
#[Command]
17+
class ClassCommand extends GeneratorCommand
18+
{
19+
public function __construct()
20+
{
21+
parent::__construct('gen:class');
22+
}
23+
24+
public function configure()
25+
{
26+
$this->setDescription('Create a new class');
27+
28+
parent::configure();
29+
}
30+
31+
protected function getStub(): string
32+
{
33+
return $this->getConfig()['stub'] ?? __DIR__ . '/stubs/class.stub';
34+
}
35+
36+
protected function getDefaultNamespace(): string
37+
{
38+
return $this->getConfig()['namespace'] ?? 'App';
39+
}
40+
}

src/Generator/stubs/class.stub

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace %NAMESPACE%;
6+
7+
class %CLASS%
8+
{
9+
10+
}

0 commit comments

Comments
 (0)