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

Class existence resource#20121

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:masterfromfabpot:class-existence-resource
Oct 5, 2016

Conversation

fabpot
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketssee#20094
LicenseMIT
Doc PRn/a

linaori and Koc reacted with thumbs up emoji
namespace Symfony\Component\Config\Resource;

/**
* ClassExistenceResource represents a class availability.
Copy link
Member

Choose a reason for hiding this comment

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

Let's replaceavailability withexistence, to be consistent with the class name and theclass_exists function name.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done

EOF
);

$this->assertFalse($res->isFresh(time()));
Copy link
Member

Choose a reason for hiding this comment

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

Afaik, this should beassertTrue. In table form (horizontal: current state, vertical: stored state)

Class existsClass does not exists
Class existsNot freshFresh
Class does not existsFreshNot fresh

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The freshness is all about the state change. The resource is fresh if there is no change in class existence, so no need to refresh the cache. Not fresh means that the cache must be recalculated, so when the state changes. So, the table should be:

Class existsClass does not exists
Class existsFreshNot fresh
Class does not existsNot freshfresh

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry. Completely messed up the definition of "fresh"...

@@ -72,15 +76,18 @@ public function process(ContainerBuilder $container)
$container->getDefinition('twig.extension.assets')->addTag('twig.extension');
}

if (class_exists('Symfony\Component\Yaml\Parser')) {
$container->addResource(new ClassExistenceResource(YamlParser::class));
if (class_exists(YamlParser::class)) {
Copy link
Member

@javiereguiluzjaviereguiluzOct 2, 2016
edited
Loading

Choose a reason for hiding this comment

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

Related tothis comment, just asking if we could replace this:

if (class_exists(YamlParser::class)) {$container->getDefinition('twig.extension.yaml')->addTag('twig.extension');}

by this?

if (!class_exists(YamlParser::class)) {$container->removeDefinition('twig.extension.yaml');}

Choose a reason for hiding this comment

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

The difference is that if one uses thetwig.extension.yaml directly, the proposed version will break.
I think the current approach is a more open thus a better practice, even if in this very case using the extension directly is so unlikely.

javiereguiluz reacted with thumbs up emoji
@fabpotfabpotforce-pushed theclass-existence-resource branch from8d0ff06 to222b56dCompareOctober 3, 2016 23:53
@fabpotfabpot merged commit222b56d intosymfony:masterOct 5, 2016
fabpot added a commit that referenced this pull requestOct 5, 2016
This PR was merged into the 3.2-dev branch.Discussion----------Class existence resource| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | see#20094| License       | MIT| Doc PR        | n/aCommits-------222b56d [TwigBundle] added support for ClassExistenceResource when relevantd98eb7b [Config] added ClassExistenceResource
fabpot added a commit to sensiolabs/SensioFrameworkExtraBundle that referenced this pull requestOct 5, 2016
This PR was merged into the 4.0.x-dev branch.Discussion----------added support for ClassExistenceResourcedepends onsymfony/symfony#20121Commits-------a1f987d added support for ClassExistenceResource
public function __construct($resource)
{
$this->resource = $resource;
$this->exists = class_exists($resource);
Copy link
Member

Choose a reason for hiding this comment

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

we should useclass_exists() || interface_exists() || trait_exists() to make it usable for interfaces and traits too

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@wouterjwouterjwouterj left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@fabpot@javiereguiluz@nicolas-grekas@stof@wouterj@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp