Giter Club home page Giter Club logo

Comments (7)

AD7six avatar AD7six commented on June 1, 2024

example?

from cakephp-codesniffer.

rhelms avatar rhelms commented on June 1, 2024

Two examples, because one of them can probably be done better.

The first is from the cakephp/Datasources project, the LdapSource.php. I have a pull awaiting approval.

/**
 * If you want to pull everything from a netscape stype ldap server 
 * iPlanet, Redhat-DS, Project-389 etc you need to ask for specific 
 * attributes like so.  Other wise the attributes listed below wont
 * show up
 */
public function setNetscapeEnv() {
    $this->OperationalAttributes = 'accountUnlockTime aci copiedFrom ' .
    'copyingFrom createTimestamp creatorsName dncomp entrydn entryid ' .
    'hasSubordinates ldapSchemas ldapSyntaxes modifiersName modifyTimestamp ' .
    'nsAccountLock nsAIMStatusGraphic nsAIMStatusText nsBackendSuffix ' .
    'nscpEntryDN nsds5ReplConflict nsICQStatusGraphic nsICQStatusText ' .
    'nsIdleTimeout nsLookThroughLimit nsRole nsRoleDN nsSchemaCSN ' .
    'nsSizeLimit nsTimeLimit nsUniqueId nsYIMStatusGraphic nsYIMStatusText ' .
    'numSubordinates parentid passwordAllowChangeTime passwordExpirationTime ' .
    'passwordExpWarned passwordGraceUserTime passwordHistory ' .
    'passwordRetryCount pwdExpirationWarned pwdGraceUserTime pwdHistory ' .
    'pwdpolicysubentry retryCountResetTime subschemaSubentry';

    $this->SchemaFilter = '(objectClass=subschema)';
    $this->SchemaAttributes = 'objectClasses attributeTypes ldapSyntaxes ' .
    'matchingRules matchingRuleUse createTimestamp modifyTimestamp';
}

The second is from a unit test for the SoapSource of the same project (and same pull request). In this one I've only wrapped across two lines, because the content is not something I particularly care about. Though I'm sure anyone else having to read it might have a differing opinion. This one could be done better (perhaps store the anticipated result in an external file, and the do the comparison, but I digress).

/**
 * Testing getting last request
 * 
 * Calls an actual soap service
 * 
 * @return void 
 */
public function testGetRequest() {
    $config = array(
        'wsdl' => 'file://' . App::pluginPath('Datasources') . 'Test' . DS . 'File' . DS . 'GeoCoderPHP.wsdl'
    );
    $this->Soap = new SoapSource($config);

    $result = $this->Soap->query('geocode', array('location' => '1600 Pennsylvania Av, Washington, DC'));

    $this->assertEquals($result[0]->street, 'Pennsylvania');

    $this->assertEquals($this->Soap->getRequest(),
    '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
    '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://rpc.geocoder.us/Geo/Coder/US/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:geocode><location xsi:type="xsd:string">1600 Pennsylvania Av, Washington, DC</location></ns1:geocode></SOAP-ENV:Body></SOAP-ENV:Envelope>' . "\n");
}

from cakephp-codesniffer.

AD7six avatar AD7six commented on June 1, 2024

I don't think there's anything currently in the standard for line widths. we could add this:

<rule ref="Generic.Files.LineLength">
 <properties>
   <property name="lineLimit" value="120"/>
   <property name="absoluteLineLimit" value="150"/>
  </properties>
</rule>

I think 80 chars is nowadays too restrictive.

The above would warn at > 120, and reject at > 150. For me 150 is the width of a 1/2 width vim session (or approx 1000px). I.e. > 150 is the point where I'd see wrapping if I have 2 sessions side by side (which is how I write code: code|test).

But, those numbers are just suggestions - mark?

Regarding concatenation, I'm not sure - I don't recall ever having problems with the standard when concatenating long strings, though previously I didn't use this standard.

from cakephp-codesniffer.

rhelms avatar rhelms commented on June 1, 2024

How about recommendations for the period (.) placement?

I would suggest something similar to as shown. The period is last on the line, and the expected indenting on the next line is the same, or one more in. If that is something that would even need to be written in.

from cakephp-codesniffer.

markstory avatar markstory commented on June 1, 2024

I don't think there is anything for requiring or not requiring an indent with a trailing concat operator. I know it will complain if there is trailing whitespace after the .

from cakephp-codesniffer.

rhelms avatar rhelms commented on June 1, 2024

Perhaps if the rules for whitespace after the . were modified to stop at the EOL marker, and not comment on the whitespace on the following lines, which it seems to do at the moment.

from cakephp-codesniffer.

AD7six avatar AD7six commented on June 1, 2024

I created two test files with the two examples you've indicated in this ticket - and they both pass the CakePHP code standard without any errors being raised](https://gist.github.com/2519831).

If you're getting errors, please create a test file (see tests/files) and a pull request.

from cakephp-codesniffer.

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.