-
Notifications
You must be signed in to change notification settings - Fork 10
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
Throws a validation exception now if attempting to cast an object to string #42
Conversation
I can see this is due to a undocumented BC breakage with PHP 7.4 where previously it would throw an instance of I believe that the correct solution is that it should expect to catch Let me see if I can get acceptance for dropping support for PHP 5. |
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.
Hey @ronnied ,
Where this PR is for compatibility with PHP 7.4, can you also modify .travis.yml
to add PHP 7.4 to be tested, and modify composer.json
to remove the upper cap on PHP versions? (I.e. change the version constraint from >=7.1.0 <7.4.0
to >=7.1.0
.)
src/Fields/StringField.php
Outdated
try { | ||
if (is_object($val)) { | ||
throw $this->getValidationException('Could not cast object to string', $val); | ||
} | ||
$val = (string) $val; | ||
} catch (\Exception $e) { |
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 latest set of changes in frictionlessdata:master
drop support for PHP 5.6.
With support for 5.6 dropped, I believe a better correction for PHP 7.4 will the following.
try { | |
if (is_object($val)) { | |
throw $this->getValidationException('Could not cast object to string', $val); | |
} | |
$val = (string) $val; | |
} catch (\Exception $e) { | |
try { | |
$val = (string) $val; | |
} catch (\Throwable $e) { |
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.
Done.
…e to StringField class.
Overview
PHP 7.4 was failing unit tests (PHPUnit v4.8.36).
Please preserve this line to notify @courtney-miles (lead of this repository)