Skip to content

Commit 8872455

Browse files
algolia-botmillotp
andcommitted
feat(spec): eslint with custom rules APIC-387
algolia/api-clients-automation#304 Co-authored-by: Pierre Millot <[email protected]>
1 parent 70bed99 commit 8872455

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+11312
-0
lines changed

algoliasearch-client-php/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
2+
3+
composer.phar
4+
/vendor/
5+
6+
# php-cs-fixer cache
7+
.php_cs.cache
8+
9+
# PHPUnit cache
10+
.phpunit.result.cache
11+
12+
.openapi-generator/
13+
composer.lock
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
docs/**
8+
test/**
9+
lib/Model/**
10+
lib/Model/
11+
12+
.travis.yml
13+
README.md
14+
git_push.sh
15+
.php_cs
16+
17+
lib/HeaderSelector.php
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
$config = new PhpCsFixer\Config();
4+
5+
return $config
6+
->setUsingCache(true)
7+
->setRules([
8+
'array_syntax' => [ 'syntax' => 'short' ],
9+
'blank_line_after_namespace' => false,
10+
'blank_line_after_opening_tag' => true,
11+
'blank_line_before_statement' => true,
12+
'braces' => false,
13+
'cast_spaces' => true,
14+
'combine_consecutive_unsets' => true,
15+
'echo_tag_syntax' => true,
16+
'general_phpdoc_tag_rename' => true,
17+
'mb_str_functions' => true,
18+
'no_blank_lines_after_class_opening' => true,
19+
'no_empty_phpdoc' => true,
20+
'no_empty_statement' => true,
21+
'no_extra_blank_lines' => true,
22+
'no_multiline_whitespace_around_double_arrow' => true,
23+
'no_short_bool_cast' => true,
24+
'no_trailing_whitespace' => true,
25+
'no_trailing_whitespace_in_comment' => true,
26+
'no_unneeded_control_parentheses' => true,
27+
'no_unreachable_default_argument_value' => true,
28+
'no_unused_imports' => true,
29+
'no_useless_else' => true,
30+
'no_useless_return' => true,
31+
'no_whitespace_before_comma_in_array' => true,
32+
'no_whitespace_in_blank_line' => true,
33+
'normalize_index_brace' => true,
34+
'not_operator_with_space' => false,
35+
'object_operator_without_whitespace' => true,
36+
'ordered_imports' => true,
37+
'phpdoc_annotation_without_dot' => true,
38+
'phpdoc_inline_tag_normalizer' => true,
39+
'phpdoc_order' => true,
40+
'phpdoc_scalar' => true,
41+
'phpdoc_separation' => true,
42+
'phpdoc_single_line_var_spacing' => true,
43+
'phpdoc_tag_type' => true,
44+
'protected_to_private' => true,
45+
'@PSR2' => true,
46+
'short_scalar_cast' => true,
47+
'single_blank_line_at_eof' => false,
48+
'single_blank_line_before_namespace' => true,
49+
'single_quote' => true,
50+
'space_after_semicolon' => true,
51+
'standardize_not_equals' => true,
52+
'strict_comparison' => true,
53+
'strict_param' => true,
54+
'ternary_operator_spaces' => true,
55+
'trailing_comma_in_multiline' => true,
56+
'trim_array_spaces' => true,
57+
])
58+
->setFinder(
59+
PhpCsFixer\Finder::create()
60+
->exclude('test')
61+
->exclude('tests')
62+
->in(__DIR__)
63+
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "algolia/algoliasearch-client-php",
3+
"description": "API powering the features of Algolia.",
4+
"keywords": [
5+
"openapitools",
6+
"openapi-generator",
7+
"openapi",
8+
"php",
9+
"sdk",
10+
"rest",
11+
"api"
12+
],
13+
"homepage": "https://openapi-generator.tech",
14+
"license": "unlicense",
15+
"authors": [
16+
{
17+
"name": "OpenAPI-Generator contributors",
18+
"homepage": "https://openapi-generator.tech"
19+
}
20+
],
21+
"require": {
22+
"php": "^7.3 || ^8.0",
23+
"ext-curl": "*",
24+
"ext-json": "*",
25+
"ext-mbstring": "*",
26+
"guzzlehttp/guzzle": "^7.3",
27+
"guzzlehttp/psr7": "^2.0",
28+
"psr/http-message": "^1.0",
29+
"psr/log": "^1.0 || ^2.0 || ^3.0",
30+
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
31+
},
32+
"require-dev": {
33+
"friendsofphp/php-cs-fixer": "^3.5.0",
34+
"phpunit/phpunit": "^9.3"
35+
},
36+
"autoload": {
37+
"psr-4": { "Algolia\\AlgoliaSearch\\" : "lib/" },
38+
"files": [
39+
"lib/Http/Psr7/functions.php"
40+
]
41+
},
42+
"autoload-dev": {
43+
"psr-4": { "Algolia\\AlgoliaSearch\\Test\\" : "test/" }
44+
}
45+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch;
4+
5+
use Algolia\AlgoliaSearch\Cache\NullCacheDriver;
6+
use Algolia\AlgoliaSearch\Http\HttpClientInterface;
7+
use Algolia\AlgoliaSearch\Log\DebugLogger;
8+
use Psr\Log\LoggerInterface;
9+
use Psr\SimpleCache\CacheInterface;
10+
11+
final class Algolia
12+
{
13+
const VERSION = '4.0.0';
14+
15+
/**
16+
* Holds an instance of the simple cache repository (PSR-16).
17+
*
18+
* @var \Psr\SimpleCache\CacheInterface|null
19+
*/
20+
private static $cache;
21+
22+
/**
23+
* Holds an instance of the logger (PSR-3).
24+
*
25+
* @var \Psr\Log\LoggerInterface|null
26+
*/
27+
private static $logger;
28+
29+
/**
30+
* @var \Algolia\AlgoliaSearch\Http\HttpClientInterface
31+
*/
32+
private static $httpClient;
33+
34+
public static function isCacheEnabled()
35+
{
36+
if (null === self::$cache) {
37+
return false;
38+
}
39+
40+
return !self::getCache() instanceof NullCacheDriver;
41+
}
42+
43+
/**
44+
* Gets the cache instance.
45+
*
46+
* @return \Psr\SimpleCache\CacheInterface
47+
*/
48+
public static function getCache()
49+
{
50+
if (null === self::$cache) {
51+
self::setCache(new NullCacheDriver());
52+
}
53+
54+
return self::$cache;
55+
}
56+
57+
/**
58+
* Sets the cache instance.
59+
*/
60+
public static function setCache(CacheInterface $cache)
61+
{
62+
self::$cache = $cache;
63+
}
64+
65+
/**
66+
* Gets the logger instance.
67+
*
68+
* @return \Psr\Log\LoggerInterface
69+
*/
70+
public static function getLogger()
71+
{
72+
if (null === self::$logger) {
73+
self::setLogger(new DebugLogger());
74+
}
75+
76+
return self::$logger;
77+
}
78+
79+
/**
80+
* Sets the logger instance.
81+
*/
82+
public static function setLogger(LoggerInterface $logger)
83+
{
84+
self::$logger = $logger;
85+
}
86+
87+
public static function getHttpClient()
88+
{
89+
if (null === self::$httpClient) {
90+
self::setHttpClient(new \Algolia\AlgoliaSearch\Http\GuzzleHttpClient());
91+
}
92+
93+
return self::$httpClient;
94+
}
95+
96+
public static function setHttpClient(HttpClientInterface $httpClient)
97+
{
98+
self::$httpClient = $httpClient;
99+
}
100+
101+
public static function resetHttpClient()
102+
{
103+
self::$httpClient = null;
104+
}
105+
}

0 commit comments

Comments
 (0)