Skip to content
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

Now MetaDataFilter takess also regexp. For example whern you want to #507

Closed
wants to merge 5 commits into from
Closed

Now MetaDataFilter takess also regexp. For example whern you want to #507

wants to merge 5 commits into from

Conversation

catalinux
Copy link
Contributor

extract metadata if you would filter like this: --filter="Article"
would extract also for "ArticleItems" (article_items table). Now you
can use --filter="Article$" if you want only that table (articl)

extract metadata if you would filter like this: --filter="Article"
would extract also for "ArticleItems" (article_items table). Now you
can use --filter="Article$" if you want only that table (articl)
@doctrinebot
Copy link

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2128

@stof
Copy link
Member

stof commented Nov 6, 2012

This does not follow the coding standards.

if (strpos($metadata->name, $filter) !== false) {
return true;
}
if(preg_match("#$filter#",$metadata->name,$m)) return true;

Choose a reason for hiding this comment

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

Missing space after the if. Also you need to add { around the statement as defined in PSR-1/2

Copy link
Member

Choose a reason for hiding this comment

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

and you need to escape the # in the filter as you use it as regex delimiter

- Changed RegExp format
@@ -51,7 +51,7 @@ static public function filter(array $metadatas, $filter)

public function __construct(\ArrayIterator $metadata, $filter)
{
$this->filter = (array) $filter;
$this->filter = (array)$filter;
Copy link
Member

Choose a reason for hiding this comment

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

Please keep this space

@@ -66,7 +66,16 @@ public function accept()
$metadata = $it->current();

foreach ($this->filter as $filter) {
if (strpos($metadata->name, $filter) !== false) {
$pregResult = preg_match("/" . preg_quote($filter) . "/", $metadata->name);
Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot use preg_qoute here, if you do so, $filter will not be treated as a regular expression (which was the intention of this pull request). And even if you do so, you still do not escape the delimiter, you would have to do this: preg_quote($filter, '/').

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is true. I realized that after I pushed the code. Some unit test might be helpfull here

Copy link
Member

Choose a reason for hiding this comment

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

Just remove the preg_quote()

@beberlei
Copy link
Member

beberlei commented Jan 2, 2014

Merged into master.

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.

6 participants