Exceptions
Exceptions 2
Symfony\Component\PropertyAccess\Exception\ InvalidArgumentException
in
vendor/symfony/property-access/PropertyAccessor.php
(line 268)
$pos += \strlen($delim);
$j = strpos($message, ',', $pos);
$type = substr($message, 2 + $j, strpos($message, ' given', $j) - $j - 2);
$message = substr($message, $pos, $j - $pos);
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given at property path "%s".', $message, 'NULL' === $type ? 'null' : $type, $propertyPath), 0, $previous);
}
if (preg_match('/^\S+::\S+\(\): Argument #\d+ \(\$\S+\) must be of type (\S+), (\S+) given/', $message, $matches)) {
[, $expectedType, $actualType] = $matches;
in
vendor/symfony/property-access/PropertyAccessor.php
::
throwInvalidArgumentException
(line 179)
try {
$this->writeProperty($zval, $propertyPath, $value);
return;
} catch (\TypeError $e) {
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $propertyPath, $e);
// It wasn't thrown in this class so rethrow it
throw $e;
}
}
in
vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php
->
setValue
(line 69)
}
// If the data is identical to the value in $data, we are
// dealing with a reference
if (!\is_object($data) || !$form->getConfig()->getByReference() || $propertyValue !== $this->getPropertyValue($data, $propertyPath)) {
$this->propertyAccessor->setValue($data, $propertyPath, $propertyValue);
}
}
/**
* {@inheritdoc}
in
vendor/symfony/form/Extension/Core/DataAccessor/ChainAccessor.php
->
setValue
(line 54)
*/
public function setValue(&$data, $value, FormInterface $form): void
{
foreach ($this->accessors as $accessor) {
if ($accessor->isWritable($data, $form)) {
$accessor->setValue($data, $value, $form);
return;
}
}
in
vendor/symfony/form/Extension/Core/DataMapper/DataMapper.php
->
setValue
(line 87)
$config = $form->getConfig();
// Write-back is disabled if the form is not synchronized (transformation failed),
// if the form was not submitted and if the form is disabled (modification not allowed)
if ($config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled() && $this->dataAccessor->isWritable($data, $form)) {
$this->dataAccessor->setValue($data, $form->getData(), $form);
}
}
}
}
in
vendor/symfony/form/Form.php
->
mapFormsToData
(line 642)
// Use InheritDataAwareIterator to process children of
// descendants that inherit this form's data.
// These descendants will not be submitted normally (see the check
// for $this->config->getInheritData() above)
$this->config->getDataMapper()->mapFormsToData(
new \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)),
$viewData
);
}
// Normalize data to unified representation
in
vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php
->
submit
(line 110)
// Don't auto-submit the form unless at least one field is present.
if ('' === $name && \count(array_intersect_key($data, $form->all())) <= 0) {
return;
}
$form->submit($data, 'PATCH' !== $method);
}
/**
* {@inheritdoc}
*/
in
vendor/symfony/form/Form.php
->
handleRequest
(line 503)
/**
* {@inheritdoc}
*/
public function handleRequest($request = null)
{
$this->config->getRequestHandler()->handleRequest($this, $request);
return $this;
}
/**
protected function doEdit(Project $project, Request $request, EntityManagerInterface $em, Batch $batch): Response
{
$title = $project->getId() ? '编辑' : '提交材料';
$form = $this->createForm(ProjectType::class, $project);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($project);
$em->flush();
$this->addFlash('notice', '操作成功');
* @Route("edit/{id}", name="edit", requirements={"id"="\d+"})
*/
public function edit(Request $request, EntityManagerInterface $em, Project $project): Response
{
$this->denyAccessUnlessGranted(ProjectVoter::APPLICANT_EDIT, $project);
return $this->doEdit($project, $request, $em, $project->getBatch());
}
/**
*
* @Route("delete/{id}", name="delete", requirements={"id"="\d+"})
in
vendor/symfony/http-kernel/HttpKernel.php
->
edit
(line 163)
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
in
vendor/symfony/http-kernel/HttpKernel.php
->
handleRaw
(line 75)
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
in
vendor/symfony/http-kernel/Kernel.php
->
handle
(line 202)
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
in
vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php
->
handle
(line 35)
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
in
vendor/autoload_runtime.php
->
run
(line 35)
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
TypeError
in
src/Entity/Traits/NameMethodTrait.php
(line 16)
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
public function __toString(): string
in
vendor/symfony/property-access/PropertyAccessor.php
->
setName
(line 591)
if (PropertyWriteInfo::TYPE_NONE !== $mutator->getType()) {
$type = $mutator->getType();
if (PropertyWriteInfo::TYPE_METHOD === $type) {
$object->{$mutator->getName()}($value);
} elseif (PropertyWriteInfo::TYPE_PROPERTY === $type) {
$object->{$mutator->getName()} = $value;
} elseif (PropertyWriteInfo::TYPE_ADDER_AND_REMOVER === $type) {
$this->writeCollection($zval, $property, $value, $mutator->getAdderInfo(), $mutator->getRemoverInfo());
}
in
vendor/symfony/property-access/PropertyAccessor.php
->
writeProperty
(line 175)
$zval = [
self::VALUE => $objectOrArray,
];
try {
$this->writeProperty($zval, $propertyPath, $value);
return;
} catch (\TypeError $e) {
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $propertyPath, $e);
// It wasn't thrown in this class so rethrow it
in
vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php
->
setValue
(line 69)
}
// If the data is identical to the value in $data, we are
// dealing with a reference
if (!\is_object($data) || !$form->getConfig()->getByReference() || $propertyValue !== $this->getPropertyValue($data, $propertyPath)) {
$this->propertyAccessor->setValue($data, $propertyPath, $propertyValue);
}
}
/**
* {@inheritdoc}
in
vendor/symfony/form/Extension/Core/DataAccessor/ChainAccessor.php
->
setValue
(line 54)
*/
public function setValue(&$data, $value, FormInterface $form): void
{
foreach ($this->accessors as $accessor) {
if ($accessor->isWritable($data, $form)) {
$accessor->setValue($data, $value, $form);
return;
}
}
in
vendor/symfony/form/Extension/Core/DataMapper/DataMapper.php
->
setValue
(line 87)
$config = $form->getConfig();
// Write-back is disabled if the form is not synchronized (transformation failed),
// if the form was not submitted and if the form is disabled (modification not allowed)
if ($config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled() && $this->dataAccessor->isWritable($data, $form)) {
$this->dataAccessor->setValue($data, $form->getData(), $form);
}
}
}
}
in
vendor/symfony/form/Form.php
->
mapFormsToData
(line 642)
// Use InheritDataAwareIterator to process children of
// descendants that inherit this form's data.
// These descendants will not be submitted normally (see the check
// for $this->config->getInheritData() above)
$this->config->getDataMapper()->mapFormsToData(
new \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)),
$viewData
);
}
// Normalize data to unified representation
in
vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php
->
submit
(line 110)
// Don't auto-submit the form unless at least one field is present.
if ('' === $name && \count(array_intersect_key($data, $form->all())) <= 0) {
return;
}
$form->submit($data, 'PATCH' !== $method);
}
/**
* {@inheritdoc}
*/
in
vendor/symfony/form/Form.php
->
handleRequest
(line 503)
/**
* {@inheritdoc}
*/
public function handleRequest($request = null)
{
$this->config->getRequestHandler()->handleRequest($this, $request);
return $this;
}
/**
protected function doEdit(Project $project, Request $request, EntityManagerInterface $em, Batch $batch): Response
{
$title = $project->getId() ? '编辑' : '提交材料';
$form = $this->createForm(ProjectType::class, $project);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($project);
$em->flush();
$this->addFlash('notice', '操作成功');
* @Route("edit/{id}", name="edit", requirements={"id"="\d+"})
*/
public function edit(Request $request, EntityManagerInterface $em, Project $project): Response
{
$this->denyAccessUnlessGranted(ProjectVoter::APPLICANT_EDIT, $project);
return $this->doEdit($project, $request, $em, $project->getBatch());
}
/**
*
* @Route("delete/{id}", name="delete", requirements={"id"="\d+"})
in
vendor/symfony/http-kernel/HttpKernel.php
->
edit
(line 163)
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
in
vendor/symfony/http-kernel/HttpKernel.php
->
handleRaw
(line 75)
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
in
vendor/symfony/http-kernel/Kernel.php
->
handle
(line 202)
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
in
vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php
->
handle
(line 35)
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
in
vendor/autoload_runtime.php
->
run
(line 35)
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
Stack Traces 2
[2/2]
InvalidArgumentException
|
---|
Symfony\Component\PropertyAccess\Exception\InvalidArgumentException: Expected argument of type "string", "null" given at property path "name". at vendor/symfony/property-access/PropertyAccessor.php:268 at Symfony\Component\PropertyAccess\PropertyAccessor::throwInvalidArgumentException() (vendor/symfony/property-access/PropertyAccessor.php:179) at Symfony\Component\PropertyAccess\PropertyAccessor->setValue() (vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php:69) at Symfony\Component\Form\Extension\Core\DataAccessor\PropertyPathAccessor->setValue() (vendor/symfony/form/Extension/Core/DataAccessor/ChainAccessor.php:54) at Symfony\Component\Form\Extension\Core\DataAccessor\ChainAccessor->setValue() (vendor/symfony/form/Extension/Core/DataMapper/DataMapper.php:87) at Symfony\Component\Form\Extension\Core\DataMapper\DataMapper->mapFormsToData() (vendor/symfony/form/Form.php:642) at Symfony\Component\Form\Form->submit() (vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php:110) at Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler->handleRequest() (vendor/symfony/form/Form.php:503) at Symfony\Component\Form\Form->handleRequest() (src/Controller/Applicant/ProjectController.php:119) at App\Controller\Applicant\ProjectController->doEdit() (src/Controller/Applicant/ProjectController.php:64) at App\Controller\Applicant\ProjectController->edit() (vendor/symfony/http-kernel/HttpKernel.php:163) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:75) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:202) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:35) at require_once('/home/projects/pms/vendor/autoload_runtime.php') (public/index.php:5) |
[1/2]
TypeError
|
---|
TypeError: Argument 1 passed to App\Entity\Project::setName() must be of the type string, null given, called in /home/projects/pms/vendor/symfony/property-access/PropertyAccessor.php on line 591 at src/Entity/Traits/NameMethodTrait.php:16 at App\Entity\Project->setName() (vendor/symfony/property-access/PropertyAccessor.php:591) at Symfony\Component\PropertyAccess\PropertyAccessor->writeProperty() (vendor/symfony/property-access/PropertyAccessor.php:175) at Symfony\Component\PropertyAccess\PropertyAccessor->setValue() (vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php:69) at Symfony\Component\Form\Extension\Core\DataAccessor\PropertyPathAccessor->setValue() (vendor/symfony/form/Extension/Core/DataAccessor/ChainAccessor.php:54) at Symfony\Component\Form\Extension\Core\DataAccessor\ChainAccessor->setValue() (vendor/symfony/form/Extension/Core/DataMapper/DataMapper.php:87) at Symfony\Component\Form\Extension\Core\DataMapper\DataMapper->mapFormsToData() (vendor/symfony/form/Form.php:642) at Symfony\Component\Form\Form->submit() (vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php:110) at Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler->handleRequest() (vendor/symfony/form/Form.php:503) at Symfony\Component\Form\Form->handleRequest() (src/Controller/Applicant/ProjectController.php:119) at App\Controller\Applicant\ProjectController->doEdit() (src/Controller/Applicant/ProjectController.php:64) at App\Controller\Applicant\ProjectController->edit() (vendor/symfony/http-kernel/HttpKernel.php:163) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:75) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:202) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:35) at require_once('/home/projects/pms/vendor/autoload_runtime.php') (public/index.php:5) |