if ( !is_null( $datum ) ) {
return self::wrongType( 'null', $datum );
}
- return array();
+ return [];
case AvroSchema::BOOLEAN_TYPE:
if ( !is_bool( $datum ) ) {
return self::wrongType( 'boolean', $datum );
}
- return array();
+ return [];
case AvroSchema::STRING_TYPE:
case AvroSchema::BYTES_TYPE:
if ( !is_string( $datum ) ) {
return self::wrongType( 'string', $datum );
}
- return array();
+ return [];
case AvroSchema::INT_TYPE:
if ( !is_int( $datum ) ) {
return self::wrongType( 'integer', $datum );
$datum
);
}
- return array();
+ return [];
case AvroSchema::LONG_TYPE:
if ( !is_int( $datum ) ) {
return self::wrongType( 'integer', $datum );
$datum
);
}
- return array();
+ return [];
case AvroSchema::FLOAT_TYPE:
case AvroSchema::DOUBLE_TYPE:
if ( !is_float( $datum ) && !is_int( $datum ) ) {
return self::wrongType( 'float or integer', $datum );
}
- return array();
+ return [];
case AvroSchema::ARRAY_SCHEMA:
if ( !is_array( $datum ) ) {
return self::wrongType( 'array', $datum );
}
- $errors = array();
+ $errors = [];
foreach ( $datum as $d ) {
$result = self::getErrors( $schema->items(), $d );
if ( $result ) {
if ( !is_array( $datum ) ) {
return self::wrongType( 'array', $datum );
}
- $errors = array();
+ $errors = [];
foreach ( $datum as $k => $v ) {
if ( !is_string( $k ) ) {
$errors[] = self::wrongType( 'string key', $k );
}
return $errors;
case AvroSchema::UNION_SCHEMA:
- $errors = array();
+ $errors = [];
foreach ( $schema->schemas() as $schema ) {
$result = self::getErrors( $schema, $datum );
if ( !$result ) {
- return array();
+ return [];
}
$errors[] = $result;
}
if ( $errors ) {
- return array( "Expected any one of these to be true", $errors );
+ return [ "Expected any one of these to be true", $errors ];
}
return "No schemas provided to union";
case AvroSchema::ENUM_SCHEMA:
$symbols = implode( ', ', $schema->symbols );
return "Expected one of $symbols but recieved $datum";
}
- return array();
+ return [];
case AvroSchema::FIXED_SCHEMA:
if ( !is_string( $datum ) ) {
return self::wrongType( 'string', $datum );
return "Expected string of length {$schema->size()}, "
. "but recieved one of length $len";
}
- return array();
+ return [];
case AvroSchema::RECORD_SCHEMA:
case AvroSchema::ERROR_SCHEMA:
case AvroSchema::REQUEST_SCHEMA:
if ( !is_array( $datum ) ) {
return self::wrongType( 'array', $datum );
}
- $errors = array();
+ $errors = [];
foreach ( $schema->fields() as $field ) {
$name = $field->name();
if ( !array_key_exists( $name, $datum ) ) {