Skip to content

Commit 2d93777

Browse files
committed
Merge pull request #3 from phpcr/prevent_keyword_truncation
Prevent keyword truncation
2 parents 13926c2 + 6af6226 commit 2d93777

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

lib/MigratorUtil.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ public static function getClassNameFromFile($file)
3434
break;
3535
}
3636

37-
$buffer .= fread($fp, 512);
38-
$tokens = token_get_all($buffer);
37+
// Read entire lines to prevent keyword truncation
38+
for ($line = 0; $line <= 20; $line++) {
39+
$buffer .= fgets($fp);
40+
}
41+
$tokens = @token_get_all($buffer);
3942

4043
if (strpos($buffer, '{') === false) {
4144
continue;

tests/Unit/MigratorUtilTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHPCR Migrations package
5+
*
6+
* (c) Daniel Leech <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PHPCR\Migrations\tests\Unit;
13+
14+
use PHPCR\Migrations\MigratorUtil;
15+
16+
class MigratorUtilTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* It should return the classname of a file.
20+
*/
21+
public function testGetClassName()
22+
{
23+
$className = MigratorUtil::getClassNameFromFile(__DIR__ . '/migrations/Version201511240843.php');
24+
$this->assertEquals('\Sulu\Bundle\ContentBundle\Version201511240843', $className);
25+
}
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHPCR Migrations package
5+
*
6+
* (c) Daniel Leech <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Sulu\Bundle\ContentBundle;
13+
14+
use PHPCR\Migrations\VersionInterface;
15+
use PHPCR\NodeInterface;
16+
use PHPCR\SessionInterface;
17+
use Bala\Bundle\ContentBundle\Blog\BasePageBlog;
18+
use Bala\Bundle\BlogManagerBundle\Bridge\BlogInspector;
19+
use Bala\Bundle\BlogManagerBundle\Bridge\PropertyEncoder;
20+
use Bala\Component\Content\Metadata\BlockMetadata;
21+
use Bala\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface;
22+
use Bala\Component\Content\Metadata\PropertyMetadata;
23+
use Bala\Component\Content\Metadata\StructureMetadata;
24+
use Bala\Component\BlogManager\BlogManagerInterface;
25+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
26+
use Symfony\Component\DependencyInjection\ContainerInterface;
27+
28+
/**
29+
* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
30+
*
31+
* Created: 2015-12-10 10:04
32+
*/
33+
class Version201511240843 implements VersionInterface, ContainerAwareInterface
34+
{
35+
}

0 commit comments

Comments
 (0)