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

disussion#7862: adds first test case #7890

Draft
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

BruceGitHub
Copy link

This PR poin to implements the idea from this
#7862

Comment on lines 1359 to 1360
$file_contents = <<<'EOT'
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the master branch requires PHP 7.4, I'd prefer the indented heredoc syntax. Not sure if @orklah has any thoughts on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I never use heredoc so I don't really know, but yeah, if we can indent that, it's probably for the best

Copy link
Author

Choose a reason for hiding this comment

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

Ok!

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, just indent everything including EOT.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I elaborate first crappy crappy version!
The idea is:

  1. Detect from the "issue->message" two arrays, requested and provided
    to perform this operation I create a class "PrettyDetectArray->detect"

This is a complex operation because the message is a "random" payload!
The next idea might add some sort of meta-data, to the point where detecting the issue.
In this case, the process is simple: format and compare... (next in work...)

  1. Format one and second array
    to perform this operation I create a class "PrettyFormat->format"

  2. Compare one and second array
    to perform this operation I create a class "PrettyCompare->compare"

I think to improve the concrete code, to make it more clean and readable

push coming

Copy link
Collaborator

Choose a reason for hiding this comment

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

Detect from the "issue->message" two arrays, requested and provided to perform this operation I create a class "PrettyDetectArray->detect"

This seems unnecessarily complicated and will probably cause issues if I do something like class Myarray Myarray{key: 'value'}. I think it would probably be easier and better to do something like add a $types list to issues and have the message be a format string. You could even be more generic and support multiple rendering categories in the future:

