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

Add scalar typehints/return types#23262

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

Merged
fabpot merged 2 commits intosymfony:masterfromchalasr:dotenv4-typehints
Sep 3, 2017

Conversation

chalasr
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no (final, already breaks if doc not respected)
Deprecations?no
Tests pass?yes
Fixed tickets#23242 (comment)
LicenseMIT
Doc PRn/a

@@ -65,7 +65,7 @@ public function load($path, ...$paths)
*
* @param array $values An array of env variables
Copy link
Contributor

Choose a reason for hiding this comment

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

phpdoc maybe also requires update

Copy link
MemberAuthor

@chalasrchalasrJun 22, 2017
edited
Loading

Choose a reason for hiding this comment

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

in fact the type should bearray, no need for supporting Traversable. fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

imo it would be better to haveiterable

dunglas and ronnylt reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

If PHP7.1, theniterable is a solution. But it depends, If you really want an array, it's not the same as requiring an iterable. For example, if you need tocount the content, you can't rely onTraversable. So it really depends on the situation

@@ -45,7 +45,7 @@
* @throws FormatException when a file has a syntax error
* @throws PathException when a file does not exist or is not readable
*/
public function load($path, ...$paths)
public function load($path,string...$paths): void
Copy link
Contributor

Choose a reason for hiding this comment

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

why notstring on the required argument ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

@@ -65,7 +65,7 @@ public function load($path, ...$paths)
*
* @param array $values An array of env variables
Copy link
Contributor

Choose a reason for hiding this comment

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

imo it would be better to haveiterable

dunglas and ronnylt reacted with thumbs up emoji
@@ -88,7 +88,7 @@ public function populate($values)
*
* @throws FormatException when a file has a syntax error
*/
public function parse($data, $path = '.env')
public function parse(string$data, string $path = '.env')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the return type here ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done

@fabpot
Copy link
Member

What about other similar cases in the code base. I don't see why we should make the change here and not for similar use cases.

@stof
Copy link
Member

@fabpot this component is easy to change, because everything is final.

For other components, we could start using them in constructors, but mostly nothing else (returns types could be added later, once we have PHP 7.2 as min requirement)

dunglas and till reacted with thumbs up emoji

@chalasr
Copy link
MemberAuthor

@fabpot@stof I found a few cases where making the change is as easy (final, no contract, no parent). Seeb2c916f.

@xabbuh
Copy link
Member

Internal class and methods could be easy to update to (seehttps://github.com/symfony/symfony/compare/master...xabbuh:yaml-scalar-type-hints?expand=1 for how this could look like in the Yaml component).

chalasr reacted with thumbs up emoji

@fabpot
Copy link
Member

I like@xabbuh changes.@chalasr Do you have time to make those changes across the board when possible without BC breaks.

@chalasrchalasr changed the title[Dotenv] Add scalar typehints/return typesAdd scalar typehints/return typesJul 3, 2017
@nicolas-grekasnicolas-grekas added this to the4.0 milestoneJul 3, 2017
@chalasr
Copy link
MemberAuthor

Sure.
Status: needs work

@xabbuh
Copy link
Member

xabbuh commentedJul 3, 2017
edited
Loading

private methods could be candidates too

@chalasrchalasrforce-pushed thedotenv4-typehints branch 7 times, most recently from5717ecb tod2b8d38CompareJuly 8, 2017 14:44
@@ -178,9 +178,8 @@ private function doParse($value, $flags)
$context = 'mapping';

// force correct settings
Inline::parse(null,$flags, $this->refs);
Inline::initialize($flags, $this->getRealCurrentLineNb());
Copy link
Contributor

Choose a reason for hiding this comment

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

getRealCurrentLineNb is also marked as internal. Why not add return type there?

@Tobion
Copy link
Contributor

👍 To do this.

@mnapoli
Copy link
Contributor

As it is now there are still a lot of useful comments (in the phpdoc) that are removed in this PR, it might be better to preserve all comments that bring additional information?

@chalasr
Copy link
MemberAuthor

@mnapoli I tried to remove comments only where naming+typehints are clear enough. For instance,FirewallConfig methods returning?string were documented as@return string|null The firewall's xxx if configured, null otherwise. The class name says that these values are parsed configuration, the return type says it can be null. Wouldn't the comment be redundant? I think so.

There are not that much removed comments actually, would you mind commenting on the ones that should be kept to you?

Copy link
Contributor

@mnapolimnapoli left a comment

Choose a reason for hiding this comment

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

@chalasr OK I've reviewed the diff and "a lot" was probably exaggerated sorry ^^

TheFirewallConfig class was the main problem I had, but it seems it's obvious that everything is a service ID there so maybe all those docblocks are not so useful indeed. In the end when you ignore that class there are just a few spots that I've noted as questions (also the@throws that were removed might be worth preserving).

@@ -128,16 +121,7 @@ private function parseSelectorList(TokenStream $stream)
return $selectors;
}

/**
* Parses next selector or combined node.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment might be useful? (I don't know the class so might be wrong)

The same applies to the other methods of that class, but if it's expected that all methods parse the "next […]" then feel free to ignore my comment.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

yes, applies to all methods

*
* @return Extension\ExtensionInterface
*
* @throws ExpressionErrorException
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the@throws be kept?

*
* @return XPathExpr
*
* @throws ExpressionErrorException
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here?

*
* @return XPathExpr
*
* @throws ExpressionErrorException
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@throws annotations re-added

@@ -33,6 +33,18 @@ class Inline
private static $objectForMap = false;
private static $constantSupport = false;

public static function initialize(int $flags, int $parsedLineNumber = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new method intended?

Copy link
Member

Choose a reason for hiding this comment

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

The idea was to not have to acceptnull values inInline::parse(). But I have moved it to its own PR:#24060

$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
}

return sprintf('{ %s }', implode(', ', $output));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this code change intended in this PR?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this part is handling the dumping of objects as YAML mappings and thus allows us to type hint the$value argument indumpArray() witharray.

@xabbuhxabbuhforce-pushed thedotenv4-typehints branch 3 times, most recently fromfa7c35b toa7e1656CompareAugust 29, 2017 20:48
xabbuh added a commit that referenced this pull requestAug 30, 2017
This PR was merged into the 3.4 branch.Discussion----------[Yaml] mark some classes as final| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Making these classes final unlocks more scalar type hint possibilities on top of the changes proposed in#23262.Commits-------330c6bf [Yaml] mark some classes as final
@chalasr
Copy link
MemberAuthor

Updated by@xabbuh next to#24028 to add some more typehints, his changes look good to me.
PR ready.

@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commit7b1715b intosymfony:masterSep 3, 2017
fabpot added a commit that referenced this pull requestSep 3, 2017
This PR was merged into the 4.0-dev branch.Discussion----------Add scalar typehints/return types| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no (final, already breaks if doc not respected)| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#23242 (comment)| License       | MIT| Doc PR        | n/aCommits-------7b1715b [Yaml] use scalar type hints where possible6ce70e4 Add scalar typehints/return types on final/internal/private code
@chalasrchalasr deleted the dotenv4-typehints branchSeptember 3, 2017 16:18
fabpot added a commit that referenced this pull requestSep 6, 2017
This PR was merged into the 3.4 branch.Discussion----------[Yaml] add inline parser context initializer| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#23262 (comment)| License       | MIT| Doc PR        |Calling the parser to initialize some internal context does not looklike a good idea. Additionally, this change allows to not accept nullvalues in `Inline::parse()` in 3.4 anymore.Commits-------1be23c2 [Yaml] add inline parser context initializer
@fabpotfabpot mentioned this pull requestOct 19, 2017
fabpot added a commit that referenced this pull requestOct 26, 2017
This PR was merged into the 4.0-dev branch.Discussion----------[Intl] Allow passing null as a locale fallback| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -[`Null` is passed in `update-data.php`](https://github.com/symfony/symfony/blob/e2b4a35a720b85173d15055d0554f86602d43593/src/Symfony/Component/Intl/Resources/bin/update-data.php#L209) to prevent falling back to English locale during icu data import. It's been always possible, but since it hasn't been documented in the docblock it was missed while merging#23262.Commits-------e2b4a35 [Intl] Allow passing null as a locale fallback
@derrabusderrabus mentioned this pull requestJun 25, 2019
57 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@xabbuhxabbuhxabbuh left review comments

@KocKocKoc left review comments

@greg0iregreg0iregreg0ire left review comments

@mnapolimnapolimnapoli left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@just1602just1602just1602 left review comments

@PierstovalPierstovalPierstoval left review comments

@jderussejderussejderusse left review comments

@anaelChardananaelChardananaelChardan left review comments

@jenkoianjenkoianjenkoian left review comments

@TaluuTaluuTaluu left review comments

@jvasseurjvasseurjvasseur left review comments

@afurculitaafurculitaafurculita left review comments

@marek-pietrzak-tgmarek-pietrzak-tgmarek-pietrzak-tg left review comments

@ogizanagiogizanagiogizanagi approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@stofstofstof approved these changes

@TobionTobionTobion approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
4.0
Development

Successfully merging this pull request may close these issues.

22 participants
@chalasr@fabpot@stof@xabbuh@jderusse@mnapoli@nicolas-grekas@Tobion@javiereguiluz@jenkoian@Koc@Taluu@lyrixx@just1602@greg0ire@jvasseur@ogizanagi@marek-pietrzak-tg@afurculita@Pierstoval@anaelChardan@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp