Skip to content

Commit

Permalink
Merge pull request #3 from devbrunocorrea/feature/upgrade-php8-sf6
Browse files Browse the repository at this point in the history
Upgrade de pacotes para Symfony 6 e ajustes para compatibilidade com PHP 8.3
  • Loading branch information
alisonvalente committed Apr 10, 2024
2 parents 66c54e7 + ccc1389 commit c505bc5
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 52 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"license": "MIT",
"require": {
"php": "^8.0",
"symfony/console": "^5.1",
"symfony/var-dumper": "^5.1",
"symfony/lock": "^5.1",
"symfony/dotenv": "^5.1",
"symfony/console": "^6.4",
"symfony/var-dumper": "^6.4",
"symfony/lock": "^6.4",
"symfony/dotenv": "^6.4",
"doctrine/orm": "^2.8",
"doctrine/persistence": "^2.1",
"symfony/yaml": "^5.1",
"symfony/finder": "^5.1",
"symfony/filesystem": "^5.1",
"symfony/yaml": "^6.4",
"symfony/finder": "^6.4",
"symfony/filesystem": "^6.4",
"monolog/monolog": "^2.0",
"symfony/cache": "^5.1",
"symfony/cache": "^6.4",
"twig/twig": "^2.10|^3.0",
"psr/simple-cache": "^1.0",
"phpdocumentor/reflection-docblock": "^5.2"
Expand All @@ -34,7 +34,7 @@
}
},
"require-dev": {
"gpupo/common-dev": "^5.3||dev-main"
"phpunit/phpunit": "^8.5||^9.0"
},
"bin": ["bin/developer-toolbox"],
"config": {
Expand Down
4 changes: 2 additions & 2 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

use Symfony\Component\Dotenv\Dotenv;

if (!class_exists('\Gpupo\Common\Console\Application')) {
if (!class_exists(\Gpupo\Common\Console\Application::class)) {
require __DIR__.'/../vendor/autoload.php';
}

if (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
}
// load all the .env files
(new Dotenv(true))->loadEnv(dirname(__DIR__).'/.env');
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
14 changes: 4 additions & 10 deletions src/Console/AbstractApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
parent::__construct($name, $version);
}

#[\Override]
public function doRun(InputInterface $input, OutputInterface $output)
{
return parent::doRun($input, $output);
Expand Down Expand Up @@ -71,11 +72,8 @@ public function processInputParameters(array $definitions, InputInterface $input

/**
* @deprecated since 4.6
*
* @param mixed $name
* @param mixed $description
*/
public function appendCommand($name, $description, array $definition = [])
public function appendCommand(mixed $name, mixed $description, array $definition = [])
{
return $this->register($name)
->setDescription($description)
Expand All @@ -91,10 +89,8 @@ public function showException(Exception $e, OutputInterface $output, $descriptio

/**
* @deprecated since 4.6. Use ResourceTrait instead
*
* @param mixed $filename
*/
public function jsonLoadFromFile($filename)
public function jsonLoadFromFile(mixed $filename)
{
if (!file_exists($filename)) {
throw new Exception('Filename '.$filename.' not exists!');
Expand Down Expand Up @@ -122,10 +118,8 @@ protected function define(string $name, $value): void

/**
* @deprecated since 4.6
*
* @param mixed $parameter
*/
protected function processInputParameter($parameter, InputInterface $input, OutputInterface $output)
protected function processInputParameter(mixed $parameter, InputInterface $input, OutputInterface $output)
{
if ($input->getOption($parameter['key'])) {
return $input->getOption($parameter['key']);
Expand Down
7 changes: 4 additions & 3 deletions src/Entity/AbstractORMEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
use Doctrine\ORM\Mapping as ORM;
use Gpupo\Common\Traits\PropertyAccessorsTrait;

/**
* @ORM\MappedSuperclass
*/
#[ORM\MappedSuperclass]
abstract class AbstractORMEntity implements CollectionInterface
{
use PropertyAccessorsTrait;

#[\Override]
public function toJson(string $route = null, int $options = 0, int $depth = 512): string
{
return '';
}

#[\Override]
public function toLog(): array
{
return [];
}

#[\Override]
public function toArray(): array
{
return [];
Expand Down
47 changes: 21 additions & 26 deletions src/Entity/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,29 @@
* Minimal/modified Based version of the object Doctrine\Common\Collections\ArrayCollection
* For more information, see <http://www.doctrine-project.org>.
*/
class ArrayCollection implements Countable, IteratorAggregate, ArrayAccess
class ArrayCollection implements Countable, IteratorAggregate, ArrayAccess, \Stringable
{
/**
* An array containing the entries of this collection.
*
* @var array
*/
private $elements = [];

/**
* Initializes a new ArrayCollection.
*/
public function __construct(array $elements = [])
public function __construct(
/**
* An array containing the entries of this collection.
*/
private array $elements = []
)
{
$this->elements = $elements;
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function __toString()
#[\Override]
public function __toString(): string
{
return __CLASS__.'@'.spl_object_hash($this);
return self::class.'@'.spl_object_hash($this);
}

public function toArray()
Expand Down Expand Up @@ -104,31 +102,27 @@ public function removeElement($element)

/**
* Required by interface ArrayAccess.
*
* @param mixed $offset
*/
public function offsetExists($offset)
#[\Override]
public function offsetExists(mixed $offset)
{
return $this->containsKey($offset);
}

/**
* Required by interface ArrayAccess.
*
* @param mixed $offset
*/
public function offsetGet($offset)
#[\Override]
public function offsetGet(mixed $offset)
{
return $this->get($offset);
}

/**
* Required by interface ArrayAccess.
*
* @param mixed $offset
* @param mixed $value
*/
public function offsetSet($offset, $value): void
#[\Override]
public function offsetSet(mixed $offset, mixed $value): void
{
if (!isset($offset)) {
$this->add($value);
Expand All @@ -139,10 +133,9 @@ public function offsetSet($offset, $value): void

/**
* Required by interface ArrayAccess.
*
* @param mixed $offset
*/
public function offsetUnset($offset)
#[\Override]
public function offsetUnset(mixed $offset)
{
return $this->remove($offset);
}
Expand Down Expand Up @@ -179,7 +172,7 @@ public function indexOf($element)

public function get($key)
{
return isset($this->elements[$key]) ? $this->elements[$key] : null;
return $this->elements[$key] ?? null;
}

public function getKeys()
Expand All @@ -192,6 +185,7 @@ public function getValues()
return array_values($this->elements);
}

#[\Override]
public function count()
{
return \count($this->elements);
Expand All @@ -217,6 +211,7 @@ public function isEmpty()
/**
* Required by interface IteratorAggregate.
*/
#[\Override]
public function getIterator()
{
return new ArrayIterator($this->elements);
Expand Down
17 changes: 15 additions & 2 deletions tests/TestCaseAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@

namespace Gpupo\Common\Tests;

use Gpupo\CommonDev\Traits\TestCaseTrait;
use PHPUnit\Framework\TestCase;

abstract class TestCaseAbstract extends TestCase
{
use TestCaseTrait;
protected function getConstant($name, $default = false)
{
if (\defined($name)) {
return \constant($name);
}

return $default;
}

protected function hasConstant($name)
{
$value = $this->getConstant($name);

return empty($value) ? false : true;
}
}

0 comments on commit c505bc5

Please sign in to comment.