Comments (3)
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.
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.
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)
- PHP 8.2.0 HOT 1
- Try styleci.io HOT 3
- Try coveralls.io HOT 1
- Further OCSP Decoding/Encoding Ability HOT 3
- OCSP CertStatus Info Again HOT 2
- Encoder usage question HOT 2
- BitString encapsulating Sequence of Integers HOT 5
- PHP 5.4 and 5.5 HOT 9
- CSR parsing ends in 'PHP Fatal error' => ParserException HOT 7
- Add keywords to composer.json HOT 1
- NullObject is undefined HOT 4
- `Object` is a special class name HOT 8
- php -l errors. HOT 1
- Doesn't detect gmp HOT 3
- Remove a node
- OIDs 2.40+ are not supported HOT 1
- Modifying an existing object failing HOT 6
- PHPUnit tests fail on 32bit systems due to out-of-bounds integer.
- Some signatures cannot be parsed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpasn1.