PHP code example of amacode / property-info-override
1. Go to this page and download the library: Download amacode/property-info-override library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amacode / property-info-override example snippets
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Amacode\PropertyInfoOverride\Annotation\PropertyType;
/**
* @ORM\Entity()
*/
class TestEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* By default, bigint will be defined as string by DoctrineExtractor because it can be bigger than PHP_INT_MAX in 32-bit systems.
* But if you're sure that your bigint will always be less than PHP_INT_MAX, you can override type manually.
*
* @PropertyType(type="int")
*
* @ORM\Column(type="bigint")
*/
private $bigIntAsInt;
/**
* @ORM\Column(type="bigint")
*/
private $bigIntAsString;
}
class ClientCode
{
private PropertyInfoExtractorInterface $propertyInfoExtractor;
public function __construct(PropertyInfoExtractorInterface $propertyInfoExtractor)
{
$this->propertyInfoExtractor = $propertyInfoExtractor;
}
public function action(): void
{
$types = $this->propertyInfoExtractor->getTypes(TestEntity::class, 'bigIntAsInt');
echo $types[0]->getBuiltinType(); // int
$types = $this->propertyInfoExtractor->getTypes(TestEntity::class, 'bigIntAsString');
echo $types[0]->getBuiltinType(); // string
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.