Skip to content

Commit

Permalink
[Composer] Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Feb 18, 2020
1 parent f443c51 commit 0d91c76
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 150 deletions.
19 changes: 8 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"symfony/asset": "^4.4|^5.0",
"symfony/config": "^4.4|^5.0",
"symfony/console": "^4.4|^5.0",
"symfony/translation-contracts": "^1.0",
"symfony/translation-contracts": "^1.1|^2.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/filesystem": "^4.4|^5.0",
"symfony/finder": "^4.4|^5.0",
Expand All @@ -40,24 +40,21 @@
"zendframework/zend-hydrator": "^2.2"
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"matthiasnoback/symfony-config-test": "^4.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"mikey179/vfsstream": "^1.6",
"phpspec/phpspec": "^5.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-webmozart-assert": "^0.11",
"phpunit/phpunit": "^7.0",
"phpspec/phpspec": "^6.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-webmozart-assert": "^0.12",
"phpunit/phpunit": "^8.5",
"sylius-labs/coding-standard": "^3.0",
"symfony/browser-kit": "^4.4|^5.0",
"symfony/security-csrf": "^4.4|^5.0",
"symfony/twig-bundle": "^4.4|^5.0",
"twig/twig": "^2.0",
"vimeo/psalm": "^3.5"
},
"conflict": {
"twig/twig": "^1.0"
},
"autoload": {
"psr-4": {
"Sylius\\Bundle\\ThemeBundle\\": "src/"
Expand Down
20 changes: 10 additions & 10 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ includes:
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false

specDir: 'spec/'
treatPhpDocTypesAsCertain: false

excludes_analyse:
- %currentWorkingDirectory%/tests/Application/var/*
# Test dependencies
- %currentWorkingDirectory%/spec/
- %currentWorkingDirectory%/tests/Application/var/

ignoreErrors:
# PHPStan integration
- '/Call to an undefined method Prophecy\\Prophecy\\MethodProphecy::getRealPath\(\)/'

# Symfony 3.4 support
- '/Method Symfony\\Component\\HttpKernel\\KernelInterface::getBundle\(\) invoked with 2 parameters, 1 required/'
- '/Method Symfony\\Component\\HttpKernel\\KernelInterface::getBundle\(\) invoked with 2 parameters, 0-1 required/'
- '/Call to function method_exists\(\) with .Symfony\\\\Component…. and .getRootNode. will always evaluate to false/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::getRootNode\(\)/'
- '/Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not have a constructor and must be instantiated without any parameters/'

# Symfony caveats
- '/Parameter \#1 \$name of method Symfony\\Component\\Config\\FileLocatorInterface::locate\(\) expects string, Symfony\\Component\\Templating\\TemplateReferenceInterface given/'
- '/Parameter \#1 \$translator of class Symfony\\Component\\Translation\\Formatter\\MessageFormatter constructor expects Symfony\\Contracts\\Translation\\TranslatorInterface|null, Symfony\\Component\\Translation\\MessageSelector given/'

# Symfony passes TemplateReference object instead of a string
- "/Casting to string something that\\'s already string./"
- '/Parameter \#1 \$name of method Twig\\Loader\\LoaderInterface::[A-Za-z]+\(\) expects string, string\|Symfony\\Component\\Templating\\TemplateReference given\./'

- '/Method Sylius\\Bundle\\ThemeBundle\\Filesystem\\FilesystemInterface::[A-Za-z]+\(\) has no return typehint specified./'
- '/Method Sylius\\Bundle\\ThemeBundle\\Translation\\ThemeAwareTranslator::__call\(\) has no return typehint specified./'
- '/Method Sylius\\Bundle\\ThemeBundle\\Translation\\ThemeAwareTranslator::trans\(\) has parameter \$[A-Za-z]+ with no typehint specified./'
- '/Method Sylius\\Bundle\\ThemeBundle\\Templating\\Locator\\TemplateFileLocator::unserialize\(\) has parameter \$serialized with no typehint specified./'
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<InvalidArgument>
<errorLevel type="suppress">
<referencedFunction name="Symfony\Component\Config\FileLocatorInterface::locate" />
<referencedFunction name="Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch" />
</errorLevel>
</InvalidArgument>
Expand Down
2 changes: 0 additions & 2 deletions src/Asset/Installer/AssetsInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\KernelInterface;

Expand Down Expand Up @@ -110,7 +109,6 @@ private function installThemedBundleAssets(ThemeInterface $theme, string $origin
$finder = new Finder();
$finder->sortByName()->ignoreDotFiles(false)->in($originDir);

/** @var SplFileInfo[] $finder */
foreach ($finder as $originFile) {
$targetFile = $targetDir . '/' . $originFile->getRelativePathname();
$targetFile = $this->pathResolver->resolve($targetFile, $theme);
Expand Down
5 changes: 1 addition & 4 deletions src/Asset/Package/PathPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public function __construct(
$this->pathResolver = $pathResolver;
}

/**
* {@inheritdoc}
*/
public function getUrl($path): string
public function getUrl(string $path): string
{
if ($this->isAbsoluteUrl($path)) {
return $path;
Expand Down
5 changes: 1 addition & 4 deletions src/Asset/Package/UrlPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public function __construct(
$this->pathResolver = $pathResolver;
}

/**
* {@inheritdoc}
*/
public function getUrl($path): string
public function getUrl(string $path): string
{
if ($this->isAbsoluteUrl($path)) {
return $path;
Expand Down
35 changes: 13 additions & 22 deletions src/Configuration/ThemeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,19 @@ final class ThemeConfiguration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('sylius_theme');

/** @var ArrayNodeDefinition $rootNodeDefinition */
$rootNodeDefinition = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$treeBuilder = new TreeBuilder();

/** @var ArrayNodeDefinition $rootNodeDefinition */
$rootNodeDefinition = $treeBuilder->root('sylius_theme');
}

$rootNodeDefinition->ignoreExtraKeys();

$this->addRequiredNameField($rootNodeDefinition);
$this->addOptionalTitleField($rootNodeDefinition);
$this->addOptionalDescriptionField($rootNodeDefinition);
$this->addOptionalPathField($rootNodeDefinition);
$this->addOptionalParentsList($rootNodeDefinition);
$this->addOptionalScreenshotsList($rootNodeDefinition);
$this->addOptionalAuthorsList($rootNodeDefinition);
$treeBuilder = new TreeBuilder('sylius_theme');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

$rootNode->ignoreExtraKeys();

$this->addRequiredNameField($rootNode);
$this->addOptionalTitleField($rootNode);
$this->addOptionalDescriptionField($rootNode);
$this->addOptionalPathField($rootNode);
$this->addOptionalParentsList($rootNode);
$this->addOptionalScreenshotsList($rootNode);
$this->addOptionalAuthorsList($rootNode);

return $treeBuilder;
}
Expand Down
25 changes: 8 additions & 17 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,16 @@ public function __construct(array $configurationSourceFactories = [])
*/
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('sylius_theme');
$treeBuilder = new TreeBuilder('sylius_theme');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

/** @var ArrayNodeDefinition $rootNodeDefinition */
$rootNodeDefinition = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$treeBuilder = new TreeBuilder();
$this->addSourcesConfiguration($rootNode);

/** @var ArrayNodeDefinition $rootNodeDefinition */
$rootNodeDefinition = $treeBuilder->root('sylius_theme');
}

$this->addSourcesConfiguration($rootNodeDefinition);

$rootNodeDefinition->children()->arrayNode('assets')->canBeDisabled();
$rootNodeDefinition->children()->arrayNode('templating')->canBeDisabled();
$rootNodeDefinition->children()->arrayNode('translations')->canBeDisabled();
$rootNodeDefinition->children()->scalarNode('context')->defaultValue('sylius.theme.context.settable')->cannotBeEmpty();
$rootNode->children()->arrayNode('assets')->canBeDisabled();
$rootNode->children()->arrayNode('templating')->canBeDisabled();
$rootNode->children()->arrayNode('translations')->canBeDisabled();
$rootNode->children()->scalarNode('context')->defaultValue('sylius.theme.context.settable')->cannotBeEmpty();

return $treeBuilder;
}
Expand Down
22 changes: 11 additions & 11 deletions src/Filesystem/FilesystemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface FilesystemInterface
* @throws FileNotFoundException When originFile doesn't exist
* @throws IOException When copy fails
*/
public function copy($originFile, $targetFile, $override = false);
public function copy(string $originFile, string $targetFile, bool $override = false);

/**
* Creates a directory recursively.
Expand All @@ -42,7 +42,7 @@ public function copy($originFile, $targetFile, $override = false);
*
* @throws IOException On any directory creation failure
*/
public function mkdir($dirs, $mode = 0777);
public function mkdir($dirs, int $mode = 0777);

/**
* Checks the existence of files or directories.
Expand All @@ -62,7 +62,7 @@ public function exists($files);
*
* @throws IOException When touch fails
*/
public function touch($files, $time = null, $atime = null);
public function touch($files, int $time = null, int $atime = null);

/**
* Removes files or directories.
Expand All @@ -83,7 +83,7 @@ public function remove($files);
*
* @throws IOException When the change fail
*/
public function chmod($files, $mode, $umask = 0000, $recursive = false);
public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false);

/**
* Change the owner of an array of files or directories.
Expand All @@ -94,7 +94,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false);
*
* @throws IOException When the change fail
*/
public function chown($files, $user, $recursive = false);
public function chown($files, string $user, bool $recursive = false);

/**
* Change the group of an array of files or directories.
Expand All @@ -105,7 +105,7 @@ public function chown($files, $user, $recursive = false);
*
* @throws IOException When the change fail
*/
public function chgrp($files, $group, $recursive = false);
public function chgrp($files, string $group, bool $recursive = false);

/**
* Renames a file or a directory.
Expand All @@ -117,7 +117,7 @@ public function chgrp($files, $group, $recursive = false);
* @throws IOException When target file or directory already exists
* @throws IOException When origin cannot be renamed
*/
public function rename($origin, $target, $overwrite = false);
public function rename(string $origin, string $target, bool $overwrite = false);

/**
* Creates a symbolic link or copy a directory.
Expand All @@ -128,7 +128,7 @@ public function rename($origin, $target, $overwrite = false);
*
* @throws IOException When symlink fails
*/
public function symlink($originDir, $targetDir, $copyOnWindows = false);
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false);

/**
* Mirrors a directory to another.
Expand All @@ -144,7 +144,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false);
*
* @throws IOException When file type is unknown
*/
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = []);
public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = []);

