Skip to content

Commit

Permalink
minor #6084 Change: Remove __constructor() from RuleSetDescriptionInt…
Browse files Browse the repository at this point in the history
…erface (niklam)

This PR was merged into the master branch.

Discussion
----------

Change: Remove __constructor() from RuleSetDescriptionInterface

Constructor should be defined by the implementation, not by the interface.

With this change one could do, which is not possible at the moment due to the interface defining constructor with no parameters.

```php
class MyDynamicRules implements RuleSetDescriptionInterface {
    protected bool $risky;

    public function __constructor(bool $risky = false) {
        $this->risky = $risky;
    }
    ...
    public function getRules(): array {
        // return rules based on $this->risky
    }
}
```

This would allow doing something like

```php
$myRules = new MyDynamicRules(true);
$config->setRules(array_merge(
    $myRules->getRules(),
    [ /* more rules, override previously set rules */ ]
);
```

Commits
-------

1de299c Remove __constructor() from RuleSetDescriptionInterface
  • Loading branch information
SpacePossum committed Oct 30, 2021
2 parents 9abe7a6 + 1de299c commit 1e81ab2
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/RuleSet/RuleSetDescriptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
interface RuleSetDescriptionInterface
{
public function __construct();

public function getDescription(): string;

public function getName(): string;
Expand Down

0 comments on commit 1e81ab2

Please sign in to comment.