[wp-trac] [WordPress Trac] #54323: Too few arguments for function (closure)

WordPress Trac noreply at wordpress.org
Wed Oct 27 23:03:26 UTC 2021


#54323: Too few arguments for function (closure)
-------------------------------------------------+-------------------------
 Reporter:  aristath                             |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  5.8.2
Component:  Script Loader                        |     Version:
 Severity:  major                                |  Resolution:
 Keywords:  has-patch needs-unit-tests fixed-    |     Focuses:  coding-
  major                                          |  standards
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:7 jrf]:
 > > However, it was deemed acceptable because in this scenario, the
 anonymous function enqueues a stylesheet and doesn't do anything else...
 >
 > While the above is true, I still think it should be changed as it may
 give new(er) contributors the impression that closures as hook callbacks
 are acceptable. Consistency is key in these things and having a rule like
 this applied inconsistently only provides confusion and leads to repeated
 discussions about it (''why is it allowed there, but not here ?'').

 That makes perfect sense to me :) I agree, let's change this to a proper
 callback. Worth noting that another instance of a closure as a hook
 callback was also committed recently in [51902] and would need a similar
 change.

 > > It would definitely be a great idea, looks like there are no tests for
 enqueue_block_styles_assets() yet. The original changesets, [46111] and
 [51471], did not have any tests either.
 >
 > Ouch. That's just painful. Old code not having tests I can understand,
 we're playing catch-up. But greenfields new code being introduced without
 tests or with insufficient tests is something I'd really like to
 eradicate.

 Also agree here. But how do we resolve this? Code like this is merged from
 Gutenberg. I find the current pace of Gutenberg development a bit too fast
 to keep up or wrap my head around it enough to write meaningful tests.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54323#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list