Skip to content

Commit

Permalink
Merge pull request #5 from AngelFQC/master
Browse files Browse the repository at this point in the history
Fix deprecations about return types
  • Loading branch information
ywarnier authored Apr 5, 2024
2 parents d6ff2bc + 7dc0604 commit f2a2495
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 107 deletions.
5 changes: 1 addition & 4 deletions src/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
*/
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('sylius_settings');
$rootNode = $treeBuilder->getRootNode();
Expand Down
78 changes: 15 additions & 63 deletions src/Bundle/Model/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,17 @@ class Settings implements SettingsInterface
*/
protected $parameters = [];

/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}

/**
* {@inheritdoc}
*/
public function getSchemaAlias()
public function getSchemaAlias(): string
{
return $this->schemaAlias;
}

/**
* {@inheritdoc}
*/
public function setSchemaAlias($schemaAlias)
public function setSchemaAlias(string $schemaAlias): void
{
if (null !== $this->schemaAlias) {
throw new \LogicException('The schema alias of the settings model is immutable, instantiate a new object in order to use another schema.');
Expand All @@ -66,18 +57,12 @@ public function setSchemaAlias($schemaAlias)
$this->schemaAlias = $schemaAlias;
}

/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
return $this->namespace;
}

/**
* {@inheritdoc}
*/
public function setNamespace($namespace)
public function setNamespace($namespace): void
{
if (null !== $this->namespace) {
throw new \LogicException('The namespace of the settings model is immutable, instantiate a new object in order to use another namespace.');
Expand All @@ -86,66 +71,42 @@ public function setNamespace($namespace)
$this->namespace = $namespace;
}

/**
* {@inheritdoc}
*/
public function getParameters()
public function getParameters(): array
{
return $this->parameters;
}

/**
* {@inheritdoc}
*/
public function setParameters(array $parameters)
public function setParameters(array $parameters): void
{
$this->parameters = $parameters;
}

/**
* {@inheritdoc}
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return $this->has($offset);
}

/**
* {@inheritdoc}
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return $this->get($offset);
}

/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
$this->set($offset, $value);
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
$this->remove($offset);
}

/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
return count($this->parameters);
}

/**
* {@inheritdoc}
*/
public function get($name)
public function get(string $name): mixed
{
if (!$this->has($name)) {
throw new ParameterNotFoundException($name);
Expand All @@ -154,26 +115,17 @@ public function get($name)
return $this->parameters[$name];
}

/**
* {@inheritdoc}
*/
public function has($name)
public function has(string $name): bool
{
return array_key_exists($name, $this->parameters);
}

/**
* {@inheritdoc}
*/
public function set($name, $value)
public function set(string $name, mixed $value): void
{
$this->parameters[$name] = $value;
}

/**
* {@inheritdoc}
*/
public function remove($name)
public function remove(string $name): void
{
if (!$this->has($name)) {
throw new ParameterNotFoundException($name);
Expand Down
50 changes: 10 additions & 40 deletions src/Bundle/Model/SettingsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,29 @@
*/
interface SettingsInterface extends \ArrayAccess, \Countable //ResourceInterface,
{
/**
* @return string
*/
public function getSchemaAlias();
public function getSchemaAlias(): string;

/**
* @param string $schemaAlias
*/
public function setSchemaAlias($schemaAlias);
public function setSchemaAlias(string $schemaAlias);

/**
* @return string
*/
public function getNamespace();
public function getNamespace(): string;

/**
* @param string $namespace
*/
public function setNamespace($namespace);
public function setNamespace(string $namespace): void;

/**
* @return array
*/
public function getParameters();
public function getParameters(): array;

public function setParameters(array $parameters);
public function setParameters(array $parameters): void;

/**
* @param string $name
*
* @return mixed
*
* @throws ParameterNotFoundException
*/
public function get($name);
public function get(string $name): mixed;

/**
* @param string $name
*
* @return bool
*/
public function has($name);
public function has(string $name): bool;

/**
* @param string $name
* @param mixed $value
*/
public function set($name, $value);
public function set(string $name, mixed $value): void;

/**
* @param string $name
*
* @throws ParameterNotFoundException
*/
public function remove($name);
public function remove(string $name): void;
}

0 comments on commit f2a2495

Please sign in to comment.