edifact-generator icon indicating copy to clipboard operation
edifact-generator copied to clipboard

Errors running demo code

Open BemolRetail opened this issue 4 years ago • 7 comments

Dears,

I have a problem running VERMAS demo code from SAMPLES.md file. I have PHP 8.0.3. Can you please help

PHP Fatal error: Uncaught TypeError: EDI\Encoder::escapeValue(): Argument #1 ($str) must be of type string, int given, called in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php on line 134 and defined in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php:162 Stack trace: #0 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(134): EDI\Encoder->escapeValue(2) #1 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(101): EDI\Encoder->encodeSegment(Array) #2 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(77): EDI\Encoder->encode(Array, false) #3 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\rbo.php(27): EDI\Encoder->__construct(Array, false) #4 {main} thrown in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php on line 162

Fatal error: Uncaught TypeError: EDI\Encoder::escapeValue(): Argument #1 ($str) must be of type string, int given, called in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php on line 134 and defined in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php:162 Stack trace: #0 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(134): EDI\Encoder->escapeValue(2) #1 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(101): EDI\Encoder->encodeSegment(Array) #2 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php(77): EDI\Encoder->encode(Array, false) #3 C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\rbo.php(27): EDI\Encoder->__construct(Array, false) #4 {main} thrown in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\edifact-generator\vendor\sabas\edifact\src\EDI\Encoder.php on line 162

BemolRetail avatar Mar 18 '21 21:03 BemolRetail

Hello, are you using the latest version of the code or it has some changes? Because escapeValue() is on line 136 currently https://github.com/php-edifact/edifact/blob/master/src/EDI/Encoder.php

I tested the samples code right now and it is working... (although I'm on php 7.4.3 right now, guess I will upgrade :D )

Thanks, Stefano

sabas avatar Mar 18 '21 22:03 sabas

Hello,

I downgrade to PHP 7.4.16 same result. My steps:

  1. Install php
  2. install composter
  3. downloaded zip file with edifact-generator source and unpack
  4. install "php composer.phar install" using composter.json from zip file
  5. create rbo.php and copy there first sample from sample.md What am I doing wrong?

BemolRetail avatar Mar 18 '21 22:03 BemolRetail

Hi,

if I use only composer install without downloaded source I have the error

[RuntimeException] Could not scan for classes inside "src/" which does not appear to be a file nor a folder

BemolRetail avatar Mar 18 '21 23:03 BemolRetail

Hi, my workflow is downloading it directly from composer through Packagist https://packagist.org/packages/php-edifact/edifact-generator#dev-master (this pulls also the other library)

https://packagist.org/packages/sabas/edifact#dev-master

then in the file <?php require('vendor/autoload.php');

and it works

My base composer.json is

{
    "require": {
        "sabas/edifact": "dev-master",
        "php-edifact/edifact-mapping": "dev-master",
        "php-edifact/edifact-generator": "dev-master"
    },
    "require-dev": {
        "kint-php/kint": "^3.3"
    }
}

sabas avatar Mar 19 '21 08:03 sabas

Dear Stefano,

Thank you very much. After update all samples work fine (VERMAS, CODECO, COPRAR, WESTIM, COHAOR, ORDERS) except COPINO. For COPINO I have the following error : PHP Fatal error: Access level to EDI\Generator\Copino::$sender must be protected (as in class EDI\Generator\Message) or weaker in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\generator4\vendor\php-edifact\edifact-generator\src\Generator\Copino.php on line 9

Fatal error: Access level to EDI\Generator\Copino::$sender must be protected (as in class EDI\Generator\Message) or weaker in C:\0 - Dream\GDisk\000 - Work\003\019 -IATA\generator4\vendor\php-edifact\edifact-generator\src\Generator\Copino.php on line 9

BemolRetail avatar Mar 19 '21 10:03 BemolRetail

Dear Stefano,

I change in Copino class variable from private to protected and now all code works fine. Thank you.

BemolRetail avatar Mar 19 '21 21:03 BemolRetail

@BemolRetail thanks I'm glad you solved, I was away from the pc today. If you feel you may submit a pull request to fix it? :)

sabas avatar Mar 19 '21 23:03 sabas