Skip to content

Commit 7fa23c6

Browse files
committed
init
0 parents  commit 7fa23c6

16 files changed

+411
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/tests export-ignore
2+
/.github export-ignore

.github/workflows/release.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Release
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: Release ${{ github.ref }}
24+
draft: false
25+
prerelease: false

.github/workflows/test.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: PHPUnit
2+
3+
on: [ push, pull_request ]
4+
5+
env:
6+
SWOOLE_VERSION: '4.8.10'
7+
SWOW_VERSION: 'develop'
8+
9+
jobs:
10+
ci:
11+
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.engine }}
12+
runs-on: "${{ matrix.os }}"
13+
strategy:
14+
matrix:
15+
os: [ ubuntu-latest ]
16+
php-version: [ '7.3', '7.4', '8.0' ]
17+
engine: [ 'none', 'swoole', 'swow' ]
18+
exclude:
19+
- php-version: '7.3'
20+
engine: 'swow'
21+
- php-version: '7.4'
22+
engine: 'swow'
23+
max-parallel: 5
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php-version }}
31+
tools: phpize
32+
ini-values: opcache.enable_cli=0
33+
coverage: none
34+
- name: Setup Swoole
35+
if: ${{ matrix.engine == 'swoole' }}
36+
run: |
37+
cd /tmp
38+
sudo apt-get update
39+
sudo apt-get install libcurl4-openssl-dev
40+
wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz
41+
mkdir -p swoole
42+
tar -xf swoole.tar.gz -C swoole --strip-components=1
43+
rm swoole.tar.gz
44+
cd swoole
45+
phpize
46+
./configure --enable-openssl --enable-http2 --enable-swoole-curl --enable-swoole-json
47+
make -j$(nproc)
48+
sudo make install
49+
sudo sh -c "echo extension=swoole > /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
50+
php --ri swoole
51+
- name: Setup Swow
52+
if: ${{ matrix.engine == 'swow' }}
53+
run: |
54+
cd /tmp
55+
wget https://github.com/swow/swow/archive/"${SWOW_VERSION}".tar.gz -O swow.tar.gz
56+
mkdir -p swow
57+
tar -xf swow.tar.gz -C swow --strip-components=1
58+
rm swow.tar.gz
59+
cd swow/ext || exit
60+
61+
phpize
62+
./configure --enable-debug
63+
make -j "$(nproc)"
64+
sudo make install
65+
sudo sh -c "echo extension=swow > /etc/php/${{ matrix.php-version }}/cli/conf.d/swow.ini"
66+
php --ri swow
67+
- name: Setup Packages
68+
run: composer update -o --no-scripts
69+
- name: Run Test Cases
70+
run: |
71+
vendor/bin/php-cs-fixer fix --dry-run
72+
composer analyse
73+
composer test

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.idea
2+
/vendor/
3+
composer.lock
4+
*.cache
5+
*.log

.php-cs-fixer.php

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$header = <<<'EOF'
6+
7+
EOF;
8+
9+
return (new PhpCsFixer\Config())
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR12' => true,
13+
'@Symfony' => true,
14+
'@DoctrineAnnotation' => true,
15+
'@PhpCsFixer' => true,
16+
'header_comment' => [
17+
'comment_type' => 'PHPDoc',
18+
'header' => $header,
19+
'separate' => 'none',
20+
'location' => 'after_declare_strict',
21+
],
22+
'array_syntax' => [
23+
'syntax' => 'short',
24+
],
25+
'list_syntax' => [
26+
'syntax' => 'short',
27+
],
28+
'concat_space' => [
29+
'spacing' => 'one',
30+
],
31+
'blank_line_before_statement' => [
32+
'statements' => [
33+
'declare',
34+
],
35+
],
36+
'general_phpdoc_annotation_remove' => [
37+
'annotations' => [
38+
'author',
39+
],
40+
],
41+
'ordered_imports' => [
42+
'imports_order' => [
43+
'class', 'function', 'const',
44+
],
45+
'sort_algorithm' => 'alpha',
46+
],
47+
'single_line_comment_style' => [
48+
'comment_types' => [
49+
],
50+
],
51+
'yoda_style' => [
52+
'always_move_variable' => false,
53+
'equal' => false,
54+
'identical' => false,
55+
],
56+
'phpdoc_align' => [
57+
'align' => 'left',
58+
],
59+
'multiline_whitespace_before_semicolons' => [
60+
'strategy' => 'no_multi_line',
61+
],
62+
'constant_case' => [
63+
'case' => 'lower',
64+
],
65+
'class_attributes_separation' => true,
66+
'combine_consecutive_unsets' => true,
67+
'declare_strict_types' => true,
68+
'linebreak_after_opening_tag' => true,
69+
'lowercase_static_reference' => true,
70+
'no_useless_else' => true,
71+
'no_unused_imports' => true,
72+
'not_operator_with_successor_space' => true,
73+
'not_operator_with_space' => false,
74+
'ordered_class_elements' => true,
75+
'php_unit_strict' => false,
76+
'phpdoc_separation' => false,
77+
'single_quote' => true,
78+
'standardize_not_equals' => true,
79+
'multiline_comment_opening_closing' => true,
80+
])
81+
->setFinder(
82+
PhpCsFixer\Finder::create()
83+
->exclude('vendor')
84+
->in(__DIR__)
85+
)
86+
->setUsingCache(false);