/**
* Given an existing path, convert it to a path relative to a given starting path.
Expand All @@ -154,7 +154,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
*
* @return string Path of target relative to starting path
*/
public function makePathRelative($endPath, $startPath);
public function makePathRelative(string $endPath, string $startPath);

/**
* Returns whether the file path is an absolute path.
Expand All @@ -163,7 +163,7 @@ public function makePathRelative($endPath, $startPath);
*
* @return bool
*/
public function isAbsolutePath($file);
public function isAbsolutePath(string $file);

public function getFileContents(string $file): string;
}
1 change: 0 additions & 1 deletion src/Loader/ThemeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ private function initializeThemes(array $configurations): array
{
$themes = [];
foreach ($configurations as $configuration) {
/** @var ThemeInterface $theme */
$themes[$configuration['name']] = $this->themeFactory->create($configuration['name'], $configuration['path']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Locator/BundleResourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function locateResourceBasedOnBundleNotation(string $resourcePath, Theme

// Symfony 4.0+ always returns a single bundle
/** @var BundleInterface|BundleInterface[] $bundles */
$bundles = $this->kernel->getBundle($bundleName, false);
$bundles = $this->kernel->getBundle($bundleName);

// So we need to hack it to support both Symfony 3.4 and Symfony 4.0+
if (!is_array($bundles)) {
Expand Down
1 change: 1 addition & 0 deletions src/Twig/ThemeFilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function getCacheKey($name): string

/**
* @param string|TemplateReference $name
* @param int $time
*/
public function isFresh($name, $time): bool
{
Expand Down
8 changes: 1 addition & 7 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

final class Kernel extends HttpKernel
{
/**
* {@inheritdoc}
*/
public function registerBundles()
{
return [
Expand All @@ -31,10 +28,7 @@ public function registerBundles()
];
}

/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/config/config.yml');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

final class TestExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
Expand Down
Loading

0 comments on commit 0d91c76

Please sign in to comment.