Skip to content
Open
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"doctrine/doctrine-bundle": "^2.5.5",
"whatwedo/php-coding-standard": "^1.0",
"symfony/twig-bundle": "^6.0",
"phpstan/phpstan": "^1.7"
"phpstan/phpstan": "^1.7",
"phpstan/phpstan-phpunit": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 6
paths:
- src
- tests
bootstrapFiles:
- vendor/bin/.phpunit/phpunit-9.5-0/vendor/autoload.php
- vendor/autoload.php
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<php>
<server name="KERNEL_CLASS" value="whatwedo\CoreBundle\Tests\App\Kernel"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>

</php>
<testsuites>
Expand Down
6 changes: 3 additions & 3 deletions src/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

// Dump settings
$this->debug('Arguments: ' . var_export($input->getArguments(), true));
$this->debug('Options: ' . var_export($input->getOptions(), true));
$this->debug('Arguments: '.var_export($input->getArguments(), true));
$this->debug('Options: '.var_export($input->getOptions(), true));

return Command::SUCCESS;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ private function startStopwatch(): void
private function stopStopwatch(): void
{
$event = $this->stopwatch->stop('command');
$this->debug('Finished in ' . $event->getDuration() . 'ms');
$this->debug('Finished in '.$event->getDuration().'ms');
}

protected function tearDown(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Traits/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getOutput(): OutputInterface
public function log(string $message): void
{
if ($this->isVerbose()) {
$message = date('[H:i:s] ') . $message;
$message = date('[H:i:s] ').$message;
}
$this->getOutput()->writeln($message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/whatwedoCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);

$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
4 changes: 2 additions & 2 deletions src/Formatter/CollectionFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function getHtml(mixed $value): string
}
$str = '<ul>';
foreach ($value as $singleValue) {
$str .= '<li>' . $singleValue . '</li>';
$str .= '<li>'.$singleValue.'</li>';
}

return $str . '</ul>';
return $str.'</ul>';
}
}
2 changes: 1 addition & 1 deletion src/Formatter/EnumFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getString(mixed $enum): string
return '';
}

return $this->translator->trans($this->options['translation_key_prefix'] . $enum->value);
return $this->translator->trans($this->options['translation_key_prefix'].$enum->value);
}

protected function configureOptions(OptionsResolver $resolver): void
Expand Down
4 changes: 2 additions & 2 deletions src/Formatter/MoneyFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function getString(mixed $value): string
);

if ($this->options[self::OPT_CURRENCY_POSITION] === 'start') {
return $this->options[self::OPT_CURRENCY] . ' ' . $str;
return $this->options[self::OPT_CURRENCY].' '.$str;
}

return $str . ' ' . $this->options[self::OPT_CURRENCY];
return $str.' '.$this->options[self::OPT_CURRENCY];
}

protected function configureOptions(OptionsResolver $resolver): void
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/TwigFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ private function camel_to_snake($input)
}
$pattern = '/([a-z])([A-Z])/';

return strtolower(preg_replace_callback($pattern, fn ($a) => $a[1] . '_' . strtolower($a[2]), $input));
return strtolower(preg_replace_callback($pattern, fn ($a) => $a[1].'_'.strtolower($a[2]), $input));
}
}
3 changes: 2 additions & 1 deletion src/Manager/FormatterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class FormatterManager
* @param FormatterInterface[] $formatters
*/
public function __construct(
#[TaggedIterator('whatwedo_core.formatter')] iterable $formatters
#[TaggedIterator('whatwedo_core.formatter')]
iterable $formatters
) {
foreach ($formatters as $formatter) {
$this->formatters[$formatter::class] = $formatter;
Expand Down
1 change: 1 addition & 0 deletions tests/AbstractFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class AbstractFormatterTest extends KernelTestCase
{
protected function getFormatter(string $formatterClass): FormatterInterface
{
/** @var FormatterManager $formatterManager */
$formatterManager = self::getContainer()->get(FormatterManager::class);

return $formatterManager->getFormatter($formatterClass);
Expand Down
4 changes: 2 additions & 2 deletions tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public function __construct()

public function getCacheDir(): string
{
return $this->getProjectDir() . '/../../var/cache/' . $this->environment;
return $this->getProjectDir().'/../../var/cache/'.$this->environment;
}

public function getProjectDir(): string
{
return \dirname(__DIR__) . '/App';
return \dirname(__DIR__).'/App';
}
}
2 changes: 1 addition & 1 deletion tests/App/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__) . '/../../vendor/autoload.php';
require dirname(__DIR__).'/../../vendor/autoload.php';

//// Load cached env vars if the .env.local.php file exists
//// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
Expand Down
2 changes: 1 addition & 1 deletion tests/App/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\HttpFoundation\Request;
use whatwedo\CoreBundle\Tests\App\Kernel;

require dirname(__DIR__) . '/config/bootstrap.php';
require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);
Expand Down
1 change: 1 addition & 0 deletions tests/CountryAlpha3FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class CountryAlpha3FormatterTest extends AbstractFormatterTest
public function testFormatter(): void
{
$formatter = $this->getFormatter(CountryAlpha3Formatter::class);
$formatter->processOptions();
self::assertSame('Schweiz', $formatter->getHtml('CHE'));
}

Expand Down
1 change: 1 addition & 0 deletions tests/DateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DateFormatterTest extends AbstractFormatterTest
public function testFormatter(): void
{
$formatter = $this->getFormatter(DateFormatter::class);
$formatter->processOptions();
self::assertSame('04.02.2022', $formatter->getHtml(new \DateTime('2022-02-04 13:45:56')));
}
}
1 change: 1 addition & 0 deletions tests/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DateTimeFormatterTest extends AbstractFormatterTest
public function testFormatter(): void
{
$formatter = $this->getFormatter(DateTimeFormatter::class);
$formatter->processOptions();
self::assertSame('04.02.2022 13:45', $formatter->getHtml(new \DateTime('2022-02-04 13:45:56')));
}
}
2 changes: 1 addition & 1 deletion tests/InfoFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testFormatter(): void
$formatter = $this->getFormatter(InfoFormatter::class);
$formatter->processOptions();
self::assertSame('<span title="info" data-toggle="tooltip"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2"/>
</svg></span>
', $formatter->getHtml('info'));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

use Symfony\Component\Filesystem\Filesystem;

require \dirname(__DIR__) . '/vendor/autoload.php';
require \dirname(__DIR__).'/vendor/autoload.php';

(new Filesystem())->remove(__DIR__ . '/../var');
(new Filesystem())->remove(__DIR__.'/../var');
Loading