Git Product home page Git Product logo

Comments (3)

fgrosse avatar fgrosse commented on August 19, 2024

So far I recommend defining a class for the thing you want to parse then move the parsing logic into there (including checking types etc) (check X509/CertificateSubject if you haven't already).
This gives you full error handling capacities, you can handle optional arguments and have full type savety with phpdoc.

The idea of defining templates sounds interesting because it can remove the necessity for the boiler plate code. However, the approach you suggested would only work if I would change the constructors to always accept no arguments which I would rather not do. Instead we could have a nested nested array of type identifiers to define such a template.

If you have yet another idea on how to traverse parsed objects while maintaining type savety and error handling I am all ears :)

I was also thinking about writing a ASN.1 compiler which could take a ASN.1 definition and compile php code which uses PHPASN1 from that. This would be a separate repository though.

from phpasn1.

fgrosse avatar fgrosse commented on August 19, 2024

I have create an experimental TemplateParser which you can check out using the experimental/template-parser branch.

I guess this is already pretty useful so I will probably merge this into master soon after I did some more error handling and improved the exception.

from phpasn1.

afk11 avatar afk11 commented on August 19, 2024

Thanks, I'll bear this advice in mind. Probably will be able to send the Certificate classes your way.

Re: informing a parser about the structure, maybe passing Identifer::XX is best, otherwise I would be thinking of doing Integer::class.

from phpasn1.

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.