{"action":"created","issue":{"url":"https://api.github.com/repos/coduo/php-matcher/issues/45","labels_url":"https://api.github.com/repos/coduo/php-matcher/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/coduo/php-matcher/issues/45/comments","events_url":"https://api.github.com/repos/coduo/php-matcher/issues/45/events","html_url":"https://github.com/coduo/php-matcher/pull/45","id":53619293,"number":45,"title":"TextMatcher should not match @null@ inside pattern","user":{"login":"adamquaile","id":69929,"avatar_url":"https://avatars.githubusercontent.com/u/69929?v=3","gravatar_id":"","url":"https://api.github.com/users/adamquaile","html_url":"https://github.com/adamquaile","followers_url":"https://api.github.com/users/adamquaile/followers","following_url":"https://api.github.com/users/adamquaile/following{/other_user}","gists_url":"https://api.github.com/users/adamquaile/gists{/gist_id}","starred_url":"https://api.github.com/users/adamquaile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamquaile/subscriptions","organizations_url":"https://api.github.com/users/adamquaile/orgs","repos_url":"https://api.github.com/users/adamquaile/repos","events_url":"https://api.github.com/users/adamquaile/events{/privacy}","received_events_url":"https://api.github.com/users/adamquaile/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-07T10:42:18Z","updated_at":"2015-01-09T14:40:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/coduo/php-matcher/pulls/45","html_url":"https://github.com/coduo/php-matcher/pull/45","diff_url":"https://github.com/coduo/php-matcher/pull/45.diff","patch_url":"https://github.com/coduo/php-matcher/pull/45.patch"},"body":"The `TextMatcher` currently reports that it matches against all strings. During matching against strings with `@null@` in them an `UnknownTypeException` will be thrown - after all a pattern like `this should be @null@` makes no sense in a text context. \r\n\r\nThis prevents other matchers from being able to match, so I've changed it to not match in this case. \r\n\r\nReproduce code: \r\n\r\n```php\r\n<?php\r\n\r\nuse Coduo\\PHPMatcher\\Factory\\SimpleFactory;\r\n\r\nrequire_once __DIR__ . '/vendor/autoload.php';\r\n\r\n$expected = <<<JSON\r\n{\r\n    \"a\": @null@,\r\n    \"b\": 4\r\n}\r\nJSON;\r\n\r\n\r\n$actual = <<<JSON\r\n{\r\n    \"a\": null,\r\n    \"b\": 5\r\n}\r\nJSON;\r\n\r\n\r\n$matcher = (new SimpleFactory())->createMatcher();\r\n\r\n\r\necho $matcher->match($actual, $expected)\r\n    ? 'Match found' :\r\n    'Match not found: ' . $matcher->getError()\r\n;\r\n```"},"comment":{"url":"https://api.github.com/repos/coduo/php-matcher/issues/comments/69341939","html_url":"https://github.com/coduo/php-matcher/pull/45#issuecomment-69341939","issue_url":"https://api.github.com/repos/coduo/php-matcher/issues/45","id":69341939,"user":{"login":"norzechowicz","id":1921950,"avatar_url":"https://avatars.githubusercontent.com/u/1921950?v=3","gravatar_id":"","url":"https://api.github.com/users/norzechowicz","html_url":"https://github.com/norzechowicz","followers_url":"https://api.github.com/users/norzechowicz/followers","following_url":"https://api.github.com/users/norzechowicz/following{/other_user}","gists_url":"https://api.github.com/users/norzechowicz/gists{/gist_id}","starred_url":"https://api.github.com/users/norzechowicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/norzechowicz/subscriptions","organizations_url":"https://api.github.com/users/norzechowicz/orgs","repos_url":"https://api.github.com/users/norzechowicz/repos","events_url":"https://api.github.com/users/norzechowicz/events{/privacy}","received_events_url":"https://api.github.com/users/norzechowicz/received_events","type":"User","site_admin":false},"created_at":"2015-01-09T14:40:17Z","updated_at":"2015-01-09T14:40:17Z","body":"Because there will be at least 2 poinst (JsonMatcher and TextMatcher) where we are going to check if string is a valid json/xml/yaml I think it would be nice to extract this logic somewhere else. \r\nMaybe simple Json and Xml classes with static method isValid($value) method? \r\nIt will give us possibility to use it like in following example in canMatch methods:\r\n\r\n```\r\npublic function canMatch($value)\r\n{\r\n    if (Json::isValid($value) || Xml::isValid($value) { \r\n         return false;\r\n    }\r\n}\r\n```\r\n\r\nBut above code breaks open closed principle so I guess we could extract logic from canMatch method into something like SimpleTextValidator class, what do You think? "}}