Git Product home page Git Product logo

Comments (5)

AndCake avatar AndCake commented on July 17, 2024

Right now classes cannot exist without a class body. However, I can see that it sometimes might make sense to have an empty class. I'll add the possibility to create empty classes.

As a work-around solution until the above-mentioned fix is in place, you could just write:

class X
    # empty class

(So a class with just a comment as class body).

from snow.

huynhminhson avatar huynhminhson commented on July 17, 2024

I am writing Magento modules and it has many empty classes. Thanks for your solution, class X with comments works. But I met two others issues. Please help.

class X extends Y
    # empty class
Fatal error: Class 'Y' not found in D:\Program\Snow\snow.php(201) : eval()'d code on line 2
class Hms_HomeTabs_Block_HomeTabs
    # empty class
Fatal error: Uncaught exception 'Exception' with message 'Unable to parse input: given input is no T_EXPRESSIONS:
class Hms_HomeTabs_Block_HomeTabs
    # empty class
null' in D:\Program\Snow\snowcompiler.php:368
Stack trace:
#0 D:\Program\Snow\snow.php(169): SnowCompiler->compile()
#1 {main}
  thrown in D:\Program\Snow\snowcompiler.php on line 368

from snow.

AndCake avatar AndCake commented on July 17, 2024

Thank you for your feedback - this is very helpful!

Now for your two new issues: the first one tries to find class Y, since you try to inherit from it, but is unable to do so. So you need to make sure that class Y is defined in the current scope (either by defining it or by including it).

The second issue: I will change the class identifier definition to actually support underscores in the middle of the name. Until this is implemented, you can try using camel-case instead.

from snow.

huynhminhson avatar huynhminhson commented on July 17, 2024

Thanks for your reply :) I think I should write plain PHP until Snow support underscores because Magento modules use underscores in class names to identify MVC and folder structure so I cannot use camel-sase or any other approaches.

from snow.

AndCake avatar AndCake commented on July 17, 2024

The above commit should fix the issue with underscores in class identifiers and also makes the class body optional.

from snow.

Related Issues (15)

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.