« first day (2622 days earlier)      last day (2326 days later) » 
02:00 - 13:0013:00 - 00:00

1:18 PM
hello guys
i am working with regular expression
 
If $_SERVER['argv'] exists in code, calls to getenv() will return argv and argc – #75712
php.ini documentation fails to mention zend.assertions – #75711
 
Wes
uh new shiny github
 
@eduardo2207fromPanama you most likely don't want /u
it changes the meaning of \d and has no other effect on that expression
actually in saying that I'm now not 100% sure about that
but regardless, it's not doing anything useful in that expr
 
@DaveRandom ok but actually i made some test and i got error
let me show you
 
I can show you the world
 
1:22 PM
public function testShouldValidationCedulas()
{
$consultaSivi = new ConsultaSivi();

$cedula = '1-728-2208';
$this->assertTrue($consultaSivi->validarCedula($cedula));

$cedula = 'asdfasdf';
$this->assertTrue($consultaSivi->validarCedula($cedula));

$cedula = ['asdfasdf', '8-88-22'];
$this->assertTrue($consultaSivi->validarCedula($cedula));

$cedula = ['8-88-22', 'asdfasdf'];
$this->assertTrue($consultaSivi->validarCedula($cedula));

$cedula = ['8-88-22', '8-88-33', 'asdfasdf'];
$this->assertTrue($consultaSivi->validarCedula($cedula));
 
Shining, shimmering splendid
 
real answer: 1. true 2. false 3. false, 4. false , 5. false , 6. true 7. false , 8. false , 9 false rest false
 
the assertEmpty() and assertNotNull() seems like a bad test
the method should always return either true or false
also I would say that the Validator should be refactored so it can be reused
 
yes the method should always return false and i did
the real problem when it's an array
i dont have problem when it's string but when it's an array that turn difficult
because i should validate every id car
 
I hate to sound like a language-ist ...
but the correct language for code is english ...
 
1:26 PM
I would approach that problem (arrays) a little differently
 
yes thank you @JoeWatkins
 
if the input is always either scalar or an array of scalars, it's better to always treat it as an array, imho
that way you only have to write one set of rules
or rather, one implementation of the logic
$validator = Validator::make($rules);

foreach ((array)$input as $value) {
    if (!$validator->isValid($value)) {
        return false;
    }
}

return true;
That pattern will always work both when $input is a scalar value or an array of scalar values
if you cast a scalar to an array, it becomes an array with one element in it
 
not i have big problem with foreach because doesnt work pretty well for me
so i prefered work with while
 
that method is called validateIdentificationCard ...
it's kinda strange to be able to pass more than one whatever isn't it ?
 
Yes I dislike that as well
better to know the type of your input
 
1:30 PM
okay
let me show you
differents inputs
 
Yes I get the idea, the point is that you shouldn't do that. I know PHP does it internally a lot, but it also shouldn't do that
 
hold on ...
 
Wes
i'm covered in mdf dust
it smells like poo
 
hahaha lol
@Wes
 
do you have an abstraction of this identification card ?
 
Wes
1:32 PM
this thing is so nasty
 
3-728-2208 correct
1-728-2208 correct
22PI-55555-666666 incorrect
PE-333-333 correct
PÉ-1-4444 incorrect
N-4444-55555 incorrect
Ñ-22-22 incorrect
E-1-1 incorrect
 
because you shouldn't be able to construct an invalid one ... in so doing, it means that any method that accepts an id might be working with an invalid one ...
I'd probably make validation a private method on the abstraction of the id itself, rather than a complex separate object ...
 
I would make a VO, personally
 
anything that accepts one of these objects must know it is valid before it works on it, or else there is going to be nonsense branches everywhere to deal with invalid ids
 
@JoeWatkins yes it's true because at the moment i made a method stop when one card id is wrong
 
1:33 PM
$id = new IdentificationNumber($input);
 
let me show you my code at the moment
 
Then validate the input in the ctor, and throw if it is invalid
 
ಠ_ಠ Is that supposed to a response to my comment about changing the title? Or is that directed at something/someone else?? — Sam Onela Dec 12 at 19:01
 
^that
 
https://codereview.stackexchange.com/questions/181424/php-oop-api-class?noredirect=1#comment347201_181424

https://codereview.stackexchange.com/questions/180330/validation-of-identification-card-fields-string-and-array/180444#180444
i feel shame about my code but
 
1:34 PM
oh, I'm not going to review any code ... I do that all day long ... and I can tell you it's wrong already without looking :)
 
