Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.4 throwing offset syntax with curly braces is deprecated message #2558

Closed
remorhaz opened this issue Jul 20, 2019 · 12 comments · Fixed by #2560
Closed

PHP 7.4 throwing offset syntax with curly braces is deprecated message #2558

remorhaz opened this issue Jul 20, 2019 · 12 comments · Fixed by #2560

Comments

@remorhaz
Copy link

remorhaz commented Jul 20, 2019

Hello!

if ($arg{0} === '-') {

Current version of PHP 7.4 (PHP 7.4.0-dev (cli) (built: Jul 19 2019 10:22:49) ( ZTS )) considers practice of using curly braces to address offset of a string/array as deprecated. PHPCS still works okay now but emits warnings:

Deprecated: Array and string offset access syntax with curly braces is deprecated in /my-project-path/vendor/squizlabs/php_codesniffer/src/Config.php on line 420

Changing brackets to square ones in src/Config.php should solve the problem.

@gsherwood gsherwood added this to Backlog in PHPCS v3 Development via automation Jul 24, 2019
@gsherwood gsherwood added this to the 3.5.0 milestone Jul 24, 2019
@gsherwood gsherwood changed the title PHP 7.4: offset syntax with curly braces is deprecated PHP 7.4 throwing offset syntax with curly braces is deprecated message Jul 24, 2019
PHPCS v3 Development automation moved this from Backlog to Ready for Release Jul 24, 2019
gsherwood added a commit that referenced this issue Jul 24, 2019
@neomerx
Copy link

neomerx commented Feb 9, 2020

The problem exists for squizlabs/php_codesniffer 2.9.2 on PHP 7.4.2

PHP Deprecated: Array and string offset access syntax with curly braces is deprecated

  • squizlabs/php_codesniffer/CodeSniffer.php on line 2028
  • squizlabs/php_codesniffer/CodeSniffer.php on line 2033
  • squizlabs/php_codesniffer/CodeSniffer.php on line 2079

I've made a few changes locally and those warnings disappear.

@jrfnl
Copy link
Contributor

jrfnl commented Feb 9, 2020

@neomerx PHPCS 2.9.2 was the last release in the PHPCS 2.x series and AFAIK there will be no further updates.

Please upgrade to PHPCS 3.5.0 or higher for compatibility with PHP 7.4 or to PHPCS 3.5.4 (or higher once released) for support in sniffs for PHP 7.4 syntaxes.

@neomerx
Copy link

neomerx commented Feb 10, 2020

@jrfnl That's a very easy fix and if you're OK to accept a PR I will send it.

As for upgrade to v3 it's not a great option for me because of #1908 so I have to wait for v4.

@jrfnl
Copy link
Contributor

jrfnl commented Feb 10, 2020

That's a very easy fix and if you're OK to accept a PR I will send it.

Not up to me, but I very much doubt it would be accepted.

As for upgrade to v3 it's not a great option for me because of #1908 so I have to wait for v4.

To be honest, that should not be a reason not to upgrade. More than anything, that's an IDE configuration issue and if I remember correctly, the thread already contains info on how to get round it.

@neomerx
Copy link

neomerx commented Feb 10, 2020

Thanks for the answer. You do underestimate how painful those true(),false(),null() and etc in global namespace. But thanks for the support. I'm currently sticking to v2 until v4 is available and probably just fork and fix v2 until v4.

@jrfnl
Copy link
Contributor

jrfnl commented Feb 10, 2020

@neomerx What's stopping you from configuring your IDE correctly to ignore the vendor/squizlabs folder for the purposes of autocompletion ?

@neomerx
Copy link

neomerx commented Feb 10, 2020

Many projects. It's easier to not to upgrade. Also, it would mean sorta accepting global namespace pollution.

@mkhandal
Copy link

Where Excel file import in codeigniter, the problem exists for phpexcel 1.8.0 on PHP 7

A PHP Error was encountered
Severity: 8192

Message: Array and string offset access syntax with curly braces is deprecated

Filename: Shared/String.php

Line Number: 529

Backtrace:

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 82
Function: _error_handler

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 82
Function: require

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 36
Function: spl_autoload_call

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel.php
Line: 6
Function: require

File: /opt/lampp/htdocs/example/application/controllers/Flats.php
Line: 4
Function: require_once

File: /opt/lampp/htdocs/example/index.php
Line: 318
Function: require_once

@ravinegi17
Copy link

Where Excel file import in codeigniter, the problem exists for phpexcel 1.8.0 on PHP 7

A PHP Error was encountered
Severity: 8192

Message: Array and string offset access syntax with curly braces is deprecated

Filename: Shared/String.php

Line Number: 529

Backtrace:

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 82
Function: _error_handler

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 82
Function: require

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel/Autoloader.php
Line: 36
Function: spl_autoload_call

File: /opt/lampp/htdocs/example/application/third_party/PHPExcel.php
Line: 6
Function: require

File: /opt/lampp/htdocs/example/application/controllers/Flats.php
Line: 4
Function: require_once

File: /opt/lampp/htdocs/example/index.php
Line: 318
Function: require_once

hi did you find the solution..if yes pls provide me I am unable to export the data in excel format it showing error same of deprecated

@jrfnl
Copy link
Contributor

jrfnl commented Jul 15, 2021

@ravinegi007 You're asking in the wrong repo about a project which is no longer maintained and has been replaced.
https://github.com/PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PHPExcel

@joyantabd
Copy link

@ilanh
Copy link

ilanh commented Oct 25, 2022

If you get this error and you installed via composer, chances are that you have v2 installed,
verify with:
phpcs --version

Try to run:
composer global require "squizlabs/php_codesniffer=3.*"
For me the problem was missing php-xml extension,
squizlabs/php_codesniffer[3.0.0, ..., 3.7.1] require ext-xmlwriter * -> it is missing from your system. Install or enable PHP's xmlwriter extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging a pull request may close this issue.

8 participants