Giter Site home page Giter Site logo

LogicException namespacing bug about php-rrule HOT 3 CLOSED

Solinx avatar Solinx commented on August 25, 2024
LogicException namespacing bug

from php-rrule.

Comments (3)

rlanvin avatar rlanvin commented on August 25, 2024

Indeed, good catch!

now I'm off to find out what I did wrong to generate this Exception

You tried to use array access syntax in write mode (e.g. $rrule[] = x or unset($rrule[x])) which is impossible.

perhaps you could reference such dependencies as at the top of the file (e.g. "use LogicException;") That provides a bit more clarity concerning the external classes you use.

I do not know what are is "recommended" way of doing it, you might be right. Though at first glance it seems that I would need a fair amount of use statements at the beginning of the file (most of the standard Exceptions, DateTime, DateTimeZone, DateTimeInterface, and so on). Care to elaborate the benefits?

from php-rrule.

Solinx avatar Solinx commented on August 25, 2024

You tried to use array access syntax in write mode (e.g. $rrule[] = x or unset($rrule[x])) which is impossible.

You're right. After a code refactor I ended up using $rrule both for the input var and the RRule object.

I do not know what are is "recommended" way of doing it, you might be right. Though at first glance it seems that I would need a fair amount of use statements at the beginning of the file (most of the standard Exceptions, DateTime, DateTimeZone, DateTimeInterface, and so on). Care to elaborate the benefits?

As far as I know it's not part of a PSR standard, so I guess there isn't really a clear recommended way of doing it. The benefits are in particular apparent when you've got a file with several 3rd party references and/or long paths. With built-in classes the benefits are certainly less clear. The exception to this though are Exceptions. It is useful for consuming developers to be able to see at a glance which Exceptions could be thrown by a module.

Some of the other benefits are that you're less likely to make typo's like the one I reported here, you get one clear list of dependencies and by grouping all dependencies you'll be made more aware of the moment you're trying to do too much within a single class. At least, that's my personal view on the matter.

A disadvantage is that the actual line by line code may become somewhat less clear, but if you're using a modern editor (such as PhpStorm) this is not much of an issue.

from php-rrule.

rlanvin avatar rlanvin commented on August 25, 2024

Thank you for taking the time to elaborate. I fully agree with you about 3rd party classes and long names. However, for standard PHP classes, I checked what other PHP projects are doing, and it seems that the standard way of doing it is to reference them with their full name. So I'm going to leave it like that for the moment.

from php-rrule.

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.