okay @JoeWatkins
1. English code
2. ?
 
wonky abstraction
 
Wes
TIL people still use PHP.
 
I'm so long you can't get me all in focus, and I need a human bed ...
 
1:50 PM
@eduardo2207fromPanama 3v4l.org/q4Ou0
 
@Wes tweet should be more like we are one in millions
 
@DaveRandom checking
 
That way, you can declare that your code requires a valid identification number, and you know that it is valid because you can't create an instance of that class without it being valid
It also has the advantage that you can represent the "parts" of the ID and do different things with them
if that's a thing you need to do
I don't know, it might not be
 
i wrote this code in laravel
 
irrelevant
OOP is OOP (and laravel is not really OOP, but that's another story)
 
1:54 PM
@DaveRandom can I ask you somthing about that code? Do you use throwing exceptions in constructors or rather create named constructor like private constructor and static method which creates object and that method throws exception? I couldn't find which is a better way in therms of good practice.
 
@brzuchal I use named ctors when I want overloads
 
okay @DaveRandom
 
Only then yes?
@DaveRandom so you think throwing exceptions in standard ctor is ok then, yes?
 
@brzuchal That's the only way you can "fail" a ctor, so yes
The issue is that you shouldn't put business logic in a ctor
like, you shouldn't throw because you failed to do something, because you shouldn't try to do anything
 
Laravel uses TOP: Taylor Orientated Programming, or Taylor Otwell Programming
11
 
1:57 PM
but validating input is not "business logic"
 
I often mark ctor as private and throw exception in named ctor to fail, but I didn't know if this is a good approach
 
Well there's no functional difference
 
@JoeWatkins lol
 
Thx @DaveRandom
 
I suppose there's an argument that it's best to avoid the overhead of creating an object if you can, and thus if you are using named ctors then you should throw in the static method rather than the actual ctor
but that is full-on micro optimisation
 
2:00 PM
you don't optimize error paths
(there is no point, they include a stack trace)
 
@brzuchal the rule is: 1) can someone else read it? 2) can it be tested? If yes to both, then do it. If no to either, then do something else.
 
if no to both, kill yourself ...
 
"Is it fast(er)?" is a question you ask when you have a performance problem, not before
 
yeah, there are millions of PHP developers, so I suppose someone would be able to read it :)
 
@JoeWatkins Or everyone else in the whole world
 
2:02 PM
Ok, thx
 
they are the only options ...
 
@brzuchal yeh, you want to be aiming for at least 50% :-P
If only you and @bwoebi can read it, you have a problem
 
or Marco ...
 
Yeh that's probably a good metric. "Does it look like code your would find in Doctrine?" -> do something else
I have been working on code recently that one might describe as "reflection af" and it is driving me up the wall
 
Guys, naming helpz: What's a good clever name to give to a bot that reports deployments to staging/production environments?
 
2:16 PM
How about "Steve"?
 
Sexy Steve
 
Deployment Dan
 
@Fabor That'll work until we recruit someone named Steve
 
'sup?
Also, this is fine:
user image
3
 
DeploymentNotifier ? Nickname DepNo
 
2:18 PM
Johnny Dep
 
The heck Danack
 
No you can't call it that
 
Robert DepNiro
 
Deploy Chopra
 
El Chupacabra
I got it...
Botty McBotface
@Jeeves What should @MadaraUchiha call his bot?
 
2:23 PM
@Fabor Whatever you want. As long as it good.
 
useless
 
Gee thanks Jeeves
 
@Jeeves what is your name?
 
@DaveRandom 42
 
@Jeeves what is your favourite colour?
 
2:24 PM
@DaveRandom 42
 
"clever"bot
 
!!error
 
It's @PeeHaa's fault
 
damn straight
 
Anonymous
 
