for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
/*
* This file is part of the KleijnWeb\ApiDescriptions package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace KleijnWeb\ApiDescriptions\Description\OpenApi;
use KleijnWeb\ApiDescriptions\Description\Description;
use KleijnWeb\ApiDescriptions\Description\Factory\StandardFactory;
use KleijnWeb\ApiDescriptions\Description\OpenApi\OpenApiDescription;
use KleijnWeb\ApiDescriptions\Document\Document;
use KleijnWeb\ApiDescriptions\Document\Definition\RefResolver\RefResolver;
use KleijnWeb\ApiDescriptions\Document\Definition\Validator\DefinitionValidator;
/**
* @author John Kleijn <[email protected]>
class OpenApiFactory implements StandardFactory
{
* @var DefinitionValidator|null
private $validator;
* Repository constructor.
* @param DefinitionValidator|null $validator
public function __construct(DefinitionValidator $validator = null)
$this->validator = $validator;
}
* @param string $uri
* @param \stdClass $definition
* @return Description
public function build(string $uri, \stdClass $definition): Description
$resolver = new RefResolver($definition, $uri);
/** @var \stdClass $definition */
$description = new OpenApiDescription(new Document($uri, $definition = $resolver->resolve()));
if ($this->validator) {
$this->validator->validate($definition);
$definition
object|array
object<stdClass>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return $description;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: