Skip to content

Commit

Permalink
Merge pull request #2953 from bolt/bumping-deps
Browse files Browse the repository at this point in the history
Bumping versions of Glide and PHPStan
  • Loading branch information
bobdenotter committed Nov 29, 2021
2 parents dcfd7db + 72409b1 commit 4e7878c
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 61 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jasny/twig-extensions": "^1.3",
"knplabs/doctrine-behaviors": "^2.1",
"knplabs/knp-menu-bundle": "^3.1",
"league/glide-symfony": "^1.0",
"league/glide-symfony": "^1.0.4",
"miljar/php-exif": "^0.6.4",
"nelexa/zip": "^3.3 || ^4.0",
"nelmio/cors-bundle": "^2.1",
Expand Down Expand Up @@ -103,9 +103,9 @@
"php-translation/loco-adapter": "^0.11",
"phpspec/phpspec": "^6.3.1",
"phpspec/prophecy": "^1.14",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-doctrine": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-symfony": "^1.0.1",
"phpunit/phpunit": "^8.5",
"se/selenium-server-standalone": "^3.141",
"symfony/browser-kit": "^5.3",
Expand Down
8 changes: 4 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ parameters:

# false positive: An item to the Logger's Record added by us isn't recognized
-
message: "#Offset 'location' does not exist on array#"
message: "#Offset '.*' ([a-z ]*)on array#"
path: %currentWorkingDirectory%/src/Log/LogHandler.php

# false positive: UserPasswordHasherInterface::isPasswordValid() given UserInterface
# False positive: `id` on Entities
-
message: '#UserPasswordHasherInterface::isPasswordValid\(\)#'
path: %currentWorkingDirectory%/src/Security/LoginFormAuthenticator.php
message: '#Property Bolt\\Entity\\(.*)::\$id is never written, only read#'
path: %currentWorkingDirectory%/src/Entity/*

includes:
- vendor/phpstan/phpstan-symfony/extension.neon
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Extensions/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function filterUnpublishedViewlessContent(QueryBuilder $queryBuilder): v
$queryBuilder->setParameter('status', Statuses::PUBLISHED);

//todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed.
if (! empty($this->viewlessContentTypes)) {
if ($this->viewlessContentTypes->isNotEmpty()) {
$queryBuilder->andWhere(sprintf('%s.contentType NOT IN (:cts)', $rootAlias));
$queryBuilder->setParameter('cts', $this->viewlessContentTypes);
}
Expand All @@ -82,7 +82,7 @@ private function filterUnpublishedViewlessFields(QueryBuilder $queryBuilder): vo
$queryBuilder->setParameter('status', Statuses::PUBLISHED);

//todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed.
if (! empty($this->viewlessContentTypes)) {
if ($this->viewlessContentTypes->isNotEmpty()) {
$queryBuilder->andWhere('c.contentType NOT IN (:cts)');
$queryBuilder->setParameter('cts', $this->viewlessContentTypes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/CachingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setCacheKey(array $tokens): void

public function getCacheKey(): string
{
return $this->cacheKey ?? '';
return $this->cacheKey;
}

public function setCacheTags(array $tags): void
Expand Down
7 changes: 2 additions & 5 deletions src/Command/CopyAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$this->filesystem->remove($targetDir);
$this->hardCopy($originDir, $targetDir);

$rows[] = [sprintf('<fg=green;options=bold>%s</>', "\xE2\x9C\x94"), $message, 'copied'];
} catch (\Throwable $e) {
$exitCode = 1;
$rows[] = [sprintf('<fg=red;options=bold>%s</>', "\xE2\x9C\x98"), $message, $e->getMessage()];
}
}

if (! empty($rows)) {
$io->table(['', 'Folder', 'Method / Error'], $rows);
}
$io->table(['', 'Folder', 'Method / Error'], $rows);

if ($exitCode !== 0) {
$io->error('Some errors occurred while installing assets.');
} else {
$io->success(! empty($rows) ? 'All assets were successfully installed.' : 'No assets were provided by any bundle.');
$io->success('All assets were successfully installed.');
}

return $exitCode;
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Content/FieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct($items, ?string $slug = null)
);
}

private static function defaults(): Collection
protected static function defaults(): Collection
{
return new Collection([
'slug' => '',
Expand Down
2 changes: 1 addition & 1 deletion src/DataFixtures/ContentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function ($match) {

try {
return $this->faker->{$match};
} catch (\Throwable $e) {
} finally {
}

return '(unknown)';
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/TablePrefixTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ protected function setTablePrefixes($tablePrefixes, ManagerRegistry $managerRegi
*/
protected function getTablePrefix(): string
{
return current($this->tablePrefixes) ?? '';
return current($this->tablePrefixes);
}
}
3 changes: 1 addition & 2 deletions src/Entity/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ public function getSlug($locale = null): ?string
return (string) $this->getId();
}

