-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
type checking exception raised in php8 #38
Conversation
A tiny adjustment in order to be able to execute the package in php8 |
Codecov Report
@@ Coverage Diff @@
## develop #38 +/- ##
==========================================
Coverage 97.45% 97.45%
Complexity 121 121
==========================================
Files 5 5
Lines 275 275
==========================================
Hits 268 268
Misses 7 7
Continue to review full report at Codecov.
|
@@ -251,15 +251,15 @@ private function getInternArrayOffset(): int | |||
* @param bool $internCall indicates that methods is calling itself | |||
* @return AbstractStructArrayBase | |||
*/ | |||
private function initInternArray(array $array = [], bool $internCall = false): self | |||
private function initInternArray($array = [], bool $internCall = false): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not supposed to be anything else than an array if the class inheriting from it is defined as expected. To be discusssed within the WsdlToPhp/PackageGenerator#248 issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As can be seen below, the generated class (ArrayDadosFuncionais) is a child (extends) of AbstractStructArrayBase This class (ArrayDadosFuncionais) when initialized, calls the function initInternArray with no parameters, which in turn calls the same function again with $this->getPropertyValue($this->getAttributeName()) as the first parameter. This parameter is resolved (please, see the code below) in the "dadosFuncionais" which is typed as \SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayOfDadosFuncionais (other generated class).
The attribute $dadosFuncionais, typed as ArrayOfDadosFuncionais, extends AbstractStructArrayBase, which in turn implements StructArrayInterface (StructInterface, ArrayAccess, Iterator, Traversable, Countable, iterable), StructInterface, JsonSerializable.
And when this occurs this exceptions is raised:
WsdlToPhp\PackageBase\AbstractStructArrayBase::initInternArray(): Argument #1 ($array) must be of type array, SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayOfDadosFuncionais given, called in /app/vendor/wsdltophp/packagebase/src/AbstractStructArrayBase.php on line 262
namespace SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ServiceType;
use SoapFault;`
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosBancarios;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosDDP;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosDependentes;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosFuncionais;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosPA;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosRepresentanteLegal;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosSICAJ as ArrayDadosSICAJAlias;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayDadosUorg;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayOfArrayDadosAfastamento;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayOfArrayDadosFinanceiros;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayPensaoRecebida;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayPensoesInstituidas;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\ArrayDadosAfastamento;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\ArrayDadosFinanceiros;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\DadosCurriculo;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\DadosDocumentacao;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\DadosEnderecoResidencial;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\DadosEscolares;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\DadosPessoais;
use SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\StructType\TotalVagasOrgao;
use \WsdlToPhp\PackageBase\AbstractSoapClientBase;
/**
-
This class stands for Consulta ServiceType
-
@subpackage Services
*/
class Consulta extends AbstractSoapClientBase
{/**
- Method to call the operation originally named consultaDadosFuncionais
- @uses AbstractSoapClientBase::getSoapClient()
- @uses AbstractSoapClientBase::setResult()
- @uses AbstractSoapClientBase::getResult()
- @uses AbstractSoapClientBase::saveLastError()
- @param string $siglaSistema
- @param string $nomeSistema
- @param string $senha
- @param string $cpf
- @param string $codOrgao
- @param string $parmExistPag
- @param string $parmTipoVinculo
- @return ArrayDadosFuncionais|bool
*/
public function consultaDadosFuncionais(string $siglaSistema, string $nomeSistema, string $senha, string $cpf, string $codOrgao, string $parmExistPag, string $parmTipoVinculo): ArrayDadosFuncionais|bool
{
try {
$this->setResult($this->getSoapClient()->consultaDadosFuncionais($siglaSistema, $nomeSistema, $senha, $cpf, $codOrgao, $parmExistPag, $parmTipoVinculo));
return $this->getResult();
} catch (SoapFault $soapFault) {
$this->saveLastError(METHOD, $soapFault);
return false;
}
}
=============================================================
namespace SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType;
use WsdlToPhp\PackageBase\AbstractStructArrayBase;
/**
- This class stands for ArrayDadosFuncionais ArrayType
- @subpackage Arrays
/
class ArrayDadosFuncionais extends AbstractStructArrayBase
{
/*- The dadosFuncionais
- Meta information extracted from the WSDL
-
- minOccurs: 0
-
- nillable: true
- @var \SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType\ArrayOfDadosFuncionais
/
public $dadosFuncionais;
// ....
/* - Returns the attribute name
- @see AbstractStructArrayBase::getAttributeName()
- @return string dadosFuncionais
*/
public function getAttributeName():string
{
return 'dadosFuncionais';
}
=============================================================
namespace SuppCore\SigepeBackend\Integracao\DadoPessoal\Models\ArrayType;
use WsdlToPhp\PackageBase\AbstractStructArrayBase;
/**
- This class stands for ArrayOfDadosFuncionais ArrayType
- @subpackage Arrays
*/
class ArrayOfDadosFuncionais extends AbstractStructArrayBase
{
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code you pasted seems incomplete. Normally, the constructor, __construct
, has one argument which is typed as an array with an array as default value:
public function __construct(array $dadosFuncionais = array())
{
$this
->setDadosFuncionais($dadosFuncionais);
}
This initialize the property as an array which allows to right away loop on the object using foreach.
To loop through the items using foreach (or for in twig), until PackageBase:5.0, you have to first call the $instance->initInternArray();
method. In my case, it does not throw an exception.
Please paste the whole code using gist if necessary
Generated classes are children of AbstractStructArrayBase and neither they neither AbastracrStructArrayBase don’t implement ArrayObject, so the exception is raised.
Em 14 de abr. de 2021, à(s) 04:11, Mikaël DELSOL ***@***.***> escreveu:
@mikaelcom commented on this pull request.
________________________________
In src/AbstractStructArrayBase.php<#38 (comment)>:
@@ -251,15 +251,15 @@ private function getInternArrayOffset(): int
* @param bool $internCall indicates that methods is calling itself
* @return AbstractStructArrayBase
*/
- private function initInternArray(array $array = [], bool $internCall = false): self
+ private function initInternArray($array = [], bool $internCall = false): self
It's not supposed to be anything else than an array if the class inheriting from it is defined as expected. To be discusssed within the WsdlToPhp/PackageGenerator#248<WsdlToPhp/PackageGenerator#248> issue
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub<#38 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHHMQGMT6RVVGTFMC2WFHL3TIU5ZBANCNFSM424KNGPQ>.
|
PR to execute the package in PHP8.