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
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('tetranz_select2_entity');
$rootNode = $treeBuilder->getRootNode();
Expand Down
16 changes: 8 additions & 8 deletions Form/DataTransformer/EntitiesToPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,30 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr
/**
* Transform initial entities to array
*
* @param mixed $entities
* @param mixed $value
* @return array
*/
public function transform($entities)
public function transform($value): mixed
{
if (empty($entities)) {
if (empty($value)) {
return array();
}

$data = array();

foreach ($entities as $entity) {
foreach ($value as $entity) {
$text = is_null($this->textProperty)
? (string) $entity
: $this->accessor->getValue($entity, $this->textProperty);

if ($this->em->contains($entity)) {
$value = (string) $this->accessor->getValue($entity, $this->primaryKey);
$v = (string) $this->accessor->getValue($entity, $this->primaryKey);
} else {
$value = $this->newTagPrefix . $text;
$v = $this->newTagPrefix . $text;
$text = $text.$this->newTagText;
}

$data[$value] = $text;
$data[$v] = $text;
}

return $data;
Expand All @@ -87,7 +87,7 @@ public function transform($entities)
* @param array $values
* @return array
*/
public function reverseTransform($values)
public function reverseTransform($values): mixed
{
if (!is_array($values) || empty($values)) {
return array();
Expand Down
4 changes: 2 additions & 2 deletions Form/DataTransformer/EntityToPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr
* @param mixed $entity
* @return array
*/
public function transform($entity)
public function transform($entity): mixed
{
$data = array();
if (empty($entity)) {
Expand Down Expand Up @@ -85,7 +85,7 @@ public function transform($entity)
* @param string $value
* @return mixed|null|object
*/
public function reverseTransform($value)
public function reverseTransform($value): mixed
{
if (empty($value)) {
return null;
Expand Down
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@
}
],
"require": {
"php": ">=7.1.3",
"php": "^8.2",
"doctrine/orm": ">=2.4",
"twig/twig": ">=2.9",
"symfony/property-access": ">=4.0",
"symfony/dependency-injection": ">=4.0",
"symfony/http-kernel": ">=4.0",
"symfony/form": ">=4.0",
"symfony/config": ">=4.0",
"symfony/routing": ">=4.0"
"twig/twig": "^3.15",
"symfony/property-access": "^6.4 || ^7.1" ,
"symfony/dependency-injection": "^6.4 || ^7.1" ,
"symfony/http-kernel": "^6.4 || ^7.1" ,
"symfony/form": "^6.4 || ^7.1" ,
"symfony/config": "^6.4 || ^7.1" ,
"symfony/routing": "^6.4 || ^7.1"
},
"autoload": {
"psr-4": { "Tetranz\\Select2EntityBundle\\": "" }
},
"extra": {
"branch-alias": {
}
},
"require-dev": {
"phpstan/phpstan": "^2.0"
}
}
32 changes: 32 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
parameters:
level: 0
inferPrivatePropertyTypeFromConstructor: true
paths:
- .

excludePaths:
# - 'src/Resources/skeleton'
# - */cache/*
analyse:
- ./vendor

ignoreErrors:
# False positive: clients are not dependencies of this project.
# -
# message: '#Return typehint of method KnpU\\OAuth2ClientBundle\\Client\\Provider\\[a-zA-Z0-9\\_]+::fetchUserFromToken\(\) has invalid type [a-zA-Z0-9\\_]#'
# path: ./src/Client/Provider
# -
# message: '#Return typehint of method KnpU\\OAuth2ClientBundle\\Client\\Provider\\[a-zA-Z0-9\\_]+::fetchUser\(\) has invalid type [a-zA-Z0-9\\_]#'
# path: ./src/Client/Provider
# False positive: using `::class` is not an error for those providers `::getProviderClass()` method.
# -
# message: '#Class [a-zA-Z0-9\\_]+ not found#'
# path: ./src/DependencyInjection/Providers

# The DependencyInjection returns are very complex to deal with
# -
# message: '#.*NodeParentInterface\|null.*#'
# path: ./src/DependencyInjection/Providers

# - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#'
# - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::scalarNode\(\).#'