1. Go to this page and download the library: Download magicsunday/jsonmapper 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/ */
/**
* @MagicSunday\JsonMapper\Annotation\ReplaceProperty("type", replaces="crypticTypeNameProperty")
*/
class FooClass
{
/**
* @var string
*/
public $type;
}
use \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use \Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use \Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use \Symfony\Component\PropertyAccess\PropertyAccessor;
$listExtractors = [ new ReflectionExtractor() ];
$typeExtractors = [ new PhpDocExtractor() ];
$propertyInfoExtractor = new PropertyInfoExtractor($listExtractors, $typeExtractors);
/**
* Returns an instance of the JsonMapper for testing.
*
* @param string[]|Closure[] $classMap A class map to override the class names
*
* @return \MagicSunday\JsonMapper
*/
protected function getJsonMapper(array $classMap = []): \MagicSunday\JsonMapper
{
$listExtractors = [ new ReflectionExtractor() ];
$typeExtractors = [ new PhpDocExtractor() ];
$extractor = new PropertyInfoExtractor($listExtractors, $typeExtractors);
return new \MagicSunday\JsonMapper(
$extractor,
PropertyAccess::createPropertyAccessor(),
new CamelCasePropertyNameConverter(),
$classMap
);
}