.phpstorm.meta.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
// Reflect
5+
override(\Psr\Container\ContainerInterface::get(0), map('@'));
6+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Hyperf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# component-creator
2+
3+
```
4+
composer create-project hyperf/component-creator
5+
```

composer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "kkguan/php-mapstruct",
3+
"type": "library",
4+
"license": "MIT",
5+
"keywords": [
6+
"php",
7+
"hyperf"
8+
],
9+
"description": "",
10+
"autoload": {
11+
"psr-4": {
12+
"Kkguan\\PHPMapstruct\\": "src/"
13+
}
14+
},
15+
"autoload-dev": {
16+
"psr-4": {
17+
"HyperfTest\\": "tests"
18+
}
19+
},
20+
"require": {
21+
"php": ">=8.0"
22+
},
23+
"require-dev": {
24+
"friendsofphp/php-cs-fixer": "^3.0",
25+
"mockery/mockery": "^1.0",
26+
"phpstan/phpstan": "^1.0",
27+
"phpunit/phpunit": ">=7.0",
28+
"swoole/ide-helper": "^4.5"
29+
},
30+
"suggest": {
31+
"swow/swow": "Required to create swow components."
32+
},
33+
"minimum-stability": "dev",
34+
"prefer-stable": true,
35+
"config": {
36+
"optimize-autoloader": true,
37+
"sort-packages": true
38+
},
39+
"scripts": {
40+
"test": "phpunit -c phpunit.xml --colors=always",
41+
"analyse": "phpstan analyse --memory-limit 1024M -l 0 ./src",
42+
"cs-fix": "php-cs-fixer fix $1"
43+
}
44+
}

phpunit.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="tests/bootstrap.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
verbose="true"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuite name="Testsuite">
13+
<directory>./tests/</directory>
14+
</testsuite>
15+
</phpunit>

src/Mapper.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kkguan\PHPMapstruct;
6+
7+
use Attribute;
8+
9+
#[\Attribute(\Attribute::TARGET_CLASS)]
10+
class Mapper
11+
{
12+
public function __construct(
13+
public array $uses = [],
14+
public array $imports = [],
15+
public ?string $componentModel = null,
16+
) {
17+
}
18+
}

src/Mapping.php

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kkguan\PHPMapstruct;
6+
7+
use Attribute;
8+
9+
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
10+
class Mapping
11+
{
12+
// TODO
13+
public function __construct(
14+
public string $target = '',
15+
public string $source = '',
16+
public string $dateFormat = '',
17+
public string $numberFormat = '',
18+
public string $constant = '',
19+
public string $expression = '',
20+
public string $defaultExpression = '',
21+
public bool $ignore = false,
22+
) {
23+
}
24+
25+
public function getTarget(): string
26+
{
27+
return $this->target;
28+
}
29+
30+
public function getSource(): string
31+
{
32+
return $this->source;
33+
}
34+
35+
public function getDateFormat(): string
36+
{
37+
return $this->dateFormat;
38+
}
39+
40+
public function getNumberFormat(): string
41+
{
42+
return $this->numberFormat;
43+
}
44+
45+
public function getConstant(): string
46+
{
47+
return $this->constant;
48+
}
49+
50+
public function getExpression(): string
51+
{
52+
return $this->expression;
53+
}
54+
55+
public function getDefaultExpression(): string
56+
{
57+
return $this->defaultExpression;
58+
}
59+
60+
public function isIgnore(): bool
61+
{
62+
return $this->ignore;
63+
}
64+
}

src/MappingTarget.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kkguan\PHPMapstruct;
6+
7+
use Attribute;
8+
9+
#[\Attribute(\Attribute::TARGET_CLASS)]
10+
class MappingTarget
11+
{
12+
}

0 commit comments

Comments
 (0)