new SomeIssue('The type "{provided}" doesn't match the expected "{expected}"', ["provided" => $provided_type, "expected" => $expected_type], $suppressed_issues);

On the other hand having to track the type in the issue requires more refactoring, so idk. If we do decide to do a refactor requiring a change to issue messages, we might as well try to be consistent about the order of "Foo provided, expected Bar" vs "Expected Foo, found Bar" everywhere.

Really nice to get this improvement though!

Copy link
Collaborator

@AndrolGenhald AndrolGenhald May 11, 2022

Choose a reason for hiding this comment

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

Thinking about it a bit more, I think if we went the route of having the issues track the actual Union types, we'd probably want to make the message generic like 'The provided type doesn't match the expected type', and then when it's rendered that can be converted to either 'The provided...type. Provided: array{...}; Expected: array{...}' or the new pretty format based on config and output type.

If you've already gotten the type detection mostly working though, that might be easier to go with for now until things get closer to finished.

Copy link
Author

@BruceGitHub BruceGitHub May 11, 2022

Choose a reason for hiding this comment

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

Nice !

Really nice to get this improvement though!

I'm ready to go in this direction for me is the best!

I could create a intermediate task/issue to do this work, then complete this ...

Copy link
Author

@BruceGitHub BruceGitHub May 12, 2022

Choose a reason for hiding this comment

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

Can you explain the second sentence?

Thinking about it a bit more, I think if we went the route of having the issues track the actual Union types, ...

like structure with the "tokens" ?

@BruceGitHub BruceGitHub force-pushed the pr-prettry-print-from-discussion-7862 branch from 10e4fba to d398f05 Compare May 11, 2022 21:02
@orklah
Copy link
Collaborator

orklah commented May 14, 2022

Sorry for not triggering CI earlier, I have some backlog on replying to issues and PR. Don't hesitate to ping me if needed ;)

@BruceGitHub
Copy link
Author

BruceGitHub commented May 17, 2022

Sorry for not triggering CI earlier, I have some backlog on replying to issues and PR. Don't hesitate to ping me if needed ;)

I will try some spyke, for the next step

@BruceGitHub BruceGitHub force-pushed the pr-prettry-print-from-discussion-7862 branch from 9fb9fd2 to 62b57b6 Compare May 28, 2022 15:35
@BruceGitHub
Copy link
Author

BruceGitHub commented Jun 2, 2022

I will try to simulate windows env with linux ...

@BruceGitHub
Copy link
Author

BruceGitHub commented Jun 3, 2022

I did not understand if the last commit passed all tests or if some random failure occurs

@BruceGitHub
Copy link
Author

I did not understand if the last commit passed all tests or if some random failure occurs

small recap:

  • ci: I did not understand well the problem yet
  • src: I found a defect in the algorithm and I working on it to resolve

@BruceGitHub
Copy link
Author

BruceGitHub commented Jun 10, 2022

I did not understand if the last commit passed all tests or if some random failure occurs

small recap:

  • ci: I did not understand well the problem yet
  • src: I found a defect in the algorithm and I working on it to resolve

Good news!

through this #8034 I fixed the code.

Example of the output:

        |
        | Expected                                           | Provided
        | ---                                                | ---
        | array {                                            | array {
        |  array {                                           |  array {
        |   _id: string,                                     |   _id: '6259381a37d1f57503ca646f',
        |   activeFrom: string,                              |   activeFrom: '2022-04-16T00: 00: 00.000+02: 00',
        |   actualCity: string,                              |   actualCity: 'Aachen',
        |   address: string,                                 |   address: 'elefantenstrasse12',
        |   annualSalaryFrom: int,                           |   annualSalaryFrom: 55000,
        |   annualSalaryTo: int,                             |   annualSalaryTo: 70000,
        |   candidateContactWay: string,                     |   candidateContactWay: 'Email',
        |   cityCategory: string,                            |   cityCategory: 'Aachen',
        |   company: string,                                 |   company: 'bkipebussolutionsGmbH',
        |   companyId: string,                               |   companyId: '623b3be0c421b2d41d3778db',
        |   companySize: string,                             |   companySize: ' {
        |   companyType: string,                             |    50',
        |   country: 'ch'|'de',                              |    companyType: 'Startup',
        |   expLevel: string,                                |    expLevel: 'Senior',
        |   expiresOn: null|string,                          |    expiresOn: null,
        |   hasVisaSponsorship: string,                      |    hasVisaSponsorship: 'No',
        |   isFullRemote: bool,                              |    isFullRemote: false,
        |   jobType: string,                                 |    jobType: 'Full-Time',
        |   jobUrl: string,                                  |    jobUrl: 'bippokippo-solutions-Architekten-mwd-fr-Elektromobilitt',
        |   language: string,                                |    language: 'English',
        |   latitude: float,                                 |    latitude: float(50.76881525),
        |   logoImg: string,                                 |    logoImg: 'bkip-ebus-solutions-gmbh-logo.jpg',
        |   longitude: float,                                |    longitude: float(6.08364339),
        |   name: string,                                    |    name: 'Software-Architekten(m/w/d)fürElektromobilität',
        |   offerStockOrBonus: bool,                         |    offerStockOrBonus: false,
        |   postalCode: string,                              |    postalCode: '52064',
        |   techCategory: string,                            |    techCategory: 'Architect',
        |   technologies: array {                            |    technologies: array {
        |    int,                                            |     'Angular',
        |    string                                          |     'CI/CD',
        |   }                                                |     'DevOps',
        |  }                                                 |     'Docker',
        | }                                                  |     'ElasticSearch',
        |                                                    |     'Git',
        |                                                    |     'JBoss',
        |                                                    |     'Java',
        |                                                    |     'Jenkins',
        |                                                    |     'Quarkus'
        |                                                    |    }

now I work to fix the "CI". I think that soon I will open PR for the review.
Probably I will do much work the CI sorry :-(

@orklah
Copy link
Collaborator

orklah commented Jun 10, 2022

If you want, find a little something to PR so I can merge it. You won't be bothered by manual approval on our end anymore after that ;)

@AndrolGenhald
Copy link
Collaborator

If you want, find a little something to PR so I can merge it. You won't be bothered by manual approval on our end anymore after that ;)

☝️

There are plenty of issues marked as easy or good first issue, I generally don't bother with the easy ones that I don't personally care about so that there are good ways for new contributors to get started.

@BruceGitHub
Copy link
Author

If you want, find a little something to PR so I can merge it. You won't be bothered by manual approval on our end anymore after that ;)

point_up

There are plenty of issues marked as easy or good first issue, I generally don't bother with the easy ones that I don't personally care about so that there are good ways for new contributors to get started.

OK, so I start with an issue with this label?
some suggestion or preference?

@orklah
Copy link
Collaborator

orklah commented Jun 12, 2022

#8062 should be fairly easy for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants