1. PHP / Говнокод #26950

    0

    1. 1
    2. 2
    Trying to get property '%s' of non-object:   Notice -> Warning
    Undefined property: %s::$%s                  Notice -> Warning

    тут брейкинг ченджес подвезли

    https://wiki.php.net/rfc/engine_warnings

    Fike, 14 Сентября 2020

    Комментарии (46)
  2. PHP / Говнокод #26948

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    public function getFlagCode()
    {
        $code = $this->_storeManager->getStore()->getCode();
    
        switch ($code) {
            case 'us':
                return 'us';
                break;
            case 'eu':
                return 'eu';
                break;
            default;
                return 'ww';
        }
    }

    denistrator, 14 Сентября 2020

    Комментарии (7)
  3. C++ / Говнокод #26947

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    catch (Exception &exception)
    	{
    		Application->ShowException(&exception);
    	}
    	catch (...)
    	{
    		try
    		{
    			throw Exception("");
    		}
    		catch (Exception &exception)
    		{
    			Application->ShowException(&exception);
    		}
    	}

    https://github.com/greatis/Anti-WebMiner/blob/master/AntiWebMiner.cpp#L23

    MAKAKA, 13 Сентября 2020

    Комментарии (85)
  4. C++ / Говнокод #26946

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    foreach ($files as $n => $f) {
        $new_content = $common.$namespace_begin.$f.$namespace_end;
    
        $std_methods = array();
        preg_match_all('/std::[a-z_0-9]*/', $new_content, $std_methods);
        $std_methods = array_unique($std_methods[0]);
    
        $needed_std_headers = array();
        $type_headers = array(
            'std::move' => '',
            'std::vector' => '',
            'std::string' => '',
    // [...]
            'std::unordered_set' => 'unordered_set');
        foreach ($type_headers as $type => $header) {
            if (in_array($type, $std_methods)) {
                $std_methods = array_diff($std_methods, array($type));
                if ($header && !in_array($header, $needed_std_headers)) {
                    $needed_std_headers[] = $header;
                }
            }
        }
    
        if (!$std_methods) { // know all needed std headers
            $new_content = preg_replace_callback(
                '/#include <([a-z_]*)>/',
                function ($matches) use ($needed_std_headers) {
                    if (in_array($matches[1], $needed_std_headers)) {
                        return $matches[0];
                    }
                    return '';
                },
                $new_content
            );
        }

    Тут вот в https://govnokod.ru/20049 CHayT предлагал использовать «PHP» в качестве препроцессора для «C» — так вот в «Телеграме» совет оценили и решили взять на вооружение.
    https://github.com/tdlib/td/blob/master/SplitSource.php

    gost, 13 Сентября 2020

    Комментарии (20)
  5. Python / Говнокод #26945

    +1

    1. 1
    2. 2
    3. 3
    https://docs.python.org/3.9/whatsnew/3.9.html#optimizations
    
    См 38 -- > 3.9

    MAPTbIwKA, 11 Сентября 2020

    Комментарии (10)
  6. Java / Говнокод #26944

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    try {
    	throw new SQLException();
    } catch (SQLException e) {
    	logger.error("error while updating "
    		+ e.getMessage());
    }

    нет слов

    ld50, 11 Сентября 2020

    Комментарии (23)
  7. C++ / Говнокод #26943

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    #include <vector>
    #include <cwchar>
    #include <algorithm>
    #include <iostream>
     
    int main()
    {
        std::vector<const wchar_t*> leaders{L"Ленин", L"Сталин", L"Маленков",
            L"Хрущёв", L"Брежнев", L"Андропов", L"Черненко", L"Горбачёв"};
     
        std::sort(leaders.begin(), leaders.end(), [](auto strA, auto strB) {
            return std::wcscmp(strA, strB) < 0;
        });
     
        std::setlocale(LC_ALL, "en_US.utf8");
        std::wcout.imbue(std::locale("en_US.utf8"));
        for (auto leader : leaders)
            std::wcout << leader << '\n';
    }

    Отсюда:
    https://en.cppreference.com/w/cpp/string/wide/wcscmp

    Naf-Naf, 11 Сентября 2020

    Комментарии (14)
  8. Си / Говнокод #26942

    +6

    1. 1
    2. 2
    #define add(x, y) &((void*)x)[y];
    #define mul(x, y) (sizeof (char[x][y]))

    из свитера

    3.14159265, 10 Сентября 2020

    Комментарии (337)
  9. PHP / Говнокод #26940

    0

    1. 1
    2. 2
    3. 3
    foreach ($properties->xml->ЗначенияСвойства as $property) {
        //......
    }

    $properties->xml->ЗначенияСвойства

    hrustbb2, 10 Сентября 2020

    Комментарии (12)
  10. PHP / Говнокод #26939

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    # Alternative mysql_real_escape_string without mysql connection
    
    function escape_string($param) {
        if(is_array($param))
            return array_map(__METHOD__, $param);
    
        if(!empty($param) && is_string($param)) {
            return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $param);
        }
    
        return $param;
    }
    
    #Using example
    $name       = @trim(escape_string(stripslashes($_POST['name'])));

    https://gist.github.com/wilnaweb/ca37459bdf92aa74bd2dd7994fa5b0df

    real_escape_string, 09 Сентября 2020

    Комментарии (6)