Coder Social home page Coder Social logo

Comments (3)

norberttech avatar norberttech commented on July 30, 2024

Could you share your pattern and data you are trading to match against?

from php-matcher.

fr0N73ND3r avatar fr0N73ND3r commented on July 30, 2024

I added only the library to the composer.

// src/index.php
<?php

require __DIR__ . '/../vendor/autoload.php';

// https://github.com/coduo/php-matcher/blob/6.x/src/PHPMatcher.php#L55
$factory = new Coduo\PHPMatcher\Factory\MatcherFactory();
$backtrace = new Coduo\PHPMatcher\Backtrace\VoidBacktrace();

$matcher = $factory->createMatcher($backtrace);

$matcher->match('1', '@number@'); // is true
$matcher->match(1, '@number@'); // is true
$matcher->match('1', '@integer@'); // is true <- wrong
$matcher->match(1, '@integer@'); // is true

from php-matcher.

norberttech avatar norberttech commented on July 30, 2024

Ahh I see, the problem is that Matcher Factory is creating a chain of matchers, they are executed in a specific order.
It works this way because typically, you want to use matcher against JSON files, so what happens here is that TextMatcher recognizes your input as a text and it's probably using the wrong matcher.

I think the problem is an order of matchers here but it's been a while since I looked into this logic so you might need to play with it a bit.

from php-matcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.