Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Fatal error: Cannot redeclare iconv() during lint check #66

Closed
kenorb opened this issue Dec 11, 2017 · 1 comment
Closed

Fatal error: Cannot redeclare iconv() during lint check #66

kenorb opened this issue Dec 11, 2017 · 1 comment

Comments

@kenorb
Copy link
Contributor

kenorb commented Dec 11, 2017

Reproducible steps on empty folder:

$ composer require patchwork/utf8
  - Installing patchwork/utf8 (v1.3.1)
$ find vendor -name '*.php' -exec php -l {} ';'
No syntax errors detected in vendor/patchwork/utf8/src/Patchwork/Utf8/BestFit.php
Fatal error: Cannot redeclare iconv() in vendor//patchwork/utf8/src/Patchwork/Utf8/Bootup/iconv.php on line 21
Errors parsing vendor/patchwork/utf8/src/Patchwork/Utf8/Bootup/iconv.php
No syntax errors detected in vendor//patchwork/utf8/src/Patchwork/Utf8/Bootup/intl.php
Fatal error: Cannot redeclare mb_convert_encoding() in vendor/patchwork/utf8/src/Patchwork/Utf8/Bootup/mbstring.php on line 23
Errors parsing vendor//patchwork/utf8/src/Patchwork/Utf8/Bootup/mbstring.php
Fatal error: Cannot redeclare utf8_encode() in vendor/patchwork/utf8/src/Patchwork/Utf8/Bootup/utf8_encode.php on line 16
Errors parsing vendor//patchwork/utf8/src/Patchwork/Utf8/Bootup/utf8_encode.php
No syntax errors detected in vendor//patchwork/utf8/src/Patchwork/Utf8/Bootup.php
...
$ php --version
PHP 7.1.7 (cli) (built: Aug 20 2017 16:16:31) ( NTS )
$ php -m | grep iconv
iconv

If it's up to me, I could ignore these errors. However the project which I'm working on, we're using Jenkins CI which invokes the following Ant's base.xml file and it's scanning through all the PHP files to check for any syntax errors.

I believe the solution would be to check whether the iconv extension is already enabled, as other checks are in place in the same place for mbstring or xml. See: iconv.php, so the files can be properly invoked from the syntax checkers.

I'm using this library as per requirement from Underscore.php.

@nicolas-grekas
Copy link
Contributor

check whether the iconv extension is already enabled

that's on your side: your tool is linting the file, not the lib here (which already loads things conditionally...)

kenorb added a commit to kenorb-contrib/utf8 that referenced this issue Dec 11, 2017
kenorb added a commit to kenorb-contrib/utf8 that referenced this issue Dec 11, 2017
@kenorb kenorb mentioned this issue Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants