Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[VarDumper] add a GMP caster in order to cast GMP resources into string or integer#25237

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@Simperfit
Copy link
Contributor

QA
Branch?4.1
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#25222
LicenseMIT
Doc PRtodo

Do you want to dump that kind of resources ? Then it means that the app you are writing is doing some math... why?! :p

It quite nice the little snow that we have in the north of france right now:
img_2844

*/
class GmpCaster
{
publicstaticfunctionconvertToInt(\GMP$value):int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this is not what a VarDumper caster is.

"ext-iconv":"To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl":"To show region name in time zone dump"
"ext-intl":"To show region name in time zone dump",
"ext-gmp":"To dump GMP resources to string or integer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this does not make any sense: the VarDumper component does not provide any featureneeding gmp. It would just improve the dumping whenyour own code uses gmp. So there is no point suggesting it. It would just be spam in the suggestions

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i'll remove it

.travis.yml Outdated
echo extension = redis.so >> $INI
echo extension = memcached.so >> $INI
echo extension = mongodb.so >> $INI
echo extension = gmp.so >> $INI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

there is no gmp.so on Travis. So this is breaking the CI.

gmp is already available on Travis, as it is built as a bundled extension

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i'll remove it too

@sroze
Copy link
Contributor

It's clearly a WIP PR.@Simperfit I suggest you either addWIP to your PR title or just not open the PR yet (and enable Travis on your fork if you need the tests to run) :)

@SimperfitSimperfit changed the title[VarDumper] add a GMP caster in order to cast GMP resources into string or integer[VarDumper] [WIP] add a GMP caster in order to cast GMP resources into string or integerDec 1, 2017
@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch 3 times, most recently from2a4413b todd04bd0CompareDecember 1, 2017 10:33
*/
class GmpCaster
{
publicstaticfunctioncastInt(\GMP$value):array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

see other casters: that not their typical signature, we should use the same here also


publicstaticfunctioncastString(\GMP$value):array
{
returnarray('value' =>gmp_strval($value));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This means "value" will be displayed as if it were a public property on the object, which is wrong
should be a virtual property (see other casters)
Also: this will display the value as if it were a string, which is also a bad hint. I suggest to use a ConstStub to wrap the value, to that it is displayed in a more specific way. I invite you to compare with/without and decide.

'DateTimeZone' =>array('Symfony\Component\VarDumper\Caster\DateCaster','castTimeZone'),
'DatePeriod' =>array('Symfony\Component\VarDumper\Caster\DateCaster','castPeriod'),

'GMP' =>array('Symfony\Component\VarDumper\Caster\GmpCaster','castInt'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not all GMP object's values can be represented as strings, so castString should be the implementation

':xml' =>array('Symfony\Component\VarDumper\Caster\XmlResourceCaster','castXml'),
':gmp' =>array('Symfony\Component\VarDumper\Caster\GmpCaster','castInt'),
':gmp int' =>array('Symfony\Component\VarDumper\Caster\GmpCaster','castInt'),
':gmp string' =>array('Symfony\Component\VarDumper\Caster\GmpCaster','castString'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

GMP as resources cannot happen anymore on PHP 7.1, this should be removed.

returnarray('value' =>gmp_intval($value));
}

publicstaticfunctioncastString(\GMP$value):array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this should be renamed "castGmp"

{
publicfunctiontestCastInt()
{
if (false ===extension_loaded('gmp')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@requires extension gmp instead

EOTXT;

$this->assertStringMatchesFormat($expected,print_r($clone,true));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

let's useassertDumpEquals instead

Simperfit reacted with thumbs up emoji
@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch fromdd04bd0 to452a273CompareDecember 1, 2017 14:29
@SimperfitSimperfit changed the title[VarDumper] [WIP] add a GMP caster in order to cast GMP resources into string or integer[VarDumper] add a GMP caster in order to cast GMP resources into string or integerDec 1, 2017
@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch from452a273 to516e25dCompareDecember 1, 2017 14:34
"""
EODUMP;

$this->assertDumpEquals($expected,print_r($clone,true));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this is playing around assertDumpEquals
just$this->assertDumpEquals($expected, gmp_init('0101')); instead

@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch from516e25d to5f1f345CompareDecember 1, 2017 14:44
/**
* @requires extension gmp
*/
publicfunctiontestGmpCast()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

but in fact, this should not be in VarClonerTest
the existing test in the caster in enough IMO

/**
* @requires extension gmp
*/
publicfunctiontestCastString()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

bad name

{
publicstaticfunctioncastGmp(\GMP$gmp,array$a,Stub$stub,$isNested,$filter):array
{
$a[Caster::PREFIX_VIRTUAL.'gmpString'] = (string)newConstStub(\GMP::class,gmp_strval($gmp));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

s/gmpString/value/
the what's the prupose of the cast to string? looks wrong to me
should be:
$a[Caster::PREFIX_VIRTUAL.'num'] = new ConstStub(gmp_strval($gmp), gmp_strval($gmp));

useSymfony\Component\VarDumper\Cloner\Stub;

/**
* Transform a GMP object to a integer or a string. It need the gmp php extension.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

* Casts GMP objects to array representation.

@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch 3 times, most recently from369e481 to530d71bCompareDecember 1, 2017 14:57
@Simperfit
Copy link
ContributorAuthor

here is a little gif of the french fields with snow:
image uploaded from ios

@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch from530d71b to4c7a3f7CompareDecember 1, 2017 15:54
@SimperfitSimperfitforce-pushed thefeature/add-a-caster-for-gmp-numbers branch from4c7a3f7 toed2c1afCompareDecember 1, 2017 15:54
@nicolas-grekasnicolas-grekas added this to the4.1 milestoneDec 1, 2017
@fabpot
Copy link
Member

Thank you@Simperfit.

@fabpotfabpot merged commited2c1af intosymfony:masterDec 1, 2017
fabpot added a commit that referenced this pull requestDec 1, 2017
…urces into string or integer (Simperfit)This PR was merged into the 4.1-dev branch.Discussion----------[VarDumper] add a GMP caster in order to cast GMP resources into string or integer| Q             | A| ------------- | ---| Branch?       | 4.1| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#25222| License       | MIT| Doc PR        | todoDo you want to dump that kind of resources ? Then it means that the app you are writing is doing some math... why?! :pIt quite nice the little snow that we have in the north of france right now:![img_2844](https://user-images.githubusercontent.com/3451634/33472917-8b48913e-d674-11e7-923f-ad951f7f2966.JPG)Commits-------ed2c1af [VarDumper] add a GMP caster in order to cast GMP resources into string or integer
@fabpotfabpot mentioned this pull requestMay 7, 2018
@SimperfitSimperfit deleted the feature/add-a-caster-for-gmp-numbers branchMay 30, 2018 14:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof requested changes

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

6 participants

@Simperfit@sroze@fabpot@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp