Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #19276 [ClassLoader] Add ClassCollectionLoader::inline() to g…
…enerate inlined-classes files (nicolas-grekas) This PR was squashed before being merged into the 3.2-dev branch (closes #19276). Discussion ---------- [ClassLoader] Add ClassCollectionLoader::inline() to generate inlined-classes files | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Unfortunately, can't be tested because the method relies too much on side effects. Coupled with sensiolabs/SensioDistributionBundle#272, allows inlining `ClassCollectionLoader` itself into the `bootstrap.php.cache` file. Commits ------- 88fdcea [ClassLoader] Add ClassCollectionLoader::inline() to generate inlined-classes files
- Loading branch information
Showing
13 changed files
with
189 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; | ||
|
||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer; | ||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass; | ||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\WarmedClass; | ||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase; | ||
|
||
class ClassCacheCacheWarmerTest extends TestCase | ||
{ | ||
public function testWithDeclaredClasses() | ||
{ | ||
$this->assertTrue(class_exists(WarmedClass::class, true)); | ||
|
||
$dir = sys_get_temp_dir(); | ||
@unlink($dir.'/classes.php'); | ||
file_put_contents($dir.'/classes.map', sprintf('<?php return %s;', var_export(array(WarmedClass::class), true))); | ||
|
||
$warmer = new ClassCacheCacheWarmer(array(DeclaredClass::class)); | ||
|
||
$warmer->warmUp($dir); | ||
|
||
$this->assertSame(<<<'EOTXT' | ||
<?php | ||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures | ||
{ | ||
class WarmedClass extends DeclaredClass | ||
{ | ||
} | ||
} | ||
EOTXT | ||
, file_get_contents($dir.'/classes.php') | ||
); | ||
|
||
@unlink($dir.'/classes.map'); | ||
@unlink($dir.'/classes.php'); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/DeclaredClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; | ||
|
||
class DeclaredClass | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/WarmedClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; | ||
|
||
class WarmedClass extends DeclaredClass | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Symfony/Component/ClassLoader/Tests/Fixtures/DeclaredClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\ClassLoader\Tests\Fixtures; | ||
|
||
class DeclaredClass implements DeclaredInterface | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Component/ClassLoader/Tests/Fixtures/DeclaredInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\ClassLoader\Tests\Fixtures; | ||
|
||
interface DeclaredInterface | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Component/ClassLoader/Tests/Fixtures/WarmedClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\ClassLoader\Tests\Fixtures; | ||
|
||
class WarmedClass extends DeclaredClass implements WarmedInterface | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Component/ClassLoader/Tests/Fixtures/WarmedInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\ClassLoader\Tests\Fixtures; | ||
|
||
interface WarmedInterface | ||
{ | ||
} |