Anonymous
2:28 PM
if anyone is interested
 
Anonymous
!!wotd
 
facepalm the gesture of placing the palm of one's hand across the face, as to express embarrassment, frustration, disbelief, etc. (often used as an interjection): She read the post and comments and did a facepalm. Okay, that was dumb—facepalm!
2
 
imacs and beer, I'm out ...
 
@MadaraUchiha fine ... Adolf ...
 
2:33 PM
well honestly
i have a lot of for work
 
@JoeWatkins lolwut
 
@samayo it's a Laravel job, where senior devs thing that Symfony is similar to it
also, they think that "you will get an Apple computer" is a bonus
all in all, it sounds like some start-up
 
Start up culture tends to suck. Bean-bag chair lovin' bureaucrats.
 
it sounds like the sort of place where the CTO is a designer
 
"We work hard, we play hard". AKA paid 40, work 80 but we'll buy you a pizza.
 
2:40 PM
I cannot think of any other reason why they would have macs
 
Actually overall I would say "don't work for digital agencies"
It's a glorified factory production-line of CMS based websites.
 
There's not necessarily anything wrong with that, it depends whether you want to write code or spend all day configuring things
> XML Schema: Structures introduces a mechanism for signaling that an element should be accepted as ·valid· when it has no content despite a content type which does not require or even necessarily allow empty content. An element may be ·valid· without content if it has the attribute xsi:nil with the value true.
has anyone got any idea why that would make any sort of sense and why anyone would use that?
 
/me waves
@DaveRandom have a nullable field?
 
2:55 PM
@ircmaxell minOccurs = 0 though
that seems to be a way to enforce something being valid despite minOccurs > 0
which seems weird
 
only if it's empty
 
Anonymous
@Danack Is that Slim or Silex?
 
which means it's equivilant to minOccurs|0 where 0 implies nil (assuming xsi:nil)
 
Oh right, so like a type of ?int[], where null elements are permitted
explicit null vs undefined
 
@DaveRandom Rather (?int)[]?
 
2:58 PM
@kelunik I think (int[])?
because the int isn't nullable unless the child also has xsi:nil
 
[] really shouldn't be used for arrays, it doesn't play nice with ?.
 
I think I am going to ignore this possibility for now and implement it if/when it becomes an actual thing that happens
because it's breaking my head a bit
 
hey
i found an example in javascript
 
Runs for cover
 
3:00 PM
well, it's not in english
 
I'll start giving a fuck about javascript ... never ...
 
