Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"ext-zip": "*",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan": "^2.1.0",
"phpunit/phpunit": "^10.5.0 || ^11.4.0 || ^12.1.0",
"spryker-sdk/manifest-test-data-provider": "dev-master",
"spryker/code-sniffer": "^0.17.19",
Expand Down
17 changes: 14 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ parameters:
- src/
bootstrapFiles:
- tests/bootstrap.php
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false

earlyTerminatingMethodCalls:
SprykerSdk\Integrator\Transfer\AbstractTransfer:
Expand All @@ -20,3 +17,17 @@ parameters:
- '#Binary operation "." between non-[a-zA-Z0-9]+-string and PhpParser\\[a-zA-Z0-9\|\\_]+ results in an error.#'
- '#Property PhpParser\\Node\\Stmt\\ClassLike::\$stmts \(array<PhpParser\\Node\\Stmt>\) does not accept array<PhpParser\\Node>#'
- '#Unsafe access to private property SprykerSdk\\Integrator\\Builder\\ClassLoader\\ClassLoader::\$composerClassLoader through static::#'
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
-
identifier: identical.alwaysFalse
-
identifier: identical.alwaysTrue
-
identifier: ternary.alwaysTrue
-
identifier: booleanAnd.rightAlwaysTrue
-
identifier: require.fileNotFound
14 changes: 9 additions & 5 deletions src/Builder/ClassLoader/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function loadClass(string $className): ClassInformationTransfer
$classInformationTransfer->setTokenTree($syntaxTree)
->setOriginalTokenTree($originalSyntaxTree)
->setTokens($this->parser->getTokens())
->setFilePath(realpath($fileName));
->setFilePath(realpath($fileName) ?: null);

$parentClass = $this->getParent($syntaxTree);
if ($parentClass) {
Expand All @@ -65,7 +65,7 @@ public function loadClass(string $className): ClassInformationTransfer
}

