Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ env:
- DEPENDENCIES='beta'

php:
- 7.0
- 7.1
- 7.2
- 7.4

install:
- if [[ $DEPENDENCIES = 'beta' ]]; then composer config minimum-stability beta; fi
Expand Down
6 changes: 3 additions & 3 deletions src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,23 @@ public function validateCollectionIsEmpty(string $name)
*/
public function printCollectionJsonSchema(string $name)
{
echo json_encode($this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => true, 'root' => true]), JSON_PRETTY_PRINT);
echo json_encode($this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => true, 'root' => true]), \JSON_PRETTY_PRINT);
}

/**
* @Then /^print (?P<name>[\w\-]+) item JSON schema$/
*/
public function printItemJsonSchema(string $name)
{
echo json_encode($this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => false, 'root' => true]), JSON_PRETTY_PRINT);
echo json_encode($this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => false, 'root' => true]), \JSON_PRETTY_PRINT);
}

/**
* @Then /^print last JSON request$/
*/
public function printJsonData()
{
echo json_encode($this->lastRequestJson, JSON_PRETTY_PRINT);
echo json_encode($this->lastRequestJson, \JSON_PRETTY_PRINT);
}

private function findObject(string $name, $value)
Expand Down
8 changes: 4 additions & 4 deletions src/Populator/Populator.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getObject(\ReflectionClass $reflectionClass, array $values = [])
foreach (array_merge($classMetadata->getFieldNames(), $classMetadata->getAssociationNames()) as $property) {
$mapping = $this->getMapping($classMetadata, $property);
// Property is already filled, or is not required, or a primary key (except for association primary key)
if (array_key_exists($property, $values) || $mapping['nullable'] || ($classMetadata->isIdentifier($property) && $classMetadata->hasField($property))) {
if (\array_key_exists($property, $values) || $mapping['nullable'] || ($classMetadata->isIdentifier($property) && $classMetadata->hasField($property))) {
continue;
}
if ($reflectionClass->hasProperty($property)) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public function getRequestData(\ReflectionClass $reflectionClass, string $operat
/** @var ClassMetadataInfo $classMetadata */
$classMetadata = $this->registry->getManagerForClass($className)->getClassMetadata($className);
foreach ($this->propertyInfo->getProperties($className, $groups ? ['serializer_groups' => $groups] : []) as $property) {
if (!$reflectionClass->hasProperty($property) || !$this->isRequired($reflectionClass->getProperty($property), $validationGroups) || array_key_exists($property, $values) || ('put' === $operation && 0 < \count($originalValues))) {
if (!$reflectionClass->hasProperty($property) || !$this->isRequired($reflectionClass->getProperty($property), $validationGroups) || \array_key_exists($property, $values) || ('put' === $operation && 0 < \count($originalValues))) {
continue;
}
$values[$property] = $this->guesser->getValue($this->getMapping($classMetadata, $property));
Expand Down Expand Up @@ -182,7 +182,7 @@ public function getMapping(ClassMetadataInfo $classMetadata, string $property):
$this->mapping[$className][$fieldName] = $classMetadata->getFieldMapping($fieldName);
}
foreach ($this->propertyInfo->getProperties($className) as $fieldName) {
if (array_key_exists($fieldName, $this->mapping[$className])) {
if (\array_key_exists($fieldName, $this->mapping[$className])) {
continue;
}

Expand Down Expand Up @@ -246,6 +246,6 @@ private function filterOperations(array $operations, string $operation): array
{
return array_filter($operations, function ($value, $key) use ($operation) {
return $operation === (\is_int($key) ? $value : $key);
}, ARRAY_FILTER_USE_BOTH);
}, \ARRAY_FILTER_USE_BOTH);
}
}
2 changes: 1 addition & 1 deletion src/SchemaGenerator/ObjectSchemaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function generate(\ReflectionClass $reflectionClass, array $context = [])
$context['depth'] = 0;
}
if ($context['depth'] > self::MAX_DEPTH) {
throw new MaxDepthException(sprintf('Maximum depth of %d has been reached. This could be caused by a circular reference due to serialization groups.%sPath: %s', self::MAX_DEPTH, PHP_EOL, implode('->', $this->path)));
throw new MaxDepthException(sprintf('Maximum depth of %d has been reached. This could be caused by a circular reference due to serialization groups.%sPath: %s', self::MAX_DEPTH, \PHP_EOL, implode('->', $this->path)));
}
++$context['depth'];
$className = $reflectionClass->name;
Expand Down
4 changes: 2 additions & 2 deletions src/Transformer/EntityTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public function toObject(array $mapping, $value)
break;
case Type::GUID:
// Support for PostgreSQL native type
if (!\preg_match('/^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/', (string) $value)) {
if (!preg_match('/^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/', (string) $value)) {
$type = 'invalid';
}
break;
case Type::DATE:
case Type::DATETIME:
case Type::DATETIMETZ:
// Support for PostgreSQL native type
if (!\preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/', (string) $value)) {
if (!preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/', (string) $value)) {
$type = 'invalid';
}
break;
Expand Down