Issues

ZF-1308: Coding standards compliance, including private method names

Issue Type: Task Created: 2007-04-23T15:37:50.000+0000 Last Updated: 2008-02-26T12:56:07.000+0000 Status: Resolved Fix version(s): - 1.0.4 (26/Feb/08)

Reporter: Darby Felton (darby) Assignee: Simone Carletti (weppos) Tags: - Zend_Service_Audioscrobbler

Related issues: Attachments:

Description

The private Zend_Service_Audioscrobbler::getInfo() method does not follow coding standards for private and protected method names:

Though function names may not contain the underscore character, class methods that are declared as protected or private must begin with a single underscore, as in the following example:

<pre class="highlight">
class Zend_Foo 
{ 
    protected function _fooBar() 
    { 
        // ... 
    } 
}

Other members of this component, such as $testing and $testing_response also should be modified to comply with coding standards.

I should also recommend considering whether private is the appropriate designation for such class members. Though sometimes appropriate to use private, it is generally the case that making class members protected allows for an appropriate public API while providing for extensibility through class inheritance.

Comments

Posted by Simone Carletti (weppos) on 2008-01-08T03:15:53.000+0000

I contacted Chris, I'm going to take in charge this fix. :)

@ Darby

Considering that those methods/variables were declared as protected, I assume it's safe to change their scope/name for the next ZF release (1.5). There shouldn't be any BC issue.

Do you agree?

Posted by Darby Felton (darby) on 2008-01-08T08:19:51.000+0000

Well, I do not agree that there is no BC issue. Obviously people who have extended the class could be affected. However, because the likelihood of such extension for this component seems minimal, and because the BC impact deals only with naming (e.g., not behavioral changes to class logic), I do not see insurmountable problems arising with making the changes for 1.5. Thanks for looking at this, Simone! :)

Posted by Simone Carletti (weppos) on 2008-01-08T08:40:07.000+0000

Obviously people who have extended the class could be affected.

Perhaps I confused PHP behavior with Java... but as far I remember (in PHP) child classes haven't access to parent private methods but only to protected or public ones. But may be I'm wrong, I'm going to run more tests.

I do not see insurmountable problems arising with making the changes for 1.5.

Great, I'm going to fix this ticket asap.

Posted by Darby Felton (darby) on 2008-01-08T08:47:01.000+0000

bq. Perhaps I confused PHP behavior with Java... but as far I remember (in PHP) child classes haven't access to parent private methods but only to protected or public ones. But may be I'm wrong, I'm going to run more tests.

Yes, of course, I meant that renaming protected methods could affect extending classes.

Thanks again! :)

Posted by Simone Carletti (weppos) on 2008-01-08T09:39:34.000+0000

fixed in r7364

Posted by Simone Carletti (weppos) on 2008-01-29T14:39:00.000+0000

Merged to branch/release-1.0 (r7688), target changed to mini release.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts