riesenia / pohoda

XML generator a parser pre Pohodu
34 stars 30 forks source link

OptionsResolver: Argument #3 ($subject) must be of type array|string, float given #23

Closed morvy closed 3 years ago

morvy commented 3 years ago

Zdravim,

pri vytvarani objednavky mi vyskakuje tato chyba:

local.ERROR: preg_replace(): Argument #3 ($subject) must be of type array|string, float given
   {"exception":"[object] (TypeError(code: 0): preg_replace():
   Argument #3 ($subject) must be of type array|string, float given at vendor\\Riesenia\\pohoda\\src\\Pohoda\\Common\\OptionsResolver.php:94)
[stacktrace]
#0 vendor\\Riesenia\\pohoda\\src\\Pohoda\\Common\\OptionsResolver.php(94): preg_replace()
#1 vendor\\symfony\\options-resolver\\OptionsResolver.php(1122): Riesenia\\Pohoda\\Common\\OptionsResolver->Riesenia\\Pohoda\\Common\\{closure}()
#2 vendor\\symfony\\options-resolver\\OptionsResolver.php(910): Symfony\\Component\\OptionsResolver\\OptionsResolver->offsetGet()
#3 vendor\\Riesenia\\pohoda\\src\\Pohoda\\Agenda.php(225): Symfony\\Component\\OptionsResolver\\OptionsResolver->resolve()
#4 vendor\\Riesenia\\pohoda\\src\\Pohoda\\Agenda.php(52): Riesenia\\Pohoda\\Agenda->_resolveOptions()
#5 vendor\\Riesenia\\pohoda\\src\\Pohoda\\Order\\Item.php(36): Riesenia\\Pohoda\\Agenda->__construct()
#6 vendor\\Riesenia\\pohoda\\src\\Pohoda\\Order.php(54): Riesenia\\Pohoda\\Order\\Item->__construct()
#7 app\\Services\\PohodaOrderService.php(47): Riesenia\\Pohoda\\Order->addItem()

Sposobuje to $item['quantity'] = 1 a $item['delivered'] = 0 co nedava zmysel, nakolko sa predsa jedna o int resp. float a nechapem preco to ocakava string. Order pritom pri oboch ma normalizer nastaveny na float.

segy commented 3 years ago

Zdravim. Skuste mozno konkretny priklad, resp. spravte spec, na ktorej to padne. Lebo v spec/Pohoda/OrderSpec.php je quantity aj delivered presne tak, ako pisete. Cize tam dovod asi nebude.

morvy commented 3 years ago

Ku quantity a delivered som dospel vylucovacou metodou, nakolko na serveri, kde skript bezi nemam moznost spustit xdebug a na lokalke mi vsetko funguje normalne. Postupne som odmazaval vsetky pridavane polozky v poli pre addItem() kym chyba nezmizla.

Skusal som (int) $item->quantity aj (float) $item->quantity a obe mi hodili chybu (int given resp. float given). Ak to zmenim na (string) $item->quantity tak to zbehne OK. $item->quantity je standardne typu integer.

Medzicasom som ale prisiel na to, ze na serveri bezi PHP 8.0.1 zatial co na lokalke mam stale PHP 7.4.14, takze sa pravdepodobne jedna o problem s kompatibilitou s PHP 8.

segy commented 3 years ago

Potvrdzujem - je to problem na PHP 8.

segy commented 3 years ago

fixnute v 1.6.2