Skip to content

Commit

Permalink
TASK: Granularly fix php code according to psr12
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 6, 2024
1 parent be25608 commit 7cf1df0
Show file tree
Hide file tree
Showing 38 changed files with 99 additions and 107 deletions.
1 change: 1 addition & 0 deletions .composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@lint:phpcs-psr12 --exclude=Generic.Files.LineLength,PSR1.Files.SideEffects"
],
"lint:phpstan": "../../bin/phpstan analyse",
"lint:phpstan-generate-baseline": "../../bin/phpstan analyse --generate-baseline",
"lint:distributionintegrity": "[ -d 'Neos.ContentRepository' ] && { echo 'Package Neos.ContentRepository should not exist.' 1>&2; exit 1; } || exit 0;",
"lint": [
"@lint:phpcs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
throw new \InvalidArgumentException(
sprintf(
'Weight component %s was not of type ContentDimensionValueSpecializationDepth',
$specializationDepth
get_debug_type($specializationDepth)
),
1531477454
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ public static function enrichWithCommand(
get_class($event)
));
}
} else {
if (!$event instanceof PublishableToOtherContentStreamsInterface) {
throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
));
}
} elseif (!$event instanceof PublishableToOtherContentStreamsInterface) {
throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
));
}

if ($i === 0) {
Expand All @@ -75,11 +73,9 @@ public static function enrichWithCommand(
$event = DecoratedEvent::create($event, eventId: EventId::create(), metadata: $metadata);
// we remember the 1st event's identifier as causation identifier for all the others
$causationId = $event->eventId;
} else {
} elseif ($causationId !== null) {
// event 2,3,4,...n get a causation identifier set, as they all originate from the 1st event.
if ($causationId !== null) {
$event = DecoratedEvent::create($event, causationId: $causationId);
}
$event = DecoratedEvent::create($event, causationId: $causationId);
}
$processedEvents[] = $event;
$i++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Feature\NodeVariation\Exception\RootNodeCannotBeVaried;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet;
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected function earlyOptimizationOfFilters(FlowQuery $flowQuery, array $parse
$outputNodeAggregateIds = [];
foreach ($parsedFilter['Filters'] as $filter) {
$instanceOfFilters = [];
// @todo array is never queried
$attributeFilters = [];
if (isset($filter['AttributeFilters'])) {
foreach ($filter['AttributeFilters'] as $attributeFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

final class ContentGraphIntegrityCommandController extends CommandController
{
const OUTPUT_MODE_CONSOLE = 'console';
const OUTPUT_MODE_LOG = 'log';
private const OUTPUT_MODE_CONSOLE = 'console';
private const OUTPUT_MODE_LOG = 'log';

private ProjectionIntegrityViolationDetectionRunner $detectionRunner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private function buildPropertySerializer(ContentRepositoryId $contentRepositoryI

$normalizers = [];
foreach ($propertyConvertersConfiguration as $propertyConverterConfiguration) {
$normalizer = new $propertyConverterConfiguration['className'];
$normalizer = new $propertyConverterConfiguration['className']();
if (!$normalizer instanceof NormalizerInterface && !$normalizer instanceof DenormalizerInterface) {
throw InvalidConfigurationException::fromMessage('Serializers can only be created of %s and %s, %s given', NormalizerInterface::class, DenormalizerInterface::class, get_debug_type($normalizer));
}
Expand Down
23 changes: 12 additions & 11 deletions Neos.Fusion/Classes/Core/Cache/ContentCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,31 @@
* Note: If you choose a different cache backend for this content cache, make sure that it is one implementing
* TaggableBackendInterface.
*
* @internal
* @Flow\Scope("singleton")
*/
class ContentCache
{
const CACHE_SEGMENT_START_TOKEN = "\x02";
const CACHE_SEGMENT_END_TOKEN = "\x03";
const CACHE_SEGMENT_SEPARATOR_TOKEN = "\x1f";
public const CACHE_SEGMENT_START_TOKEN = "\x02";
public const CACHE_SEGMENT_END_TOKEN = "\x03";
public const CACHE_SEGMENT_SEPARATOR_TOKEN = "\x1f";

const CACHE_SEGMENT_MARKER = 'CONTENT_CACHE';
public const CACHE_SEGMENT_MARKER = 'CONTENT_CACHE';

const CACHE_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P<identifier>[a-f0-9]+)\x03CONTENT_CACHE/";
const EVAL_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P<command>[^\x02\x1f\x03]+)\x1fCONTENT_CACHE(?P<data>[^\x02\x1f\x03]+)\x03CONTENT_CACHE/";
public const CACHE_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P<identifier>[a-f0-9]+)\x03CONTENT_CACHE/";
public const EVAL_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P<command>[^\x02\x1f\x03]+)\x1fCONTENT_CACHE(?P<data>[^\x02\x1f\x03]+)\x03CONTENT_CACHE/";

const MAXIMUM_NESTING_LEVEL = 32;
public const MAXIMUM_NESTING_LEVEL = 32;

/**
* A cache entry tag that will be used by default to flush an entry on "every" change - whatever that means to
* the application.
*/
const TAG_EVERYTHING = 'Everything';
public const TAG_EVERYTHING = 'Everything';

const SEGMENT_TYPE_CACHED = 'cached';
const SEGMENT_TYPE_UNCACHED = 'uncached';
const SEGMENT_TYPE_DYNAMICCACHED = 'dynamiccached';
public const SEGMENT_TYPE_CACHED = 'cached';
public const SEGMENT_TYPE_UNCACHED = 'uncached';
public const SEGMENT_TYPE_DYNAMICCACHED = 'dynamiccached';

/**
* @var StringFrontend
Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Classes/Core/FusionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function __construct(
*/
public static function fromArray(array $fusionConfiguration): self
{
return new static($fusionConfiguration);
return new self($fusionConfiguration);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Neos.Fusion/Classes/Core/FusionSourceCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ protected function __construct(

public static function fromString(string $string): self
{
return new static(null, $string);
return new self(null, $string);
}

public static function fromFilePath(string $filePath): self
{
if (is_readable($filePath) === false) {
throw new Fusion\Exception("Trying to read Fusion source code from file, but '$filePath' is not readable.", 1657963790);
}
return new static($filePath, fn () => file_get_contents($filePath));
return new self($filePath, fn () => file_get_contents($filePath));
}

/**
* Watch out for unexpected behaviour {@link https://github.com/neos/neos-development-collection/issues/3835}
*/
public static function fromDangerousPotentiallyDifferingSourceCodeAndFilePath(string $sourceCode, string $filePath): self
{
return new static($filePath, $sourceCode);
return new self($filePath, $sourceCode);
}

public function getSourceCode(): string
Expand Down
21 changes: 13 additions & 8 deletions Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* source code.
*/

use Neos\Flow\Annotations as Flow;

/**
* @implements \IteratorAggregate<int, FusionSourceCode>
* @api
Expand All @@ -22,44 +24,47 @@ final class FusionSourceCodeCollection implements \IteratorAggregate, \Countable
/** @var array<int, FusionSourceCode> */
private array $fusionCodeCollection;

/** @param $fusionSourceCode array<int, FusionSourceCode> */
/**
* @Flow\Autowiring(false)
* @param $fusionSourceCode array<int, FusionSourceCode>
*/
public function __construct(FusionSourceCode ...$fusionSourceCode)
{
$this->fusionCodeCollection = self::deduplicateItemsAndKeepLast($fusionSourceCode);
}

public static function fromFilePath(string $filePath): self
{
return new static(FusionSourceCode::fromFilePath($filePath));
return new self(FusionSourceCode::fromFilePath($filePath));
}

public static function fromString(string $string): self
{
return new static(FusionSourceCode::fromString($string));
return new self(FusionSourceCode::fromString($string));
}

public static function tryFromFilePath(string $filePath): self
{
if (!is_readable($filePath)) {
return static::empty();
return self::empty();
}
return static::fromFilePath($filePath);
return self::fromFilePath($filePath);
}

public static function tryFromPackageRootFusion(string $packageKey): self
{
$fusionPathAndFilename = sprintf('resource://%s/Private/Fusion/Root.fusion', $packageKey);
return static::tryFromFilePath($fusionPathAndFilename);
return self::tryFromFilePath($fusionPathAndFilename);
}

public static function empty(): self
{
return new static();
return new self();
}

public function union(FusionSourceCodeCollection $other): self
{
return new static(...$this->fusionCodeCollection, ...$other->fusionCodeCollection);
return new self(...$this->fusionCodeCollection, ...$other->fusionCodeCollection);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Neos.Fusion/Classes/Core/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ class Runtime
/**
* Internal constants defining how evaluate should work in case of an error
*/
const BEHAVIOR_EXCEPTION = 'Exception';
public const BEHAVIOR_EXCEPTION = 'Exception';

const BEHAVIOR_RETURNNULL = 'NULL';
public const BEHAVIOR_RETURNNULL = 'NULL';

/**
* Internal constants defining a status of how evaluate was evaluated
*/
const EVALUATION_EXECUTED = 'Executed';
public const EVALUATION_EXECUTED = 'Executed';

const EVALUATION_SKIPPED = 'Skipped';
public const EVALUATION_SKIPPED = 'Skipped';

/**
* @var \Neos\Eel\CompilingEvaluator
Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Classes/FusionObjects/CaseImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CaseImplementation extends AbstractArrayFusionObject
*
* You should not rely on the contents or type of this constant.
*/
const MATCH_NORESULT = '_____________NO_MATCH_RESULT_____________';
public const MATCH_NORESULT = '_____________NO_MATCH_RESULT_____________';

/**
* Execute each matcher until the first one matches
Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Classes/FusionObjects/TagImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getOmitClosingTag()
*/
public function isSelfClosingTag($tagName)
{
return in_array($tagName, self::$SELF_CLOSING_TAGS, true) || (boolean)$this->fusionValue('selfClosingTag');
return in_array($tagName, self::$SELF_CLOSING_TAGS, true) || $this->fusionValue('selfClosingTag');
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public function __construct(string $assetSourceIdentifier, array $assetSourceOpt
/**
* @param string $assetSourceIdentifier
* @param array $assetSourceOptions
* @return AssetSourceInterface
* @return self
*/
public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface
public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): self
{
return new static($assetSourceIdentifier, $assetSourceOptions);
return new self($assetSourceIdentifier, $assetSourceOptions);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ interface SupportsSortingInterface
/**
* Constants representing the direction when ordering result sets.
*/
const ORDER_ASCENDING = 'ASC';
const ORDER_DESCENDING = 'DESC';
public const ORDER_ASCENDING = 'ASC';
public const ORDER_DESCENDING = 'DESC';

/**
* Note: This method is preliminary, not to be used for third-party asset sources yet.
Expand Down
10 changes: 5 additions & 5 deletions Neos.Media/Classes/Domain/Model/ImageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
*/
interface ImageInterface extends ResourceBasedInterface
{
const ORIENTATION_SQUARE = 'square';
const ORIENTATION_LANDSCAPE = 'landscape';
const ORIENTATION_PORTRAIT = 'portrait';
public const ORIENTATION_SQUARE = 'square';
public const ORIENTATION_LANDSCAPE = 'landscape';
public const ORIENTATION_PORTRAIT = 'portrait';

/**
* Inset ratio mode: If an image is attempted to get scaled with the size of both edges stated, using this mode will scale it to the lower of both edges.
* Consider an image of 320/480 being scaled to 50/50: because aspect ratio wouldn't get hurt, the target image size will become 33/50.
*/
const RATIOMODE_INSET = 'inset';
public const RATIOMODE_INSET = 'inset';

/**
* Outbound ratio mode: If an image is attempted to get scaled with the size of both edges stated, using this mode will scale the image and crop it.
* Consider an image of 320/480 being scaled to 50/50: the image will be scaled to height 50, then centered and cropped so the width will also be 50.
*/
const RATIOMODE_OUTBOUND = 'outbound';
public const RATIOMODE_OUTBOUND = 'outbound';

/**
* Width of the image in pixels
Expand Down
2 changes: 1 addition & 1 deletion Neos.Media/Classes/Domain/Service/ImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,6 @@ protected function applyAdjustments(ImageInterface $image, array $adjustments, &
protected function isAnimatedGif($image)
{
$count = preg_match_all('#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $image, $matches);
return $count ? true : false;
return (bool)$count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public function __construct(string $identifier, string $type)
/**
* @param string $identifier
* @param array $configuration
* @return Adjustment
* @return self
*/
public static function fromConfiguration(string $identifier, array $configuration): Adjustment
public static function fromConfiguration(string $identifier, array $configuration): self
{
if (!isset($configuration['type'])) {
throw new \InvalidArgumentException(sprintf('Missing type in configuration for adjustment "%s".', $identifier), 1549276551);
}

$adjustment = new static(
$adjustment = new self(
$identifier,
$configuration['type']
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function fromString(string $ratio): self
throw new \InvalidArgumentException(sprintf('Invalid aspect ratio specified ("%s").', $ratio), 1552641724);
}
[$width, $height] = explode(':', $ratio);
return new static((int)$width, (int)$height);
return new self((int)$width, (int)$height);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* source code.
*/

use Neos\Flow\Annotations as Flow;

final class Variant
{
/**
Expand All @@ -39,6 +41,7 @@ final class Variant
* @param string $identifier
* @param Label $label
* @param string $description
* @Flow\Autowiring(false)
*/
public function __construct(string $identifier, Label $label, string $description = null)
{
Expand All @@ -52,9 +55,9 @@ public function __construct(string $identifier, Label $label, string $descriptio
* @param array $configuration
* @return Variant
*/
public static function fromConfiguration(string $identifier, array $configuration): Variant
public static function fromConfiguration(string $identifier, array $configuration): self
{
$variant = new static(
$variant = new self(
$identifier,
new Label($configuration['label']),
$configuration['description'] ?? null
Expand Down
Loading

0 comments on commit 7cf1df0

Please sign in to comment.