Skip to content

Commit cbe53a5

Browse files
committed
Add the code generator setup
1 parent 4050e49 commit cbe53a5

File tree

5 files changed

+134
-1
lines changed

5 files changed

+134
-1
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/tests export-ignore
22
/.github export-ignore
3+
/.cache export-ignore
34
/.gitattributes export-ignore
45
/.gitignore export-ignore
6+
/.php-cs-fixer.php export-ignore
57
/phpstan.neon export-ignore
68
/phpunit.xml.dist export-ignore
9+
/generate export-ignore
710
/manifest export-ignore
11+
/manifest.json export-ignore

.php-cs-fixer.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__.'/src')
5+
->in(__DIR__.'/tests')
6+
;
7+
8+
return (new PhpCsFixer\Config())
9+
->setCacheFile(__DIR__.'/.cache/php-cs-fixer/.php-cs-fixer.cache')
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR2' => true,
13+
'@Symfony' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
'blank_line_after_opening_tag' => true,
16+
'concat_space' => ['spacing' => 'one'],
17+
'declare_strict_types' => false,
18+
'fully_qualified_strict_types' => true,
19+
'header_comment' => false,
20+
'lowercase_cast' => true,
21+
'is_null' => true,
22+
'magic_method_casing' => true,
23+
'modernize_types_casting' => true,
24+
'multiline_comment_opening_closing' => true,
25+
'native_constant_invocation' => ['include' => ['ReturnTypeWillChange', 'UUID_TYPE_RANDOM']],
26+
'no_alias_functions' => true,
27+
'no_alternative_syntax' => true,
28+
'no_blank_lines_after_phpdoc' => true,
29+
'no_empty_comment' => true,
30+
'no_empty_phpdoc' => true,
31+
'no_extra_blank_lines' => ['tokens' => [
32+
'extra',
33+
'use', 'attribute',
34+
'curly_brace_block',
35+
'parenthesis_brace_block',
36+
'square_brace_block',
37+
'switch', 'case', 'default', 'break', 'continue',
38+
'return', 'throw',
39+
]],
40+
'no_leading_import_slash' => true,
41+
'no_spaces_around_offset' => true,
42+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
43+
'no_trailing_comma_in_singleline' => true,
44+
'no_unset_cast' => true,
45+
'no_unused_imports' => true,
46+
'no_useless_else' => true,
47+
'no_useless_return' => true,
48+
'no_whitespace_in_blank_line' => true,
49+
'ordered_imports' => true,
50+
'ordered_interfaces' => true,
51+
'php_unit_mock' => ['target' => 'newest'],
52+
'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'],
53+
'php_unit_expectation' => ['target' => 'newest'],
54+
'php_unit_no_expectation_annotation' => ['target' => 'newest'],
55+
// 'php_unit_test_annotation' => ['style' => 'prefix'],
56+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
57+
'php_unit_mock_short_will_return' => true,
58+
'phpdoc_align' => ['align' => 'vertical'],
59+
'phpdoc_line_span' => ['method' => 'multi', 'property' => 'multi'],
60+
'phpdoc_scalar' => true,
61+
'phpdoc_separation' => true,
62+
'phpdoc_single_line_var_spacing' => true,
63+
'phpdoc_trim' => true,
64+
'phpdoc_trim_consecutive_blank_line_separation' => true,
65+
'phpdoc_types' => true,
66+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
67+
'phpdoc_var_without_name' => true,
68+
'short_scalar_cast' => true,
69+
'single_line_throw' => true,
70+
'single_trait_insert_per_statement' => true,
71+
'standardize_not_equals' => true,
72+
'nullable_type_declaration_for_default_null_value' => true,
73+
'visibility_required' => true,
74+
'yoda_style' => true,
75+
'native_function_invocation' => ['include' => ['@compiler_optimized']],
76+
'compact_nullable_typehint' => true,
77+
'declare_equal_normalize' => ['space' => 'none'],
78+
'function_typehint_space' => true,
79+
'no_leading_namespace_whitespace' => true,
80+
'blank_line_before_statement' => true,
81+
'single_quote' => true,
82+
'phpdoc_to_comment' => false,
83+
'ordered_class_elements' => ['sort_algorithm' => 'none'],
84+
'class_attributes_separation' => ['elements' => ['property' => 'one', 'method' => 'one']],
85+
'array_indentation' => true,
86+
])
87+
->setFinder($finder)
88+
;

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
"name": "incenteev/async-amazon-incentives",
33
"description": "SDK for the Amazon Incentives API based on the structure of the async-aws project",
44
"license": "MIT",
5-
"keywords": ["AmazonGiftCode", "Amazon", "GiftCard", "AGCOD", "Incentives API", "Amazon Incentives API"],
5+
"keywords": [
6+
"AmazonGiftCode",
7+
"Amazon",
8+
"GiftCard",
9+
"AGCOD",
10+
"Incentives API",
11+
"Amazon Incentives API"
12+
],
613
"require": {
714
"php": "^8.1"
815
},
916
"require-dev": {
17+
"async-aws/code-generator": "dev-master",
18+
"friendsofphp/php-cs-fixer": "^3.18",
1019
"phpstan/phpstan": "^1.10",
1120
"phpstan/phpstan-deprecation-rules": "^1.1",
1221
"phpstan/phpstan-phpunit": "^1.3",

generate

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use AsyncAws\CodeGenerator\File\Location\StandalonePackageResolver;
5+
use AsyncAws\CodeGenerator\Runner;
6+
7+
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
8+
echo "Run `composer install` before you run the `generate` script.\n";
9+
exit(1);
10+
}
11+
12+
require __DIR__ . '/vendor/autoload.php';
13+
14+
Runner::create(__DIR__ . '/manifest.json', new StandalonePackageResolver(__DIR__, 'Incenteev\AsyncAmazonIncentives'), __DIR__ . '/.cache/generate')->run();

manifest.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"endpoints": "manifest/endpoints.json",
3+
"services": {
4+
"AmazonIncentives": {
5+
"source": "manifest/api-2.json",
6+
"documentation": "manifest/docs-2.json",
7+
"pagination": "manifest/paginators-1.json",
8+
"api-reference": "https://developer.amazon.com/docs/incentives-api/incentives-api.html",
9+
"namespace": "Incenteev\\AsyncAmazonIncentives",
10+
"error-factory": "Incenteev\\AsyncAmazonIncentives\\AmazonIncentivesErrorFactory",
11+
"methods": [
12+
"CancelGiftCard",
13+
"CreateGiftCard",
14+
"GetAvailableFunds"
15+
]
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)