Thanks to visit codestin.com
Credit goes to github.com

Skip to content

removed all *.class parameters #14070

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

Merged
merged 1 commit into from
Mar 26, 2015
Merged

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Mar 26, 2015

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? no
Fixed tickets #11881, #12822
License MIT
Doc PR none

@fabpot
Copy link
Member Author

fabpot commented Mar 26, 2015

Here is the script I used:

<?php

require_once __DIR__.'/vendor/autoload.php';

use Symfony\Component\Finder\Finder;

$finder = (new Finder())->name('*.xml')->in(__DIR__.'/src');
$values = array();
foreach ($finder as $file) {
    $contents = file_get_contents($file);

    $new = preg_replace_callback("{^ +<parameter key=\"([^\"]+)\.class\">([^<]+)</parameter>\n}m", function ($match) use (&$values) {
        $values['%'.$match[1].'.class%'] = $match[2];
    }, $contents);

    $new = preg_replace("{^ +<parameters>\s+</parameters>\n\n}sm", '', $new);
    $new = preg_replace("{</parameter>\s+</parameters>}s", "</parameter>\n    </parameters>", $new);
    $new = preg_replace("{<parameters>\s+    <parameter}s", "<parameters>\n        <parameter", $new);

    if ($new != $contents) {
        file_put_contents($file, $new);
    }
}

$finder = (new Finder())->in(__DIR__.'/src');
foreach ($finder as $file) {
    $contents = file_get_contents($file);

    $new = preg_replace_callback('{%[a-zA-Z0-9\._]+\.class%}', function ($match) use ($values) {
        return isset($values[$match[0]]) ? $values[$match[0]] : $match[0];
    }, $contents);

    if ($new != $contents) {
        file_put_contents($file, $new);
    }
}

@TomasVotruba
Copy link
Contributor

👍

@@ -30,8 +30,6 @@ public function testLoadEmptyConfiguration()
$container->loadFromExtension('twig', array());
$this->compileContainer($container);

$this->assertEquals('Twig_Environment', $container->getParameter('twig.class'), '->load() loads the twig.xml file');
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this tests needs to be replaced by testing whether the twig service is defined to keep that test

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@Tobion
Copy link
Contributor

Tobion commented Mar 26, 2015

Apart from the two small things looks ok to me.

@fabpot fabpot force-pushed the class-parametres-removal branch from ebf5eca to 8835d1a Compare March 26, 2015 15:34
@Tobion
Copy link
Contributor

Tobion commented Mar 26, 2015

👍

@fabpot fabpot merged commit 8835d1a into symfony:master Mar 26, 2015
fabpot added a commit that referenced this pull request Mar 26, 2015
This PR was merged into the 3.0-dev branch.

Discussion
----------

removed all *.class parameters

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #11881, #12822
| License       | MIT
| Doc PR        | none

Commits
-------

8835d1a removed all *.class parameters
@fabpot fabpot mentioned this pull request Nov 16, 2015
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.

5 participants