and, as it has been mentioned before, the validation should go in "value objects" (for input rules") or "domain objects" (for business rules)
at least in PHP
 
/^P$|^(?:PE|E|N|[23456789]|[23456789](?:A|P)?|1[0123]?|1[0123]?(?:A|P)?)$|^(?:PE‌​|E|N|[23456789]|[23456789](?:AV|PI)?|1[0123]?|1[0123]?(?:AV|PI)?)-?$|^(?:PE|E|N|[‌​23456789](?:AV|PI)?|1[0123]?(?:AV|PI)?)-(?:\d{1,4})-?$|^(PE|E|N|[23456789](?:AV|P‌​I)?|1[0123]?(?:AV|PI)?)-(\d{1,4})-(\d{1,5})$/i
 
@DaveRandom what ya building?
 
3:06 PM
@DaveRandom why me? Do I have a talent for deciphering the most unreadable code? :-P
 
@bwoebi You write it, so I guess you're also able to decipher it. :P
 
@ircmaxell initially a tool for code-gen from WSDL. Moving forwards, possibly a full userland async-first SOAP implementation.
Initially though I need some code-gen tools for a really badly build SOAP service, and nothing existing is doing what I want.
*set of services
 
public function validarCedula($cedula)
{
$cedula = (array) $cedula;
$rules = ['cedula' => 'required|required'];
$i = 0;
$isValidCedula = true;
$cedulaCounter = count($cedula);

while ($i < $cedulaCounter && $isValidCedula) {
$input = ['cedula' => $cedula[$i]];
$validator = Validator::make($input, $rules);

if ($validator->fails()) {
$isValidCedula = false;
}
$i++;
}

return $isValidCedula;
}
 
not this again
 
if it was just one I would probably just write it by hand, it would be quicker :-P
also I have a tool I built ages ago and I opened it up and was ashamed, so it's partially a vanity project
 
3:11 PM
that's some of the strangest code I have ever had the misfortune to read :)
 
@DaveRandom I haven't found mapping WSDL 1 to 1 to actual classes is that helpful, as I want the classes to have interfaces that are useful to my system.
@DaveRandom I only map the classes I specifically want to interact with.
 
@jjok This is one of the things I am going to cater for with what I am building - I am going to generate traits rather than classes
Which is basically a poor-man's way to do partial class, which is what I really want (a la C#)
 
@DaveRandom Hmmm. Interesting... And the traits just contain the property names that are in the WSDL?
 
Yes, the traits contain the actual properties that make the VO work, and I will generate a class ActualThing { use Thing; } if (and only if) it doesn't already exist
 
@DaveRandom why SOAP? Why not Swagger?
(or one of the newer ones)?
 
3:22 PM
So you can rebuild against an updated WSDL without blowing away your custom code
 
@DaveRandom Have you found a use for traits? :O
 
@ircmaxell because there are at least 30 SOAP APIs that I talk to (I'm only building a client)
Building a SOAP server in PHP would be sort of insane :-P
@jjok yeh I was also surprised but I can't actually think of a reason it won't work
and it actually seems like a good use for them
I'd rather have partial classes but I takes what I can gets :-P
that wouldn't play nice with PSR-4 anyway
 
@DaveRandom I maintain a couple of SOAP APIs actually. Maybe you're calling them? :P
 
If so, you better run now
:-P
 
ah ok :D
 
3:31 PM
@DaveRandom Is it on Github or anything?
 
yesss ... gift (but the brown version, not blue) for my younger brother arrived
thought, I suspect it might be a bit too small for €50 banknotes
 
@jjok not yet, at least not in any form that is anything like the current state, but github.com/DaveRandom/XsdDistiller will be part of it (that also is quite different locally)
brb 10 mins
 
3:44 PM
@tereško nice
 
@James youtube.com/watch?v=5ssyiVFtWj4 ... Define 6 is out
 
@tereško That's an expensive wallet.
 
@Fabor not really
IMHO, the "expensive wallet" category starts from €100
that's the number at which I start thinking about whether something is worth it
 
Mine cost about £5. Maybe I am just not a wallet guy.
 
I like well made things :D
 
3:59 PM
I don't have wallet,there is just small cover where i put my id.
 
good morning
 
@Orangepill morning
 
Morning.
 
@Linus ah, yeah, I bought a thing like that for myself too ... it actually arrived yesterday :D
 
4:14 PM
anyone got any experience of/opinions about sendgrid?
 
buying stocks or using service?
 
using service :-P
 
\o
 
4:29 PM
Serialization bug: wrong variable name length – #75713
 
Guys, do you know tomorrow is the longest night in the year?
 
@tereško :D
 
the longest night... that might well be the best dnd3 adventure I ever played
witchfire trilogy. to my fellow geeks: that is a recommendation.
 
morning ppl
 
4:37 PM
\o
 
@Shafizadeh yes, in Europe there a various celebrations for winter solstice ... but most of those pagan festivals have been ... emm .. absorbed into "christmas" which will be in 5 days
 
5:19 PM
Nite aĺl
 
5:39 PM
@tereško I see
 
5:54 PM
I know there are good reasons not to use a goto in general :P But is there any particular reason why we disallow goto inside a while? Inside a for I get why we can't but I'm not sure about the while case
 
@pmmaga We do not permit goto to jump into a looping structure.
It's just one of things of principle: unrestricted goto is bad so let's make sure that our goto is not nearly as terrible as that.
 
@LeviMorrison yes, I meant into. I was curious if it was purely design choice or something else. Into a for makes sense to be disallowed because there is an given state on every iteration.
I was think that for a while that was not necessarily the case (it's just a condition!) but I forgot about the case where you are assigning something on the condition i.e. while($line = fgets(...
 
6:10 PM
@LeviMorrison yeah, so, to jump into a while loop, you just replace the loop with two gotos?
 
@bwoebi Yes. At that point you are asking for any punishment you get, though :D
 
6:38 PM
@pmmaga There are two reasons
The first is that some loops (foreach and switch) have additional state, so it's not possible to directly jump into them without taking care of that
We wouldn't want to allow only jumping into some loops, now would we?
The second is that jumping into a loop renders control flow irreducible
Now we don't really have a problem with that, and in fact you can also achieve this in other ways, but this is what makes a goto from a loop and a goto into a loop fundamentally different
 
6:54 PM
Date format Day is J but Example 4 use d – #75714
 
@NikiC well, the switch one is fixable by immediately releasing with a successful case statement … only foreach is impossible to jump into actually
 
hey
i back
i changed my code
public function validarCedula($cedulas)
{
$cedulas = (array) $cedulas;
$rules = ['cedula' => 'required|cedula'];
$valid = true;

foreach ($cedulas as $cedula) {
$input = ['cedula' => $cedula];
$validator = Validator::make($input, $rules);

if ($validator->fails()) {
$valid = false;
break;
}
}

return $valid;
}
i want to know how can i improve that method
when is null?
 
7:19 PM
Nov 30 at 18:07, by tereško
@eduardo2207fromPanama step one: code in english
4 hours ago, by tereško
and, as it has been mentioned before, the validation should go in "value objects" (for input rules") or "domain objects" (for business rules)
 
7:36 PM
 
@DaveRandom hahaha
lol guys you are so bad
 
I give up really 😔😔 I cannot sent an email (as activate registration) which not get spammed 😔 And mailchimp doesnt work ...
 
@mega6382 partially
 
Man what is happening with this world.
 
@mega6382 unfortunately, the video was made to push a specific ideology and portray the opposition as crazy and/or stupid
 
7:43 PM
Yeah, probably.
 
"daily show" has gone to shit :(
 
@tereško Yeah, I love Jon Stewart. I like Trevor Noah too, but you are right it is not the same anymore.
 
8:13 PM
@NikiC irreducible for the Optimizer or already during normal compilation (passtwo() or something similar)
 
Nowadays ad-blockers are just as much trouble as ads.
 
what are you using?
 
AdBlock with the red logo.
Actually I meant it as, every other site want you to whitelist them, otherwise you can't access it.
 
@tereško That's all American politics is.
 
8:44 PM
@pmmaga Irreducible as in, the control flow cannot be partitioned into forward edges (DAG from entry) and back edges (target dominates source)
 
9:08 PM
@NikiC after some further reading that is clear. thanks
 
@NikiC If you have time debugging generators:
#0  zend_generator_throw_exception (generator=0x7fffec732e80,
    exception=exception@entry=0x7fffffff9c70)
    at /home/kelunik/.php-build/release/Zend/zend_generators.c:424
#1  0x0000555555b1fde4 in zim_Generator_throw (execute_data=<optimized out>,
    return_value=0x7fffed021b70)
    at /home/kelunik/.php-build/release/Zend/zend_generators.c:1033
#2  0x0000555555ba021b in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER ()
    at /home/kelunik/.php-build/release/Zend/zend_vm_execute.h:1032
#3  execute_ex (ex=0x7fffec732e80)
Clone github.com/php-http/artax-adapter/pull/11/commits/… and comment out line 72-78 in test/AsyncClientTest.php, then run vendor/bin/phpunit.
 
9:39 PM
yay, finally sorted my steam wishlist
so, what's up, people
 
@tereško If your sorting was any good, your most wanted game.
 
har har har
 
10:04 PM
@kelunik Everything fails with Connection to '127.0.0.1:10000' failed
 
@NikiC Sorry, execute vendor/bin/http_test_server > /dev/null 2>&1 & before.
 
nite ppl
 
@kelunik throw() being called during gc...
where the get_current generator has null execute_data
 
10:32 PM
@FélixGagnon-Grenier How far north in Canadia are you?
 
user9096175
10:45 PM
hi
 
Wes
 
02:00 - 13:0013:00 - 00:00

« first day (2622 days earlier)      last day (2326 days later) »