Skip to content

Commit

Permalink
Merge pull request #9 from 21TORR/phpstan
Browse files Browse the repository at this point in the history
Add proper types for configurable bundle extension + update CI
  • Loading branch information
apfelbox authored Jun 25, 2024
2 parents a753423 + 6c2b7a9 commit 323b46f
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: ['8.2', '8.3']
php: ['8.3']

steps:
- name: Checkout Code
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2.3.0
=====

* (feature) Add proper types for configurable bundle extension.
* (internal) Update CI.
* (improvement) Require Symfony 7 and PHP 8.3+


2.2.0
=====

Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
],
"homepage": "https://github.com/21TORR/bundle-helpers",
"require": {
"php": ">= 8.2",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
"php": ">= 8.3",
"symfony/config": "^7.0",
"symfony/dependency-injection": "^7.0",
"symfony/http-kernel": "^7.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^7.0"
"symfony/phpunit-bridge": "^7.1"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -53,10 +53,11 @@
],
"lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi",
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --dry-run --no-interaction --ansi --using-cache no"
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
],
"test": [
"vendor-bin/test/vendor/bin/phpstan analyze -c phpstan.neon . --ansi"
"simple-phpunit",
"vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v"
]
}
}
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
includes:
- vendor-bin/test/vendor/21torr/php-cs/phpstan/lib.neon
- vendor-bin/janus/vendor/21torr/janus/phpstan/lib.neon

# If you use simple-phpunit, you need to uncomment the following line.
# Always make sure to first run simple-phpunit and then PHPStan.
parameters:
level: 9
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
3 changes: 2 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
Expand All @@ -11,6 +11,7 @@
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
</php>

<testsuites>
Expand Down
13 changes: 5 additions & 8 deletions src/Bundle/BundleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class BundleExtension extends Extension
private BundleInterface $bundle;
private ?string $alias;


public function __construct (
BundleInterface $bundle,
?string $alias = null,
Expand All @@ -28,22 +27,20 @@ public function __construct (
$this->alias = $alias;
}


/**
* @inheritDoc
*/
public function load (array $configs, ContainerBuilder $container) : void
{
$configDir = "{$this->bundle->getPath()}/config";

if (\is_file("{$configDir}/services.yaml"))
if (is_file("{$configDir}/services.yaml"))
{
$loader = new YamlFileLoader($container, new FileLocator($configDir));
$loader->load("services.yaml");
}
}


/**
* @inheritDoc
*/
Expand All @@ -56,17 +53,17 @@ public function getAlias () : string

$className = \get_class($this->bundle);

if ('Bundle' !== \substr($className, -6))
if ('Bundle' !== substr($className, -6))
{
throw new BundleHelpersException(\sprintf(
throw new BundleHelpersException(sprintf(
"The bundle does not follow the naming convention; you must pass an explicit alias. Its name should end on 'Bundle', but it is '%s'.",
$className,
));
}

$classBaseNameForNamespacedClass = \strrchr($className, '\\');
$classBaseNameForNamespacedClass = strrchr($className, '\\');
$classBaseName = false !== $classBaseNameForNamespacedClass
? \substr($classBaseNameForNamespacedClass, 1, -6)
? substr($classBaseNameForNamespacedClass, 1, -6)
: $className;

return Container::underscore($classBaseName);
Expand Down
5 changes: 3 additions & 2 deletions src/Bundle/ConfigurableBundleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
class ConfigurableBundleExtension extends BundleExtension
{
private ConfigurationInterface $config;
/** @var callable */

/** @var callable(array, ContainerBuilder): void */
private $callback;

/**
* @param callable(array, ContainerBuilder): void $callback
*/
public function __construct (
BundleInterface $bundle,
Expand All @@ -30,7 +32,6 @@ public function __construct (
$this->callback = $callback;
}


/**
* @inheritDoc
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Bundle/BundleExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Torr\BundleHelpers\Bundle\BundleExtension;
use Torr\BundleHelpers\Exception\BundleHelpersException;

/**
* @internal
*/
final class BundleExtensionTest extends TestCase
{
/**
Expand Down
17 changes: 9 additions & 8 deletions vendor-bin/c-norm/composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"require": {
"ergebnis/composer-normalize": "^2.41"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
}
}
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"roave/security-advisories": "dev-latest"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
}
}
}
7 changes: 4 additions & 3 deletions vendor-bin/cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require": {
"21torr/php-cs-fixer": "^1.0.2"
}
"require-dev": {
"21torr/php-cs-fixer": "^1.1.1",
"roave/security-advisories": "dev-latest"
}
}
8 changes: 8 additions & 0 deletions vendor-bin/janus/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"21torr/janus": "^1.3"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
}
}
21 changes: 21 additions & 0 deletions vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"require": {
"php": "^8.3"
},
"require-dev": {
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-doctrine": "^1.4",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.4",
"roave/security-advisories": "dev-latest",
"staabm/phpstan-todo-by": "^0.1.25"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
11 changes: 0 additions & 11 deletions vendor-bin/test/composer.json

This file was deleted.

0 comments on commit 323b46f

Please sign in to comment.