Skip to content

Prevent keyword truncation #3

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
Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/MigratorUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ public static function getClassNameFromFile($file)
break;
}

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

if (strpos($buffer, '{') === false) {
continue;
Expand Down
26 changes: 26 additions & 0 deletions tests/Unit/MigratorUtilTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the PHPCR Migrations package
*
* (c) Daniel Leech <daniel@dantleech.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace PHPCR\Migrations\tests\Unit;

use PHPCR\Migrations\MigratorUtil;

class MigratorUtilTest extends \PHPUnit_Framework_TestCase
{
/**
* It should return the classname of a file.
*/
public function testGetClassName()
{
$className = MigratorUtil::getClassNameFromFile(__DIR__ . '/migrations/Version201511240843.php');
$this->assertEquals('\Sulu\Bundle\ContentBundle\Version201511240843', $className);
}
}
35 changes: 35 additions & 0 deletions tests/Unit/migrations/Version201511240843.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of the PHPCR Migrations package
*
* (c) Daniel Leech <daniel@dantleech.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sulu\Bundle\ContentBundle;

use PHPCR\Migrations\VersionInterface;
use PHPCR\NodeInterface;
use PHPCR\SessionInterface;
use Bala\Bundle\ContentBundle\Blog\BasePageBlog;
use Bala\Bundle\BlogManagerBundle\Bridge\BlogInspector;
use Bala\Bundle\BlogManagerBundle\Bridge\PropertyEncoder;
use Bala\Component\Content\Metadata\BlockMetadata;
use Bala\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface;
use Bala\Component\Content\Metadata\PropertyMetadata;
use Bala\Component\Content\Metadata\StructureMetadata;
use Bala\Component\BlogManager\BlogManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
*
* Created: 2015-12-10 10:04
*/
class Version201511240843 implements VersionInterface, ContainerAwareInterface
{
}