$slug = null;
if ($locale === null) {
// get slug with locale the slug already has
$slug = $this->getFieldValue('slug');
Expand All @@ -263,7 +262,7 @@ public function getSlug($locale = null): ?string
}

// if no slug exists for the current/requested locale, default fallback
if (! $slug && $this->hasField('slug')) {
if ($slug === '') {
$field = $this->getField('slug');

// @todo: Refactor this. Field.php should be able to get locale
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Field/CollectionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getApiValue()
}

/**
* @var FieldInterface[]
* @param FieldInterface[] $fields
*/
public function setValue($fields): Field
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function setToContent($content): void

public function getDefinition(): array
{
if (empty($this->definition) === true && empty($this->fromContent) === false) {
if (empty($this->definition) && $this->fromContent instanceof Content) {
$this->setDefinitionFromContentDefinition();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Event/Listener/ContentFillListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function guesstimateAuthor(): User
return $this->users->getFirstAdminUser();
}

private function guaranteeUniqueSLug(Content $content): void
private function guaranteeUniqueSlug(Content $content): void
{
$slug = $content->getSlug();

Expand Down Expand Up @@ -137,7 +137,7 @@ private function guaranteeUniqueSLug(Content $content): void
if (! $safe) {
$newSlug = $this->getSafeSlug($slug);
$content->setFieldValue('slug', $newSlug);
$this->guaranteeUniqueSLug($content);
$this->guaranteeUniqueSlug($content);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Log/RequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function processRecord(array $record): array
];
}

if (! empty($user)) {
if ($user instanceof User) {
$record['user'] = [
'id' => $user->getId(),
'username' => $user->getUsername(),
Expand Down
6 changes: 3 additions & 3 deletions src/Security/LoginFormAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public function getUser($credentials, UserProviderInterface $userProvider): ?Use
return $this->userRepository->findOneByCredentials($credentials['username']);
}

/**
* @var PasswordAuthenticatedUserInterface $user
*/
public function checkCredentials($credentials, UserInterface $user): bool
{
/**
* @var PasswordAuthenticatedUserInterface $user
*/
return empty($credentials['password']) ? false : $this->passwordHasher->isPasswordValid($user, $credentials['password']);
}

Expand Down
6 changes: 1 addition & 5 deletions src/Security/LogoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ class LogoutListener implements LogoutHandlerInterface
{
use LoggerTrait;

/** @var EntityManagerInterface */
private $em;

/** @var SessionInterface */
private $session;

public function __construct(EntityManagerInterface $em, SessionInterface $session)
public function __construct(SessionInterface $session)
{
$this->em = $em;
$this->session = $session;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/FieldExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getLabel(Field $field): string

public function getType(Field $field): string
{
return $field->getType() ?? $field->getDefinition()->get('type');
return $field->getType();
}

/**
Expand All @@ -119,7 +119,7 @@ public function getSelected(Field\SelectField $field, $returnsingle = false, $re
{
$definition = $field->getDefinition();

if ($definition->get('type') !== 'select' || ! $field->isContentSelect() || ($field->isContentSelect() && $definition->get('mode') === 'format')) {
if ($definition->get('type') !== 'select' || ! $field->isContentSelect() || $definition->get('mode') === 'format') {
return $this->notifications->warning(
'Incorrect usage of `selected`-filter',
'The `selected`-filter can only be applied to a field of `type: select`, and it must be used as a selector for other content, and without `mode: format`.'
Expand Down
12 changes: 0 additions & 12 deletions src/Twig/RelatedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Bolt\Entity\Content;
use Bolt\Entity\Relation;
use Bolt\Repository\RelationRepository;
use Bolt\Storage\Query;
use Bolt\Utils\ContentHelper;
use Bolt\Utils\RelatedOptionsUtility;
use Tightenco\Collect\Support\Collection;
use Twig\Extension\AbstractExtension;
Expand All @@ -24,12 +22,6 @@ class RelatedExtension extends AbstractExtension
/** @var Config */
private $config;

/** @var Query */
private $query;

/** @var ContentHelper */
private $contentHelper;

/** @var Notifications */
private $notifications;

Expand All @@ -39,15 +31,11 @@ class RelatedExtension extends AbstractExtension
public function __construct(
RelationRepository $relationRepository,
Config $config,
Query $query,
ContentHelper $contentHelper,
Notifications $notifications,
RelatedOptionsUtility $optionsUtility)
{
$this->relationRepository = $relationRepository;
$this->config = $config;
$this->query = $query;
$this->contentHelper = $contentHelper;
$this->notifications = $notifications;
$this->optionsUtility = $optionsUtility;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Twig/TextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ public function urlDecode(string $string)
foreach (explode('&', $string) as $chunk) {
$param = explode('=', $chunk);

if (! empty($param)) {
$params[urldecode($param[0])] = urldecode($param[1]);
}
$params[urldecode($param[0])] = urldecode($param[1]);
}

return $params;
Expand Down
6 changes: 3 additions & 3 deletions src/Utils/Excerpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function getExcerpt(string $text, int $length = 200, $focus = null
* Nothing exciting here. The array_unique is required, unless you decide
* to make the words unique before passing in.
*/
private static function extractLocations(array $words, string $fulltext): array
protected static function extractLocations(array $words, string $fulltext): array
{
$locations = [];
foreach ($words as $word) {
Expand All @@ -49,7 +49,7 @@ private static function extractLocations(array $words, string $fulltext): array
* The only exception is where we have only two matches in which case we just take the
* first as will be equally distant.
*/
private static function determineSnipLocation(array $locations, int $prevCount): int
protected static function determineSnipLocation(array $locations, int $prevCount): int
{
// If we only have 1 match we don't actually do the for loop so set to the first
$startPos = (int) reset($locations);
Expand Down Expand Up @@ -84,7 +84,7 @@ private static function determineSnipLocation(array $locations, int $prevCount):
*
* @param string|array $words
*/
private static function extractRelevant($words, string $fulltext, int $relLength = 300): string
protected static function extractRelevant($words, string $fulltext, int $relLength = 300): string
{
$fulltext = strip_tags($fulltext);

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/LocaleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getCurrentLocale(Environment $twig): ?Collection
{
// Getting the currentLocale is surprisingly inefficient, so we do it once per Request
// See https://github.com/bolt/core/pull/2597
if (! isset($this->currentLocale)) {
if (! $this->currentLocale instanceof Collection) {
$this->currentLocale = $this->getLocales($twig)->firstWhere('current', true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/MomentFormatConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MomentFormatConverter
*
* @var array
*/
private static $formatConvertRules = [
protected static $formatConvertRules = [
// year
'yyyy' => 'YYYY',
'yy' => 'YY',
Expand Down
2 changes: 1 addition & 1 deletion src/Widget/BaseWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getTargets(): array
}

/**
* @var string[]
* @param string[] $targets
*/
public function setTargets(array $targets): WidgetInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/Widget/Injector/HtmlInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function inject(WidgetInterface $widget, Response $response): void
$snippet = $widget() . "\n";

// If the widget doesn't produce output, there's no need to inject it.
if (empty($snippet)) {
if (mb_strlen($snippet) === 0) {
return;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ protected function jsTagsAfter(string $snippet, string $rawHtml): string
return $result;
}

private static function findTagStart(string $rawHtml, string $htmlTag): ?string
protected static function findTagStart(string $rawHtml, string $htmlTag): ?string
{
preg_match('~(<' . $htmlTag . '[^>]*?>)~mi', $rawHtml, $matches);

Expand All @@ -251,7 +251,7 @@ private static function findTagStart(string $rawHtml, string $htmlTag): ?string
return $matches[1];
}

private static function findTagEnd(string $rawHtml, string $htmlTag): ?string
protected static function findTagEnd(string $rawHtml, string $htmlTag): ?string
{
preg_match_all('~((<' . $htmlTag . '(\s[^>]*)?>)|(</' . $htmlTag . '>))~mi', $rawHtml, $allMatches);

Expand Down
2 changes: 1 addition & 1 deletion src/Widget/Injector/RequestZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class RequestZone
{
private const KEY = 'zone';
protected const KEY = 'zone';

public const FRONTEND = 'frontend';
public const BACKEND = 'backend';
Expand Down

0 comments on commit 4e7878c

Please sign in to comment.