Skip to content

Commit

Permalink
Symfony update to 4.3 (#127)
Browse files Browse the repository at this point in the history
* phpstan fixes

* update elasticms/common-bundle and symfony

* psr12 compliance

* travis drop 7.1 support
  • Loading branch information
dameert committed Aug 16, 2019
1 parent e097397 commit 12ed397
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 50 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ matrix:
fast_finish: true

include:
- php: '7.1'
env: SNIFF=1
- php: '7.2'
env: SNIFF=1
- php: '7.3'
- php: 'nightly'

Expand All @@ -35,4 +34,4 @@ script:
# Run PHPCS
- if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpcs . --standard=./phpcs.xml.dist --extensions=php,lib,inc; fi
# Run PHPStan
- if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpstan analyse .; fi
- if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpstan analyse .; fi
4 changes: 2 additions & 2 deletions Command/HealthCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ private function checkIndexes(SymfonyStyle $io)
$indexes = [];
foreach ($prefixes as $preValue) {
foreach ($postfixes as $postValue) {
$indexes[] = $preValue.$postValue;
$indexes[] = $preValue . $postValue;
}
}

$index = join(',', $indexes);

foreach ($this->clients as $client) {
if (!$client->indices()->exists(['index' => $index])) {
$io->error('Index '.$index.' not found');
$io->error('Index ' . $index . ' not found');
throw new IndexNotFoundException();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Controller/EmbedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(ClientRequestManager $manager)

public function renderHierarchyAction(string $template, string $parent, string $field, int $depth = null, array $sourceFields = [], array $args = [], ?string $cacheType = null): Response
{
$cacheKey= [
$cacheKey = [
'EMSCH_Hierarchy',
$template,
$parent,
Expand All @@ -42,7 +42,7 @@ public function renderHierarchyAction(string $template, string $parent, string $

public function renderBlockAction(string $searchType, array $body, string $template, array $args = [], int $from = 0, int $size = 10, ?string $cacheType = null, array $sourceExclude = []) : Response
{
$cacheKey= [
$cacheKey = [
'EMSCH_Block',
$searchType,
$body,
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private function addRoutingSelection(ArrayNodeDefinition $rootNode)
->isRequired()
->beforeNormalization()
->always(function ($v) {
return 'emsch.client_request.'.$v;
return 'emsch.client_request.' . $v;
})
->end()
->end()
Expand Down
8 changes: 4 additions & 4 deletions Helper/Api/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public function updateDocument(string $apiName, string $type, string $ouuid, arr
$response = $this->getApiClient($apiName)->updateDocument($type, $ouuid, $body);

if (! $response['success']) {
throw new \Exception(isset($response['error'][0])?$response['error'][0]:'Update document failed');
throw new \Exception(isset($response['error'][0]) ? $response['error'][0] : 'Update document failed');
}

$response = $this->getApiClient($apiName)->finalize($type, $response['revision_id']);

if (! $response['success']) {
throw new \Exception(isset($response['error'][0])?$response['error'][0]:'Finalize draft failed');
throw new \Exception(isset($response['error'][0]) ? $response['error'][0] : 'Finalize draft failed');
}
return $response['ouuid'];
}
Expand All @@ -137,13 +137,13 @@ public function createDocument(string $apiName, string $type, ?string $ouuid, ar
$response = $this->getApiClient($apiName)->initNewDocument($type, $body, $ouuid);

if (! $response['success']) {
throw new \Exception(isset($response['error'][0])?$response['error'][0]:'Create draft failed');
throw new \Exception(isset($response['error'][0]) ? $response['error'][0] : 'Create draft failed');
}

$response = $this->getApiClient($apiName)->finalize($type, $response['revision_id']);

if (! $response['success']) {
throw new \Exception(isset($response['error'][0])?$response['error'][0]:'Finalize draft failed');
throw new \Exception(isset($response['error'][0]) ? $response['error'][0] : 'Finalize draft failed');
}
return $response['ouuid'];
}
Expand Down
2 changes: 1 addition & 1 deletion Helper/Asset/AssetHelperRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function unzip(string $hash, string $saveDir): array

private function extract(string $path, string $destination): bool
{
$zip = new ZipArchive;
$zip = new ZipArchive();

if (false === $open = $zip->open($path)) {
throw new AssetException(sprintf('Failed opening zip %s (ZipArchive %s)', $path, $open));
Expand Down
2 changes: 1 addition & 1 deletion Helper/Asset/ProcessHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function generate(string $processor, string $assetHash, array $options =

return $this->requestRuntime->assetPath([
EmsFields::CONTENT_FILE_HASH_FIELD => $assetHash,
EmsFields::CONTENT_FILE_NAME_FIELD=> 'filename',
EmsFields::CONTENT_FILE_NAME_FIELD => 'filename',
EmsFields::CONTENT_MIME_TYPE_FIELD => 'image/png',
], $options);
}
Expand Down
12 changes: 6 additions & 6 deletions Helper/Elasticsearch/HierarchicalStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

class HierarchicalStructure
{
/**@var \array* */
/** @var array */
private $children;
/**@var \string* */
/** @var string */
private $type;
/**@var \string* */
/** @var string */
private $id;
/**@var \string* */
/** @var array */
private $source;
/** @var mixed */
/** @var mixed */
private $data;
/** @var bool */
/** @var bool*/
private $active = false;

public function __construct(string $type, string $id, array $source, EMSLink $activeChild = null)
Expand Down
4 changes: 2 additions & 2 deletions Helper/Request/LocaleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function redirectMissingLocale(Request $request)
}

if ($session->has('_locale')) {
$url = $request->getUriForPath('/'.$session->get('_locale').$destination);
$url = $request->getUriForPath('/' . $session->get('_locale') . $destination);
} elseif (1 === count($this->locales)) {
$url = $request->getUriForPath('/'.$this->locales[0].$destination);
$url = $request->getUriForPath('/' . $this->locales[0] . $destination);
} else {
$url = $this->router->generate('emsch_language_selection', ['destination' => $destination]);
}
Expand Down
2 changes: 1 addition & 1 deletion Helper/Routing/RedirectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function getRedirectDocument($uri, $locale)
'bool' => [
'must' => [
'term' => [
'url_'.$locale => urldecode($uri)
'url_' . $locale => urldecode($uri)
]
]
]
Expand Down
4 changes: 2 additions & 2 deletions Helper/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function buildRouteCollection(): void
private function addEnvRoutes(RouteCollection $collection): void
{
foreach ($this->routes as $name => $options) {
$route = new Route('ems_'.$name, $options);
$route = new Route('ems_' . $name, $options);
$route->addToCollection($collection, $this->locales);
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ private function createRoutes(ClientRequest $clientRequest, string $type): array

$options['query'] = $source['query'] ?? null;

$staticTemplate = isset($source['template_static']) ? '@EMSCH/'.$source['template_static'] : null;
$staticTemplate = isset($source['template_static']) ? '@EMSCH/' . $source['template_static'] : null;
$options['template'] = $source['template_source'] ?? $staticTemplate;

$routes[] = new Route($name, $options);
Expand Down
4 changes: 2 additions & 2 deletions Helper/Routing/Url/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private function renderTemplate(EMSLink $emsLink, array $document, $locale = nul
$context = [
'id' => $document['_id'],
'source' => $document['_source'],
'locale' => ($locale?$locale:$this->clientRequest->getLocale()),
'locale' => ($locale ? $locale : $this->clientRequest->getLocale()),
'url' => $emsLink,
];

Expand All @@ -134,7 +134,7 @@ private function renderTemplate(EMSLink $emsLink, array $document, $locale = nul
}
}

return $this->twigRender('@EMSCH/routing/'.$document['_type'], $context);
return $this->twigRender('@EMSCH/routing/' . $document['_type'], $context);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Helper/Search/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public function handleAggregation(array $aggregation)

if (isset($aggregation['buckets'])) {
$this->handleBuckets($aggregation['buckets']);
} elseif (isset($aggregation['filtered_'.$this->name]['buckets'])) {
$this->handleBuckets($aggregation['filtered_'.$this->name]['buckets']);
} elseif (isset($aggregation['filtered_' . $this->name]['buckets'])) {
$this->handleBuckets($aggregation['filtered_' . $this->name]['buckets']);
}
}

Expand Down Expand Up @@ -207,11 +207,11 @@ private function getQueryDateRange(array $value): ?array
$start = $end = null;

if (!empty($value['start'])) {
$startDatetime = \DateTime::createFromFormat($format, $value['start'].' 00:00:00');
$startDatetime = \DateTime::createFromFormat($format, $value['start'] . ' 00:00:00');
$start = $startDatetime ? $startDatetime->format('Y-m-d') : $value['start'];
}
if (!empty($value['end'])) {
$endDatetime = \DateTime::createFromFormat($format, $value['end'].' 23:59:59');
$endDatetime = \DateTime::createFromFormat($format, $value['end'] . ' 23:59:59');
$end = $endDatetime ? $endDatetime->format('Y-m-d') : $value['end'];
}

Expand All @@ -238,7 +238,7 @@ private function getQueryOptional(): array

private function setChoices(): void
{
if (null != $this->choices ||$this->type !== self::TYPE_TERMS) {
if (null != $this->choices || $this->type !== self::TYPE_TERMS) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Helper/Search/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private function getAggPostFilter(Filter $filter)

return [
'filter' => $aggFilter,
'aggs' => ['filtered_'.$filter->getName() => $agg]
'aggs' => ['filtered_' . $filter->getName() => $agg]
];
}

Expand Down
4 changes: 2 additions & 2 deletions Helper/Translation/TranslationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ private function createMessages(ClientRequest $clientRequest, string $type): arr

foreach ($scroll as $hit) {
foreach ($this->locales as $locale) {
if (isset($hit['_source']['label_'.$locale])) {
$messages[$locale][$hit['_source']['key']] = $hit['_source']['label_'.$locale];
if (isset($hit['_source']['label_' . $locale])) {
$messages[$locale][$hit['_source']['key']] = $hit['_source']['label_' . $locale];
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
}
],
"require" : {
"php": ">=7.1",
"elasticms/common-bundle": ">=1.6.17",
"php": "^7.2",
"elasticms/common-bundle": "~1.7.0",
"composer/ca-bundle": "^1.1",
"symfony/framework-bundle" : "~3.0|~4.0",
"symfony/framework-bundle" : "^4.3",
"symfony-cmf/routing": "^2.1.0",
"twig/twig" : "~2.4",
"symfony/property-access": "^4.1",
"symfony/options-resolver": "^4.1",
"symfony/translation": "^4.1",
"symfony/config": "^4.1"
"twig/twig" : "~2.10.0",
"symfony/property-access": "^4.3",
"symfony/options-resolver": "^4.3",
"symfony/translation": "^4.3",
"symfony/config": "^4.3"
},
"require-dev" : {
"phpunit/phpunit" : "^5.7",
"mockery/mockery" : "^0.9.9",
"symfony/phpunit-bridge": "^4.1",
"squizlabs/php_codesniffer": "3.*",
"phpstan/phpstan": "^0.11.3"
"mockery/mockery" : "^0.9",
"symfony/phpunit-bridge": "^4.3",
"squizlabs/php_codesniffer": "^3.4",
"phpstan/phpstan": "^0.11"
},
"autoload" : {
"psr-4" : {
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<arg value="np"/>

<!-- Include the whole PS2 standard -->
<rule ref="PSR2" />
<rule ref="PSR12" />

<!-- Private methods MUST not be prefixed with an underscore -->
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
Expand All @@ -29,4 +29,4 @@
<type>error</type>
</rule>

</ruleset>
</ruleset>
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ parameters:
excludes_analyse:
- %currentWorkingDirectory%/vendor/*
- %currentWorkingDirectory%/DependencyInjection/Configuration.php
level: 4
level: 4
inferPrivatePropertyTypeFromConstructor: true

0 comments on commit 12ed397

Please sign in to comment.