+
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
48 changes: 0 additions & 48 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4776,48 +4776,6 @@ parameters:
count: 1
path: src/contracts/Collection/MutableArrayList.php

-
message: '#^Binary operation "\." between array\|bool\|float\|int\|string\|null and ''/'' results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:createFinder\(\) has parameter \$bundlesMetadata with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:dumpConfigurationPaths\(\) has parameter \$paths with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:locateConfigurationFiles\(\) has parameter \$bundlesMetadata with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:locateConfigurationFiles\(\) has parameter \$configFiles with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:locateConfigurationFiles\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Parameter \#1 \$bundlesMetadata of method Ibexa\\Contracts\\Core\\Container\\Encore\\ConfigurationDumper\:\:locateConfigurationFiles\(\) expects array, array\|bool\|float\|int\|string\|null given\.$#'
identifier: argument.type
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: '#^Method Ibexa\\Contracts\\Core\\FieldType\\BinaryBase\\PathGeneratorInterface\:\:getStoragePathForField\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down Expand Up @@ -41814,12 +41772,6 @@ parameters:
count: 1
path: tests/lib/Collection/MutableArrayMapTest.php

-
message: '#^Parameter \#2 \$string of static method PHPUnit\\Framework\\Assert\:\:assertRegExp\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 2
path: tests/lib/Container/Encore/ConfigurationDumperTest.php

-
message: '#^Method Ibexa\\Tests\\Core\\Event\\BookmarkServiceTest\:\:testCreateBookmarkEvents\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down
32 changes: 27 additions & 5 deletions src/contracts/Container/Encore/ConfigurationDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
final class ConfigurationDumper
{
public const ENCORE_DIR = 'encore';
public const ENCORE_TARGET_PATH = 'var/encore';
public const string ENCORE_DIR = 'encore';
public const string ENCORE_TARGET_PATH = 'var/encore';

private ContainerInterface $containerBuilder;

Expand All @@ -38,8 +38,9 @@ public function __construct(ContainerInterface $containerBuilder)
public function dumpCustomConfiguration(
array $webpackConfigNames
): void {
/** @var array<string, array{path: string, namespace: string}> $bundlesMetadata */
$bundlesMetadata = $this->containerBuilder->getParameter('kernel.bundles_metadata');
$rootPath = $this->containerBuilder->getParameter('kernel.project_dir') . '/';
$rootPath = $this->getProjectDirectory() . '/';
foreach ($webpackConfigNames as $configName => $configFiles) {
$paths = $this->locateConfigurationFiles($bundlesMetadata, $configFiles, $rootPath);
$this->dumpConfigurationPaths(
Expand All @@ -50,6 +51,12 @@ public function dumpCustomConfiguration(
}
}

/**
* @param array<string, array{path: string, namespace: string}> $bundlesMetadata
* @param array<string, array{'deprecated'?: bool, 'alternative'?: string}> $configFiles
*
* @return array<string>
*/
private function locateConfigurationFiles(
array $bundlesMetadata,
array $configFiles,
Expand All @@ -67,12 +74,12 @@ private function locateConfigurationFiles(
'4.0.0',
'Support for old configuration files is deprecated, please update name of %s file, to %s',
$fileInfo->getPathname(),
$options['alternative']
$options['alternative'] ?? ''
);
}

$path = $fileInfo->getRealPath();
if (strpos($path, $rootPath) === 0) {
if (str_starts_with($path, $rootPath)) {
$path = './' . substr($path, strlen($rootPath));
}

Expand All @@ -84,6 +91,8 @@ private function locateConfigurationFiles(
}

/**
* @param array<string> $paths
*
* @throws \JsonException
*/
private function dumpConfigurationPaths(
Expand All @@ -98,6 +107,9 @@ private function dumpConfigurationPaths(
);
}

/**
* @param array<string, array{path: string, namespace: string}> $bundlesMetadata
*/
private function createFinder(
array $bundlesMetadata,
string $configFile,
Expand All @@ -121,4 +133,14 @@ private function createFinder(

return $finder;
}

private function getProjectDirectory(): string
{
$projectDirectory = $this->containerBuilder->getParameter('kernel.project_dir');
if (!is_string($projectDirectory)) {
throw new \LogicException('Kernel project directory parameter is either not set or is not a string.');
}

return $projectDirectory;
}
}
9 changes: 5 additions & 4 deletions tests/lib/Container/Encore/ConfigurationDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
final class ConfigurationDumperTest extends TestCase
{
private const PROJECT_DIR = '/var/io-tests/';
private const FOO_BAR_BUNDLE_DIR = 'foo-bar';
private const string PROJECT_DIR = '/var/io-tests/';
private const string FOO_BAR_BUNDLE_DIR = 'foo-bar';

private Filesystem $filesystem;

Expand Down Expand Up @@ -64,11 +64,12 @@ public function testDumpCustomConfiguration(): void
$compiledFilePath = $this->projectDir . '/var/encore/foo-bar.js';
self::assertFileExists($compiledFilePath);
$compiledFileContents = file_get_contents($compiledFilePath);
self::assertRegExp(
self::assertNotFalse($compiledFileContents, "Failed to read compiled file '$compiledFilePath' contents");
self::assertMatchesRegularExpression(
'@^module\.exports = \[.*io-tests\\\/foo-bar\\\/Resources\\\/encore\\\/foo-bar\.js@',
$compiledFileContents
);
self::assertRegExp(
self::assertMatchesRegularExpression(
'@^module\.exports = \[.*io-tests\\\/encore\\\/foo-bar\.js@',
$compiledFileContents
);
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载