Skip to content

Commit

Permalink
TASK: Remove unused imports in newer neos9 code
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Nov 13, 2023
1 parent 983db91 commit 80f5262
Show file tree
Hide file tree
Showing 43 changed files with 103 additions and 164 deletions.
1 change: 1 addition & 0 deletions .composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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 @@ -43,13 +43,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 @@ -74,11 +72,9 @@ public static function enrichWithCommand(
$event = DecoratedEvent::withMetadata($event, $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::withCausationId($event, $causationId);
}
$event = DecoratedEvent::withCausationId($event, $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 @@ -115,6 +115,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
52 changes: 0 additions & 52 deletions Neos.Diff/Classes/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,58 +636,6 @@ private function ratioReduce($sum, array $triple)
return $sum + ($triple[count($triple) - 1]);
}

/**
* Quickly return an upper bound ratio for the similarity of the strings.
* This is quicker to compute than Ratio().
*
* @return float The calculated ratio.
* @todo throw away or make public
*/
private function quickRatio()
{
if ($this->fullBCount === null) {
$this->fullBCount = [];
$bLength = count($this->b);
for ($i = 0; $i < $bLength; ++$i) {
$char = $this->b[$i];
$this->fullBCount[$char] = $this->arrayGetDefault($this->fullBCount, $char, 0) + 1;
}
}

$avail = [];
$matches = 0;
$aLength = count($this->a);
for ($i = 0; $i < $aLength; ++$i) {
$char = $this->a[$i];
if (isset($avail[$char])) {
$numb = $avail[$char];
} else {
$numb = $this->arrayGetDefault($this->fullBCount, $char, 0);
}
$avail[$char] = $numb - 1;
if ($numb > 0) {
++$matches;
}
}

$this->calculateRatio($matches, count($this->a) + count($this->b));
}

/**
* Return an upper bound ratio really quickly for the similarity of the strings.
* This is quicker to compute than Ratio() and quickRatio().
*
* @return float The calculated ratio.
* @todo throw away or make public
*/
private function realquickRatio()
{
$aLength = count($this->a);
$bLength = count($this->b);

return $this->calculateRatio(min($aLength, $bLength), $aLength + $bLength);
}

/**
* Helper function for calculating the ratio to measure similarity for the strings.
* The ratio is defined as being 2 * (number of matches / total length)
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public function handleRenderingException($fusionPath, \Exception $exception)
*/
protected function handle($fusionPath, \Exception $exception, $referenceCode)
{
throw new \BadMethodCallException('I will never be invoked, as handleRenderingException is overriden.');
}
}
2 changes: 1 addition & 1 deletion Neos.Fusion/Classes/Core/FusionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function __construct(
/** @internal */
public static function fromArray(array $fusionConfiguration)
{
return new static($fusionConfiguration);
return new self($fusionConfiguration);
}

/** @internal */
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
20 changes: 12 additions & 8 deletions Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,54 @@
* source code.
*/

use Neos\Flow\Annotations as Flow;

/** @api */
final class FusionSourceCodeCollection implements \IteratorAggregate, \Countable
{
/** @var array<int, FusionSourceCode> */
private array $fusionCodeCollection;

/** @param $fusionSourceCode array<int, FusionSourceCode> */
/**
* @Flow\Autowiring(false)
*/
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()
{
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
4 changes: 2 additions & 2 deletions Neos.Fusion/Classes/FusionObjects/Helpers/LazyProps.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public function offsetGet($path): mixed

public function offsetSet($path, $value): void
{
throw new BadMethodCallException('Lazy props can not be set.', 1588182804);
throw new \BadMethodCallException('Lazy props can not be set.', 1588182804);
}

public function offsetUnset($path): void
{
throw new BadMethodCallException('Lazy props can not be unset.', 1588182805);
throw new \BadMethodCallException('Lazy props can not be unset.', 1588182805);
}

public function current(): mixed
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
2 changes: 1 addition & 1 deletion Neos.Media.Browser/Classes/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* source code.
*/

use Doctrine\Common\Persistence\Proxy as DoctrineProxy;
use Doctrine\Persistence\Proxy as DoctrineProxy;
use Doctrine\ORM\EntityNotFoundException;
use Neos\Error\Messages\Error;
use Neos\Error\Messages\Message;
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
Loading

0 comments on commit 80f5262

Please sign in to comment.