/**
* @param array $originalSyntaxTree
* @param array<\PhpParser\Node> $originalSyntaxTree
*
* @return string|null
*/
Expand Down Expand Up @@ -120,13 +120,17 @@ protected function getComposerClassLoader(): ComposerClassLoader
{
if (static::$composerClassLoader === null) {
if (file_exists(APPLICATION_ROOT_DIR . '/vendor/autoload.php')) {
static::$composerClassLoader = require APPLICATION_ROOT_DIR . '/vendor/autoload.php';
static::$composerClassLoader->unregister();
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require APPLICATION_ROOT_DIR . '/vendor/autoload.php';
$loader->unregister();
static::$composerClassLoader = $loader;

return static::$composerClassLoader;
}

static::$composerClassLoader = require INTEGRATOR_ROOT_DIR . '/vendor/autoload.php';
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require INTEGRATOR_ROOT_DIR . '/vendor/autoload.php';
static::$composerClassLoader = $loader;
}

return static::$composerClassLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function parseValue($value, bool $isLiteral)
*/
protected function parseSingleValue(string $value): Expr
{
/** @var array<\PhpParser\Node\Stmt\Expression> $tree */
/** @var array<\PhpParser\Node\Stmt\Expression>|null $tree */
$tree = $this->parserFactory->createForHostVersion()->parse(sprintf('<?php %s;', $value));

if ($tree === null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Comparer/ClassConstExpressionCompareStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __construct(UseStatementsFinderInterface $useStatementsFinder)
}

/**
* @param \PhpParser\Node\Expr\ClassConstFetch $node
* @param \PhpParser\Node\Expr\ClassConstFetch $nodeToCompare
* @param \PhpParser\Node $node
* @param \PhpParser\Node $nodeToCompare
* @param array<\PhpParser\Node> $classTokenTree
*
* @return bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function createArrayStringFromResult(array $array): string

continue;
}
if (is_string($key) && !$this->isConstant($key)) {
if (!$this->isConstant($key)) {
$key = sprintf('\'%s\'', $key);
}
if (is_string($value) && !$this->isConstant($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Finder/ClassNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function findClassNode(ClassInformationTransfer $classInformationTransfer
*/
public function hasClassMethodName(ClassInformationTransfer $classInformationTransfer, string $methodName): bool
{
/** @var \PhpParser\Node\Stmt\ClassMethod $node */
/** @var \PhpParser\Node\Stmt\ClassMethod|null $node */
$node = (new NodeFinder())->findFirst($classInformationTransfer->getTokenTree(), function (Node $node) use ($methodName) {
return $node instanceof ClassMethod && $node->name->toString() === $methodName;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,15 @@ protected function processMethodCall(
*/
protected function isStatementAddPluginMethodCall(Stmt $stmt): bool
{
if ($stmt instanceof Expression === false) {
if (!$stmt instanceof Expression) {
return false;
}

if ($stmt instanceof Expression && $stmt->expr instanceof MethodCall === false) {
if (!$stmt->expr instanceof MethodCall) {
return false;
}

if (
$stmt instanceof Expression
&& $stmt->expr instanceof MethodCall
&& strpos(strtolower($stmt->expr->name->toString()), 'add') === false
) {
if (strpos(strtolower($stmt->expr->name->toString()), 'add') === false) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,8 @@ public function leaveNode(Node $node)
return $node;
}

/** @var \PhpParser\Node\Expr\ClassConstFetch $firstParam */
$firstParam = $node->expr->args[0]->value;

/** @var \PhpParser\Node\Expr\New_ $secondParam */
$secondParam = $node->expr->args[1]->value;

if (!($firstParam instanceof ClassConstFetch) || $firstParam->class->toString() !== $this->keyClassToRemove || $firstParam->name->toString() !== $this->keyToRemove) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ protected function processMethodCall(MethodCall $methodCall): MethodCall
}
}

if (!$methodCall->var instanceof MethodCall) {
return $methodCall;
}

$methodCall->var = $this->processMethodCall($methodCall->var);

return $methodCall;
Expand All @@ -140,19 +136,15 @@ protected function processMethodCall(MethodCall $methodCall): MethodCall
*/
protected function isStatementAddPluginMethodCall(Stmt $stmt): bool
{
if ($stmt instanceof Expression === false) {
if (!$stmt instanceof Expression) {
return false;
}

if ($stmt instanceof Expression && $stmt->expr instanceof MethodCall === false) {
if (!$stmt->expr instanceof MethodCall) {
return false;
}

if (
$stmt instanceof Expression
&& $stmt->expr instanceof MethodCall
&& strpos(strtolower($stmt->expr->name->toString()), 'add') === false
) {
if (strpos(strtolower($stmt->expr->name->toString()), 'add') === false) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function enterNode(Node $node): Node
*/
protected function handleContainerExtendClosure(Closure $closure): Closure
{
$pluginToRemoveIndex = 0;
$pluginToRemoveIndex = null;

foreach ($closure->stmts as $index => $stmt) {
if ($stmt instanceof Expression === false) {
Expand All @@ -99,7 +99,7 @@ protected function handleContainerExtendClosure(Closure $closure): Closure
}

if ($pluginToRemoveIndex !== null) {
array_splice($closure->stmts, $pluginToRemoveIndex, 1);
array_splice($closure->stmts, (int)$pluginToRemoveIndex, 1);
}

return $closure;
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/ClassHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getOrganisationName(string $className): string
return '';
}

return explode('\\', ltrim($className, '\\'))[0] ?? '';
return explode('\\', ltrim($className, '\\'))[0];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/IntegratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ public function createBuilderFactory(): BuilderFactory
}

/**
* @return \SprykerSdk\Integrator\Helper\ClassHelperInterface;
* @return \SprykerSdk\Integrator\Helper\ClassHelperInterface
*/
public function createClassHelper(): ClassHelperInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/ManifestStrategy/UnwireNavigationManifestStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function apply(array $manifest, string $moduleName, InputOutputInterface
}

/**
* @param array<string|int, array<int|string, mixed>> $navigation
* @param array<string|int, mixed> $navigation
* @param array<string|int, array<string, mixed|null>|null> $manifestData
*
* @return array<string|int, array<int|string, mixed>>
* @return array<string|int, mixed>
*/
protected function applyNewNavigation(
array $navigation,
Expand Down
2 changes: 1 addition & 1 deletion src/Transfer/ChainAssignValueTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ChainAssignValueTransfer
protected array $keys = [];

/**
* @var \PhpParser\Node\Expr|null;
* @var \PhpParser\Node\Expr|null
*/
protected ?Expr $value = null;

Expand Down
Loading