Giter Site home page Giter Site logo

php54to55's Introduction

Php54to55

This is a collection of sniffs for PHP_CodeSniffer that check an PHP 5.4 application for PHP 5.5 compatibility.

This project is currently under development

Build Status

Requirements

Requires at least PHP 5.3.2 but will not properly test trait names until PHP 5.4.0 or later.

It is suggested that you test compatibility with PHP 5.5 or newer in order to use the most up-to-date PHP parser/ tokenizer.

Features

  • Check for deprecated & removed functions (MySQL, mycrypt_*)
  • Check for /e modifier in regular expressions
  • Check for removed Constants (MySQL)
  • Check for setTimeZoneID or datefmt_set_timezone_id usage
  • Check for definitions of global functions which are new in PHP 5.5
  • Check for definitions of classes that have been added in PHP 5.5
  • Check for definitions of constants that have been added in PHP 5.5

Detailed feature list.

Usage

Add "foobugs-standards/php54to55": "~2" to your composer.json. For example

{
  "require": {
    "foobugs-standards/php54to55": "~2"
  }
}
composer install

# test full standard
vendor/bin/phpcs --standard=php54to55/ /path/to/code

# test a single sniff only
vendor/bin/phpcs --standard=php54to55 --sniffs=Php54to55.Deprecated.Functions /path/to/code

Versioning

The major version reflects PHP_Codesniffer version while minor version reflects the standard revision.

php54to55's People

Contributors

ephigenia avatar reneoelke avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

php54to55's Issues

cleanup for release

Fix non-code stuff for initial release:

  • document covered changes
  • review Readme.md
  • adjust License file
  • adjust class comments

reservedKeyword parser is broken.

Could not parse namespace or class names.

Does fail to abstract as the sniff is registered to match finally keyword only. (may use different issue to track those)

Add sniff for new methods / parameters

Version 5.5.15 coverage

Extend the changelog coverage from current (most of 5.5.0-alpha3) to 5.5.9

Tasks

  • new constants (mostly CURL*)

  • deprecated constants (CURLOPT_BINARYTRANSFER)

  • added opcache_is_script_cached() with 5.5.11

  • review of intl changes (may not yet cover all

    Added the classes: IntlCalendar, IntlGregorianCalendar, IntlTimeZone, IntlBreakIterator, IntlRuleBasedBreakIterator and IntlCodePointBreakIterator
    Added the functions: intlcal_get_keyword_values_for_locale(), intlcal_get_now(), intlcal_get_available_locales(), intlcal_get(), intlcal_get_time(), intlcal_set_time(), intlcal_add(), intlcal_set_time_zone(), intlcal_after(), intlcal_before(), intlcal_set(), intlcal_roll(), intlcal_clear(), intlcal_field_difference(), intlcal_get_actual_maximum(), intlcal_get_actual_minimum(), intlcal_get_day_of_week_type(), intlcal_get_first_day_of_week(), intlcal_get_greatest_minimum(), intlcal_get_least_maximum(), intlcal_get_locale(), intlcal_get_maximum(), intlcal_get_minimal_days_in_first_week(), intlcal_get_minimum(), intlcal_get_time_zone(), intlcal_get_type(), intlcal_get_weekend_transition(), intlcal_in_daylight_time(), intlcal_is_equivalent_to(), intlcal_is_lenient(), intlcal_is_set(), intlcal_is_weekend(), intlcal_set_first_day_of_week(), intlcal_set_lenient(), intlcal_equals(), intlcal_get_repeated_wall_time_option(), intlcal_get_skipped_wall_time_option(), intlcal_set_repeated_wall_time_option(), intlcal_set_skipped_wall_time_option(), intlcal_from_date_time(), intlcal_to_date_time(), intlcal_get_error_code(), intlcal_get_error_message(), intlgregcal_create_instance(), intlgregcal_set_gregorian_change(), intlgregcal_get_gregorian_change() and intlgregcal_is_leap_year()
    Added the functions: intltz_create_time_zone(), intltz_create_default(), intltz_get_id(), intltz_get_gmt(), intltz_get_unknown(), intltz_create_enumeration(), intltz_count_equivalent_ids(), intltz_create_time_zone_id_enumeration(), intltz_get_canonical_id(), intltz_get_region(), intltz_get_tz_data_version(), intltz_get_equivalent_id(), intltz_use_daylight_time(), intltz_get_offset(), intltz_get_raw_offset(), intltz_has_same_rules(), intltz_get_display_name(), intltz_get_dst_savings(), intltz_from_date_time_zone(), intltz_to_date_time_zone(), intltz_get_error_code(), intltz_get_error_message()
    Added the methods: IntlDateFormatter::formatObject(), IntlDateFormatter::getCalendarObject(), IntlDateFormatter::getTimeZone(), IntlDateFormatter::setTimeZone()
    Added the functions: datefmt_format_object(), datefmt_get_calendar_object(), datefmt_get_timezone(), datefmt_set_timezone(), datefmt_get_calendar_object(), intlcal_create_instance()
    #5 will add the remaining changeset (some class and function names, the finally keyword).

Add sniff for methods that changed return value

From HipChat:

  • wir haben keinen Sniff/ Workflow für Methoden mit veränderten Rückgabewerten (möglicher BC-Bruch bei exakter Typprüfung; unwahrscheinlich)

From PHP migration documentation:

mark phpcs-incompatibility

As we opted for composer dependency with implicit autoloading this project no longer defines a PHP_CodeSniffer Standard and can no longer be directly executed using the phpcs binary.

This should be reflected by the documentation.

Sync existing sniffs with official PHP changelog

From HipChat:

Den Stand dokumentieren und gegen das Changelog abgleichen. Auch habe ich bisher aus dem Changelog nahezu keine Bugfixes angesehen, was nicht 100% ausschließt, dass wir alle neuen Funktionen/ Konstanten/ Klassen haben. Ebenfalls nicht abgeglichen ist, ob tatsächlich alle Funktionen und Konstanten der MySQL-Erweiterung erfasst wurden. Das ist wahrscheinlich, aber nicht garantiert.

https://github.com/php/php-src/blob/PHP-5.5/NEWS

php requirement

You set a >= 5.5 for PHP dependency. But it does work with composer dependency (5.3.x) with the only issue being unsupported trait, callable, instanceof and finally keywords.

I would rather have a E_NOTICE or E_USER_WARNING issued by the ReservedKeywordSniff or a notice/ message issued by the binary.

The trouble arising with a high requirement is the increase with each new PHP release.
We never talked about this but may want to now:

  • do we support only the most recent PHP tokenizer
  • or do we skip a subset for older tokenizers

This may effect handling of distinct PHP interpreters like HHVM if we decide to test against those (as codesniffer itself does).

prepare alpha release

Targeting an installable, easy to use standard that executes the current features set bug-free as far as covered by unit tests.

Current state:

  • must drop namespaces
  • utilise phpcs 2 (for better reporting, compatibility; current feature was developed for early phpcs 1.4)
  • have a look at the test suite and fix issues

Quiet some work needed to get it executable and some more to ensure it does cover enough issues and does proper reporting.

@Ephigenia @reneoelke is there any immediate need of better reporting? Newest phpcs allows to adjust reporting a great deal. Maybe you could provide some requirements on this issue?

Fix alpha release test-suite

Fix all those issues:

  • all deprecated function sniffs test class namespace for function names which is not needed as they can not collide (temporarily disabled tests for this edge case)
  • RegexpEModifierSniff does not test multiple modifiers
  • RegexpEModifierSniff does not test heredoc (maybe only tests quoted strings)
  • ForbiddenClassNamesSniff buggy (for alpha dev branch)
  • ForbiddenFunctionNamesSniff does test case sensitive. Function names are case-insensitive
  • ForbiddenClassNamesSniff ignores namespace

integration testing migration

Currently we have a hard requirement for shells as we call the binary with each integration test case.

As discussed integration testing itself will be maintained. We however opted to drop the shell requirement.

This will have some implications:

  • the testsuite requires CodeSniffer classes
  • a broken Sniff might kill the phpunit process

implicit /vendor name dependency

Not sure this is important but bootstrapping (and possibly further files) require composer vendors to be located within /vendor.

This however can not be enforced for composer installs.

directory structure (discussion)

@reneoelke I would like to opt for /Sniffs to only hold phpcs-integration while we keep a distinct path for abstracted/ common logic.

Otherwise it might get ugly once we start to further abstract sniffs and new developers try to add/ edit those amongst other classes.

Suggest directories:

/Sniffs     for sniffs only (minimal, like with minimal MVC controllers)
/src         for classes
/test        for unit tests

(As we do not use a phpcs-style wrapper the /Tests/ may be misleading.)

An other point would be literal extraction. In order to support minor PHP versions or distinct major versions the actual lists would grow to be a major distraction. As with most localisation approaches I would like to have them in their own files.

This may be a /properties path at top level cloning the full /Sniffs tree or /properties/ /Properties subdirectories for all Sniffs that require them.
With those files we reduce LoC-per-file ratio and may simplify things as you either edit literals within the properties file or logic within the Sniff. The latter would get even more standardized and shortened.

On a side-note: autoloading for /src should suffice and result in cleaner /Sniffs as inheritance is restricted to non-sniff-classes.

RegexpEModifierSniff can not handle `x` modifier

Parsing free form regular expressions may not be possible with current phpcs capabilities.

For the following test case

preg_replace(   "`
    # some comment
    (</?)(w+)
    ([^>]*>)
`xe",
    "'\1'.strtolower('\2').'\3'", $html_body);

phpcs reports a single T_CONSTANT_ENCAPSED_STRING per line and strips the ending delimiter completely.

If there is no explicit, reasoned demand for it I am not going to implement this case any time soon.

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.